Page 1 of 1

Portable music/radio streamer using i2s and TFT touchscreen

Posted: Fri Dec 27, 2013 5:44 pm
Hi all.

Here is my take on a portable Pi music player.

Sorry about the washed out colours - they look great in real life (see the Star Wars clip at the end for an idea). Also the backlight fade effect looks strange on the video...

In terms of hardware, in that layer case is:

(a) a modded Pi model A (removed the large connectors and inserted a low dropout regulator so that the Pi can work reliably on battery power);

(b) an i2s DAC ( ... l_v100.pdf )

(c) one of texy's TFT displays ( ... 93&t=53144), with a new connector to make it sit closer to the Pi

(d) an arduino that monitors the battery voltage and shuts down the Pi if it gets too low (the vid does not show the button under the screen that switches on the Pi which is also managed by the arduino)

Mame is controlled by a Nintendo wavebird with its receiver hacked to an arduino Leonardo plugged into the USB port so that it presents itself as a HID keyboard/analogue joystick (not shown in video)

In terms of software it uses:

(i) the latest November 2013 version of Arch

(ii) koalo's i2s kernel (the new one based on 3.10 ... =44&t=8496 and

(iii) to which I have added notro's TFT display kernel drivers (

(iv) MPD

(v) a few configurations/startup scripts

The result is a MPD mini-client that wirelessly streams internet radio stations and my server-based CD collection. It will also work with locally (to the Pi) stored CD rips. In terms of output it uses standard 3.5mm jacks that I plug into headphones or to a Minirig speaker and subwoofer. Sound quality is really excellent (IMO) but I paid some attention to shielding the DAC from the Pi. Note that as this uses MPD, any MPD client can control the device (at one stage I had a web front end but dropped it as the iPhone interface through mPod worked really well).

A bash build script based on what I was using is here:

Note that although this script will work on a model B with "gpu_mem=16" in config.txt, it is not the one I actually used (I cross-compiled and it will probably take about 12 hours to run on a Pi) you will need a lot of spare SD card space and there is a lot more you will need to do to get the overall solution working as I have it… Also note that the script runs once then reboots and then you will need to run it again post-reboot. Finally note that the script is based on kernel drivers still in the throws of very active development on the i2s 3.10 side, I imagine koalo will very shortly update the i2s drivers such that the hacks I have deployed to get the thing working will no longer be required (and may break the script).

Here is the link to the main code:

It is with some trepidation that I am posting the code here - not because I don't want anyone to use it (it is freeware - or more precisely, I will not enforce any copyright against anyone in the world and the code can be issued under any licence anyone wants) but because it is not very well written (in terms of style - I should really have objectified it - and it is probably the best example of how not to write) and because I imagine that I am making a rod for my own back if anyone wants to try to replicate the device…

Note that the code does not include the link with the arduino (for battery monitoring/shutdown) and for the link to MAME (this works but is not very good, the commented out code results in a segfault that I suspect was due to pygame not having the chance to exit cleanly before advmame was called, my eventual solution uses a bash script as this was quicker than investigating the issue).

Future work will be to internalise the battery (but I will need one with a different shape/size).

Thanks to everyone on the forum for their help but especially notro, koalo and texy.

Have fun.


Re: Portable music/radio streamer using i2s and TFT touchscr

Posted: Thu Jan 02, 2014 10:38 am
by koalo
very nice project! Looks great!
What are your actual changes needed in addition to the drivers in the foundation's kernel?


Re: Portable music/radio streamer using i2s and TFT touchscr

Posted: Thu Jan 02, 2014 12:25 pm
by Richard-TX
I took the easy way out when I did my music player. I used a Behringer UCA-202 ($29) as the Rpi audio isn't very good.
I used mpc/mpd since there are free clients for Android, Windows, etc.
I run mpd on the Rpi. It is trivial to create a web page to control mpd or to create your own hardware interface.

Re: Portable music/radio streamer using i2s and TFT touchscr

Posted: Thu Jan 02, 2014 2:54 pm
@koalo/Florian, the changes made to your 3.10.y-asoc version of the kernel were pretty basic. I just copied over the 3.8 card drivers, made a couple of changes to reflect the new platform name etc and inserted a couple of lines in rpi-proto.c to deal with the new bclk ratio (see the end of the main i2s thread and an exchange between me and vadim regarding bclk). The script I attached to the first post in this thread details all the changes made. Note that the script purports to make the changes needed for all the card drivers - I have only tested with the WM8731/proto setup. Also I have no idea whether the bclk ratio I set is the correct one, I looked at the datasheets and the chip driver but it was quicker just to copy the ratio from something else (I can't remember what it was now (I just googled) and the output sounds correct with the number I found).

@Richard-TX, your's looks like a fine solution but I was constrained with using a Model A (for battery usage) and so only one USB port (and that would be taken up with wifi)


Re: Portable music/radio streamer using i2s and TFT touchscr

Posted: Thu Jan 02, 2014 3:05 pm
by koalo
Great, that seems pretty reasonable!
If you like, it would be great if you would rebase your changes against the 3.10 branch (or 3.12 if your like) of the official kernel and send a pull request.

Re: Portable music/radio streamer using i2s and TFT touchscr

Posted: Thu Jan 02, 2014 6:58 pm
Hi Florian.

Will do.