User avatar
Douglas6
Posts: 4950
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is there such a thing as an Pi iPod emulator?

Wed Oct 19, 2016 6:35 pm

Can you plug a USB thumb drive, with mp3s on it, into the car player, and play the songs? If so, you might be able to use the Pi Zero (or just use a USB thumb drive). If not, I don't think the required reverse engineering has been done yet.

Mastiff
Posts: 65
Joined: Tue Oct 18, 2016 6:41 pm

Re: Is there such a thing as an Pi iPod emulator?

Wed Oct 19, 2016 6:38 pm

I do not have a touchscreen, and there will be no touchscreen put in, everything that's visible in the car will be fully original. If this is not possible to do the way I need it to be done, by fully emulating an iPod, it just can't not be done. Then I will use a Windows Carputer with J.River Media Center instead. That can be controlled by a phone, and I can stream to the headunit with Bluetooth, so it's possible to change tracks in the current playlist and see all the info of the track.

Douglas6, you obviously have not read a few posts up. No, it can't be done because I have well over 100K tracks (which is well over a terrabyte), and the max in the Volvo is 10K tracks, as far as I can remember.

broe23
Posts: 902
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: Is there such a thing as an Pi iPod emulator?

Wed Oct 19, 2016 6:56 pm

No touch screen to tell the Pi what to do, you are not going to be able to use it then. You are just spinning your wheels by looking at this how you want it to work in theory, but in real life it will not work, because of the nature of how the Pi works. Even when a Bluetooth device is connected or a device is connected via USB, it becomes a server. When you use Flash Storage, you are just allowing the Head Unit become the server and allow you to control how the music will be played that way.
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

broe23
Posts: 902
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: Is there such a thing as an Pi iPod emulator?

Wed Oct 19, 2016 6:58 pm

Douglas6 wrote:Can you plug a USB thumb drive, with mp3s on it, into the car player, and play the songs? If so, you might be able to use the Pi Zero (or just use a USB thumb drive). If not, I don't think the required reverse engineering has been done yet.
Yes they can. That is how the head units work. They become the server when they see a Flash Media storage device. With the Pi Zero, they are still going to run into the problem that you are decoding the music twice and it will cause it to not sound right. Also you have the risk of Pulse Audio crashing on you and not able to see the errors, unless you have a touch screen on it to allow you to know when there is an error or when to tell the unit to shut down when you leave the vehicle.
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

Mastiff
Posts: 65
Joined: Tue Oct 18, 2016 6:41 pm

Re: Is there such a thing as an Pi iPod emulator?

Wed Oct 19, 2016 7:00 pm

But with an iPod connected to the car there is no other controls than the steering wheel controls, which browses through the library (exit for going one level up, ok to go one level down or play the selected track). An iPod emulator should be able to do exactly that. And it seems like that's what was being worked on in the carputer forum:

http://www.mp3car.com/forum/mp3car-tech ... -emulation

jgreen71
Posts: 92
Joined: Wed May 01, 2013 12:29 pm
Location: Clarksville, IN

Re: Is there such a thing as an Pi iPod emulator?

Wed Oct 19, 2016 8:38 pm

Hey, Mastiff,

I've looked into doing this, and here is what you will need to figure out:

Hardware level:

1. Car has a USB/IPOD port out.
2. Connect via USB cord to a USB slave/device ( like a Teensy ). This is the device to spoof being an IPod at the hardware level. But it just needs a USB A jack on it, not a 30 or fire jack.
3. Connect the Teensy to the RPi ( probably a 2 or 3). This is where I'm stuck, I2C, serial, etc.
4. Connect the RPi to your storage device, USB stick, HDD, SSD, etc.

Software level:
Apple has created their own USB protocol. I don't know if the Teensy can handle it, or can pass-through to/from the RPi. See the link above for the Apple Accessory Protocol.

Good luck

Mastiff
Posts: 65
Joined: Tue Oct 18, 2016 6:41 pm

Re: Is there such a thing as an Pi iPod emulator?

Thu Oct 20, 2016 5:57 am

Thanks! But I'm not able to figure out much, I only know what I would like as the end result. Which is why I aske the question here in the forum. I'm no programmer (except for a bit of LUA and Python for home automation through Girder and EventGhost, with a lot of help) and I'm not hardware hacker at all. I can follow instructions and beta test stuff, but that's about it. :mrgreen:

mutley
Posts: 61
Joined: Sat Jan 02, 2016 8:06 pm

Re: Is there such a thing as an Pi iPod emulator?

Thu Oct 20, 2016 9:23 pm

Mastiff wrote:Thanks! But I'm not able to figure out much, I only know what I would like as the end result. Which is why I aske the question here in the forum. I'm no programmer (except for a bit of LUA and Python for home automation through Girder and EventGhost, with a lot of help) and I'm not hardware hacker at all. I can follow instructions and beta test stuff, but that's about it. :mrgreen:
I can't believe the junk in this tread. You are correct, you could do exact what you want with a piece of software that emulates a iPod running on a Pi. But it would only work with a Pi Zero or Model A as they do not have a built in USB hub, they have a USB port that can be configured in either host or client mode.

So, you could:-

Grab the serial driver from here, and put a Pi in OTG mode https://gist.github.com/gbaman/50b6cca61dd1c3f88f41
Connect a Pi to the Car HU with appropriate USB cable.
(Figure out how the protocol & HU initialize on Advanced Remote (Mode 4) from the below url)
on PI read the commands listed under Advanced Remote (Mode 4) https://nuxx.net/wiki/Apple_Accessory_Protocol, over the USB port and act on said commands.

That will allow you to control the Pi from the car HU as if it's an ipod. Problem is it won't play a dam thing through the car speakers.

For the Audio part, you need to remember the Audio is not actually passed over the standard 4 wire USB connection on an iPod, if you look at this cable http://car-fi.com/ipod-smartphone-integration/ you can see the iPod connection is broken out into USB and Audio line out. So next you simply need to connect the line out on the PI to the Line in on the HU. Since you need Audio line out, this means you can't use a Pi Zero (Well not without an extra board), so Pi model A is your only choice.

Next problem is storage. Your only USB port is connected to the car HU in OTG mode, this means you can't use it for a storage device. And adding a USB hub will mean you can no longer run it in OTG mode, so your have to use a dam big SD card for the OS and MP3 files. (Or find a way to do OTG or Storage via the GPIO headers)

In one of the links posted earlier in this thread, there was the start of some code to read the Apple Accessory Protocol (ipodd.zip) from here http://www.mp3car.com/forum/mp3car-tech ... -emulation.
If I was going to do this, that would be my starting point. A quick look over the code, seems most of the hard part is done, you *may* just be able to compile that, point it at the USB port and it will read the commands from the HU once you setup OTG mode. Looks like the code simply prints out the commands. You would then just need to write the part of the code that plays/stops/ff/rw the MP3 which is simple, there are loads of examples out there that do that.

Depending on what you car HU supports, next you'll need to pass back song information and album art, again looks to be simple from the Accessory Protocol Document.

-- quick edit / update --
This got me thinking so I went out and checked three of my vehicles that have this style HU, the wiring, and playing with the USB interface. Two are absolutely doing exactly as I described above (these have aftermarket HU). The other is actually passing audio over the USB connection along with commands to the iPod (This is a OEM HU) . So either there is another mode not describes in the Apple Accessory Protocol document linked, or mode 4 is incomplete (OR I'm miss-reading it). So that does bring the Pi Zero back into play, but you'll have to figure out the protocol (or find different documentation).

Mastiff
Posts: 65
Joined: Tue Oct 18, 2016 6:41 pm

Re: Is there such a thing as an Pi iPod emulator?

Fri Oct 21, 2016 6:16 am

Thanks for the comprehensive post and a bit of testing! As I said I'm not able to figure out anything, I'm afraid. Which is why I asked the question here. But you are right, there is another mode. In the Volvo there are different choices for AUX and iPod, and I believe choosing iPod stops the audio to the AUX, so the audio comes from the USB plug. I can only imagine that using an iPod will let the car choose what's to be served to the car infotainment system in a way similar to mass storage mode, but via the built-in library in the iPod. Of course a big microSD would not help, since they don't make them in 1,5TB or more (yet). So I would have to get the storage from somewhere else. I thought the multi-pin header on the Pi was IDE (I think I asked about it earlier), but that's probably wrong. So maybe I will have to rethink and instead install J.River Media Center for Linux on the Pi 3B, which I already have. And then use Bluetooth to send audio to the car and my phone (connecting to the Pi with a WiFi router, of which I have a few spare laying around) . That will show track info on the headuint and let me at least jump in the current playlist. But I am still curious what rpiMike is able to find here. :mrgreen:

broe23
Posts: 902
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: Is there such a thing as an Pi iPod emulator?

Fri Oct 21, 2016 7:44 am

Look at Rune Audio. You do have to use a smartphone as the remote control, since you need to be able to control what the Pi is streaming. Otherwise you are going to be at square one. Using a SBC in place of say a iPhone or Android device, your head unit can only be the streaming audio output device, not the controlling device. i imagine that if you have a iPod Touch that does not have that much RAM on it and you want to use that as your remote control, that would work. http://www.runeaudio.com/about/

This is about the MPD interface. You can set it to tell the Pi to play a Playlist and from there it is all hands off. http://www.runeaudio.com/about/#runeui As for music storage, I would use a SSD setup. Also you would be best to use a power USB hub for the Pi and the drives. It is just getting them to fit into a neat package, so that if you wanted to swap SSD units, you can just pull the one connected and replace it with another one. There are also M.2 adapters out there that work with the Pi. http://www.runeaudio.com/about/#runeui
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

broe23
Posts: 902
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: Is there such a thing as an Pi iPod emulator?

Fri Oct 21, 2016 7:54 am

mutley wrote:I can't believe the junk in this tread. You are correct, you could do exact what you want with a piece of software that emulates a iPod running on a Pi. But it would only work with a Pi Zero or Model A as they do not have a built in USB hub, they have a USB port that can be configured in either host or client mode.
The problem is that the iOS stuff is proprietary and Apple will never disclose how it works. All of the projects out there that have tried to emulate iOS for the iPod or act like the iPhone music player, are very outdated projects that nothing has been done with them over 2 or more years. They basically died because the person writing them could not get any farther than they got to before they dropped their project.

Rune Audio looks like it is going to be the best way for them to go with this project.
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

Mastiff
Posts: 65
Joined: Tue Oct 18, 2016 6:41 pm

Re: Is there such a thing as an Pi iPod emulator?

Fri Oct 21, 2016 8:05 am

Thanks, but that's really not that interesting. If I can't use the Pi the way I hoped (as an iPod (which I don't have - I basically hate all iStuff)), I will use J. River Media Center on the Pi instead. That program I know, I have been using it for 15 years in different versions, and I have my library in that format. So that's the route I'll take if the iPod emulator isn't possible.

broe23
Posts: 902
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: Is there such a thing as an Pi iPod emulator?

Fri Oct 21, 2016 8:17 am

Again you are not going to find what you are thinking of. As I have stated many times, there is no one way to do this. The Rune Audio software is the best way to do it and use a iPod touch or your phone to control the playlist.

You keep wanting to argue that it is not what you want, even though the options are very limited, those projects that have tried to emulate iOS has failed, not much else you can do is only give Rune Audio a try and see how it works. Otherwise going with the Carputer is going to cost you more, when you can take the free and easy route.

The problem that you are always going to have is that you have more music than anyone has on this planet in their libraries. The majority of people only stick to a few different albums, even though they may have up to 400 or more albums.

Again try the Rune Audio and see what happens. Worse case scenario is that you will not find a large enough SSD to hold all of your music.
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

User avatar
rpiMike
Posts: 1532
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: Is there such a thing as an Pi iPod emulator?

Fri Oct 21, 2016 11:45 am

This is useful :

http://www.instructables.com/id/Simple- ... /?ALLSTEPS

Looks like I need a resistor on pin 21 to enable serial mode. Trying to get Pi controlling my ipod nano before attempting to get Pi to respond to car stereo ipod commands.

Mastiff
Posts: 65
Joined: Tue Oct 18, 2016 6:41 pm

Re: Is there such a thing as an Pi iPod emulator?

Fri Oct 21, 2016 12:25 pm

broe23, I will see what ripMike finds out. And again, if I can't get this working I will use Media Center, which I know and which has a version that works on the Pi and which stores all my file meta info in it's own proprietary library:

https://yabb.jriver.com/interact/index. ... 027.0.html

rpiMike, thanks! I hope we're on the same page, so you are aware that I want to use the Pi as a full iPod emulator, with both the library on it and the USB contact to the car. There's been so much conflited info here that I'm starting to get confused myself! :mrgreen:

User avatar
rpiMike
Posts: 1532
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: Is there such a thing as an Pi iPod emulator?

Wed Oct 26, 2016 9:39 pm

Made some progress today - managed to get my Pi3 controlling my old iPod Nano via the Apple serial protocol.

Video showing play, next track and pause : https://www.youtube.com/watch?v=UkYxQwO_JZc

Python code :

Code: Select all

import serial
import time

ser = serial.Serial() # open serial port

ser.port = '/dev/ttyS0'

ser.baudrate = 19200
ser.bytesize = serial.EIGHTBITS
ser.parity = serial.PARITY_NONE
ser.stopbits = serial.STOPBITS_ONE
ser.timeout = 10

ser.open()
print(ser.isOpen)
print(ser.name) # check which port was really used

airmode = [0xFF,0x55,0x03,0x00,0x01,0x04,0xF8]

mode2 = [0xFF,0x55,0x03,0x00,0x01,0x02,0xFA]

pauseplay = [0xFF,0x55,0x03,0x02,0x00,0x01,0xFA]
stop = [0xFF,0x55,0x03,0x02,0x00,0x80,0xFB]
volup = [0xFF,0x55,0x03,0x02,0x00,0x02,0xF9]
voldown = [0xFF,0x55,0x03,0x02,0x00,0x04,0xF7]
play = [0xFF,0x55,0x04,0x02,0x00,0x00,0x01,0xF9]
pause = [0xFF,0x55,0x04,0x02,0x00,0x00,0x02,0xF8]

nexttrack = [0xFF,0x55,0x03,0x02,0x00,0x08,0xF3]
prevtrack = [0xFF,0x55,0x03,0x02,0x00,0x10,0xEB]

release = [0xFF,0x55,0x03,0x02,0x00,0x00,0xFB]

print('mode2')
ser.write(serial.to_bytes(mode2))
time.sleep(0.03)

print('play')
ser.write(serial.to_bytes(play)) 
time.sleep(0.03)

print('release')
ser.write(serial.to_bytes(release))
time.sleep(10)

print('nexttrack')
ser.write(serial.to_bytes(nexttrack))
time.sleep(0.03)

print('release')
ser.write(serial.to_bytes(release))
time.sleep(10)

print('pause')
ser.write(serial.to_bytes(pause))
time.sleep(0.03)

print('release')
ser.write(serial.to_bytes(release))

ser.close() # close port

Mastiff
Posts: 65
Joined: Tue Oct 18, 2016 6:41 pm

Re: Is there such a thing as an Pi iPod emulator?

Thu Oct 27, 2016 6:21 am

Nice! So that means that you're able to replicate the protocol to turn it around and let the car control the Pi?

User avatar
rpiMike
Posts: 1532
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: Is there such a thing as an Pi iPod emulator?

Thu Oct 27, 2016 7:39 am

Yes, in theory that should work fine. Does your Volvo have 2 ports, one USB and one ipod connector ? My Range Rover has both, the ipod port requiring a converter cable to the ipod.

Mastiff
Posts: 65
Joined: Tue Oct 18, 2016 6:41 pm

Re: Is there such a thing as an Pi iPod emulator?

Thu Oct 27, 2016 9:03 am

Good! And no, it serves the audio through the USB as well:

https://www.youtube.com/watch?v=fIJWoDD1PoM

Mastiff
Posts: 65
Joined: Tue Oct 18, 2016 6:41 pm

Re: Is there such a thing as an Pi iPod emulator?

Thu Oct 27, 2016 9:44 am

Is that a complication too far? Because if it is, it may be hopeless. I can't control the library on the "PiPod" if I connect to Aux, and then it sort of falls to pieces.

jgreen71
Posts: 92
Joined: Wed May 01, 2013 12:29 pm
Location: Clarksville, IN

Re: Is there such a thing as an Pi iPod emulator?

Thu Oct 27, 2016 7:39 pm

Do you have the USB Host/Device issue worked out? Or are you switching to an RPi0?

Mastiff
Posts: 65
Joined: Tue Oct 18, 2016 6:41 pm

Re: Is there such a thing as an Pi iPod emulator?

Fri Oct 28, 2016 7:36 am

I hope you're asking rpiMike about that. :mrgreen: I'm just following from the sideline, cheering him on! And then I'll buy whatever I need.

n9yty
Posts: 2
Joined: Sun Oct 14, 2012 1:10 am

Re: Is there such a thing as an Pi iPod emulator?

Tue Oct 24, 2017 3:17 am

Trying to connect the dots... I know this is an old thread, but I would love a solution for this, as my iPod classic wont last forever but my HU supports it so well.

Does this help? I am trying to figure out how to test it, new stuff to me.

https://github.com/oandrew/ipod-gadget

Mastiff
Posts: 65
Joined: Tue Oct 18, 2016 6:41 pm

Re: Is there such a thing as an Pi iPod emulator?

Tue Oct 24, 2017 6:38 am

I would still love a way to do this, of course. It's been on the back burner for me since I can't do it myself.

Return to “General discussion”