Technology analysis of the latest gadgets, consoles, and computer architectures.

Monday, May 21, 2012

Koss Striva Pro on WebOS Linux

Bluetooth is ubiquitous and works well with WebOS, so why would I want to stream using WiFi headphones? That is the question I might expect a common reader to have, and my response is simple: WiFi is everywhere. The Internet is the modern delivery mechanism for music; this has been established with iTunes, Amazon, Pandora, and Spotify at the forefront. If music is arriving from the Internet, why not connect directly to the source using your headphones?

Koss recently launched a WiFi music platform called Striva, the portal of which is found at myKoss.com. The website allows for the definition of music channels and the configuration of hardware. The Striva Pro, Koss's first WiFi headphone to hit the market, can connect to any predefined WiFi APs (such as a home network, a mobile hotspot, and a work network), and it will also connect to any truly open WiFi AP (like those sometimes found at your local coffee shop). When connected to a WiFi AP, the music playing on the headphones is displayed and can be controlled via myKoss. A custom channel and stream can also be added as long as it is an Icecast or Shoutcast stream (pls and IP:PORT both accepted). This is how I am able to listen to my music at home, since I am using mpd (Music Player Daemon) and icecast2 for streaming.

Since WebOS is based on Linux, only a few steps are required to properly configure your HP TouchPad or Palm Pre to stream music, audiobooks, and podcasts directly without using a Koss CAP (Content Access Point). I decided to use a chrooted Ubuntu filesystem for ease of setup and access to a UI for music control. I have a 2GB img file in /media/internal that I mount to /media/ext3fs, but for the basic set of instructions refer to this WebOS-Internals page.

Once you have XTerm and the UbuntuChroot installed and configured, you can use Xecutah to launch a terminal in both workspaces. Note: the following Linux configuration may also work on Android or jailbroken iOS with minor tweaks.

WebOS IP Configuration
Before we can setup mpd and icecast2 to play and stream music, respectively, it is advantageous to have a dynamic DNS, and port forwarding must be setup for the music to flow via WiFi. I am using a free account from Dynamic DNS and the utility ez-ipupdate, available via Preware/Optware.

In order to update the dynamic DNS with the WiFi IP, the interface parameter found in /opt/etc/ez-ipupdate.conf must be set to 'eth0'. The script '09update-ddns' should be placed in /etc/network/if-up.d/ to ensure that it is executed when a new WiFi connection is established. Note: I have seen this work on WebOS 3.x, but I have to manually execute the script to update on 2.x.

Finally, IP port forwarding must be enabled for the icecast2 (default: 8000) and mpd (default: 6600) ports. I created the following script in /etc/init.d/mpd_server.sh to configure iptables:

#!/bin/sh
/usr/sbin/iptables -I INPUT -p tcp --dport 8000 -j ACCEPT
/usr/sbin/iptables -I INPUT -p tcp --sport 6600 -j ACCEPT

MPD/Icecast Configuration
Within the Ubuntu chroot, as user 'root', execute the following commands:

'apt get mpd'
'apt get icecast2'
'apt get lame'

To configure mpd to output to icecast2 by default, open /etc/mpd.conf comment out the default 'audio_output' and uncomment the default "shout output". I set my 'mount' to '/mpd.mp3', commented out 'bitrate' and added a line for 'quality' set to '5.0'. The 'password', 'name', and 'description' can also be set to preference. Also, you will need to comment out 'bind_to_address' to allow control from an external network.

To configure icecast2, open /etc/icecast2/icecast.xml and modify the passwords to match that set in mpd.conf.

Add Music and Start Streaming
The default music location is /var/lib/mpd. In order to gain access to your mp3s, the chroot bind needs to be defined for /media/internal.

Start by creating the mount point in the ext3 partition.

'mkdir -p /media/ext3fs/ubuntu-natty-chroot/internal'

Modify /media/cryptofs/apps/usr/palm/applications/org.webosinternals.ubuntu-natty-chroot/bin/chroot-wrapper.sh and add the following:

'mount --bind /media/internal ${CHROOT}/internal'
'umount ${CHROOT}/internal'

This will automatically bind the /media/internal partition to /internal within the Ubuntu chroot. Add the music directories you would like to index as a soft link within /var/lib/mpd/music/:

'ln -s /internal/HPMusic /var/lib/mpd/music/HPMusic'

Within the Ubuntu chroot terminal, start the icecast2 process followed by the mpd process.

'/etc/init.d/icecast2 start'
'/etc/init.d/mpd start'

To update the Dynamic DNS IP and enable port forwarding, execute the following from within XTerm:

'/etc/init.d/mpd_server.sh'
'/etc/network/if-up.d/09update-ddns'

Finally, to setup and control music through mpd, install one or both of the following clients within the Ubuntu chroot:

'apt-get install mpc'
'apt-get install sonata'

Music Control
To update the music database, execute the following command within the Ubuntu chroot:

'mpc update'

To add your entire music collection to the current playlist:

'mpc listall | mpc add'

And finally, to start playing music:

'mpc play'

Custom Stream
Add a custom stream using the dynamic DNS and port number to your myKoss account.

e.g. 'http://icecast.dyndns.org:8000/mpd.mp3'

Select this stream, ensure that the chroot card is focused on WebOS, and power-up the Koss Striva Pro. If everything is configured properly, the headphones will start streaming from your TouchPad or Pre.

Pulse Audio
I was not able to make use of the icecast plugin for pulse audio on the TouchPad. If anyone is able to make any progress on this, please feel free to comment or message me and I will add the details in a future post.

Conclusion
The Koss Striva WiFi platform enables high quality audio streaming directly from your home server and mobile device. While Bluetooth is quick and easy to setup, it does not provide a high quality audio streaming experience (A2DP is equivalent to a 96kbps stream, while the Lame encoder is capable of CD quality at VBR or 320kbps settings). This demonstrates that it is possible for a Linux configuration to stream directly to the headphones. While apps on the PC and mobile devices will provide this capability to the common user with no command-line configuration, this demonstrates how powerful of a platform Striva is. The revolution is truly in the air!