Ikke's Blog

Post details: Maemo/Nokia 770 sound streaming

Jun 14
Maemo/Nokia 770 sound streaming

As I'm not allowed to code last days (studies >:() I tried to get something working I wanted for a long time: be able to run my favorite media player on my desktop (I must confess that's Amarok), and playback the music using a hifi chain in another room.

As currently I don't have a wifi network at home, I can't do "the real thing" yet, but testing can be done using usbnet (little howto on how to set up that might follow later).

After lots of searching and great help on several IRC channels, I got things working fine now.

Let's start with a little overview of the setup.
Desktop:

  • Music player: Amarok using the Xine backend, using alsa
  • Streaming server: Icecast2
  • Icecast source: gst-launch using the shout2cast sink

770:

  • Just the standard audio player

Here's how to set up things correctly:

  • Install icecast2 on your system (this is distribution dependant)
  • Configure the server. You can run icecast as a system service, or as a normal user. I chose to run it as a normal user:
    • Copy /etc/icecast2/icecast.xml to some directory
    • Change "logdir" to some directory you got write permissions for
    • Start the server: icecast -c icecast.xml (add -b to daemonize)
  • Start some media player
  • Now we got to get the media player's output to our icecast server. As the 770 cannot playback ogg/vorbis, but can handle mp3, we'll use mp3 here. I know that might be non-free etc, but let's be pragmatic.

    To get the alsa sound to the server, one might use DarkIce, but I could not get this working, so I used a simple gstreamer pipeline instead:gst-launch-0.10 alsasrc device=plughw:0,0 ! audioconvert ! lame ! shout2send mount=amarok

    You might need to change the "device" parameter, you can change the "mount" parameter of shout2send too (although you'll have to adjust the URI used later too, of course). I'm using the default password ("hackme") in this setup, if you don't, or want to set other options, see gst-inspect-0.10 shout2send for more info.

  • When that's running fine, open a browser, and go to http://localhost:8000. If all goes well, the "amarok" mount should be listed there. Do not open the stream, as this'd create a loop!
  • Finally, launch the audio player on your 770 device, open the menu, "Playlist -> Add Stream...", and enter here the URI of the stream. In my setup, this is http://192.168.2.1:8000/amarok. Now start playback.
  • The 770 should buffer some data, then start playback.

Currently, I stream my Amarok's output to my device using usbnet, and got my normal computer speaker connected to the jack output. Works fine :-)

If you're using Amarok too, take a look at the "Web Control" script. When running this script, you can open the 770's browser, and browse to http://192.168.2.1:4774 (adjust the IP). Now you're able to control Amarok from your device, and look at the current playlist. No need to walk to your desktop. The web interface might need some love though.

That's about it, have fun!

Comments:

Comment from: Stewart Smith [Visitor] · http://www.flamingspork.com/blog/
Dude, awesome!

I'm going to try this ASAIGAFM (As Soon As I Get A Free Minute). I'll blog on how I go with rhythmbox.

The 770 has a 3.5mm jack, right? (mine is downstairs... too lazy to go check). If so, this could be the solution to my loose headphone jack on my laptop. It also means I can hear when people message me (and not have to stop listening to music) as I walk downstairs to make coffee.
PermalinkPermalink 06/14/06 @ 14:28
Comment from: Stewart Smith [Visitor] · http://www.flamingspork.com/blog/
I'm having trouble getting the source right.... I get sound from the microphone, not what's being played... Any hints to find out the right device to pass to alsasrc?
PermalinkPermalink 06/15/06 @ 08:00
Comment from: Ikke [Member] · http://www.eikke.com
First you can try to make sure the non-alsa part works fine, by using something like this on your desktop:
gst-launch-0.10 filesrc location=/path/to/some/ogg/or/mp3 ! decodebin ! audioconvert ! lame ! shout2send mount=test
then see whether something like
mplayer http://localhost:8000/test
works on your desktop, and you can stream on your 770.

If that works, great, only need to get the alsa stuff working.

First you got to make sure your capture device is enabled. I assume here you got only one soundcard.
Start "alsamixer", press Tab, go to the right until you find the "Capture" device. If there's no "CAPTUR" under the level widget, press space, this should enable it. You also might need to lower the level (even to 0), otherwise sound quality will be horrible.

Now, in a terminal, go to /proc/asound/card0. There should be some subdirectories in there with the name "pcmXc", where X is a number. I got pcm0c and pcm1c.

Now you can run something like this:
for i in pcm*c; do echo -n "${i}: "; grep ^name ${i}/info | cut -d":" -f2; done

Here is my output:
pcm0c: Intel 82801BA-ICH2
pcm1c: Intel 82801BA-ICH2 - MIC ADC
This shows my pcm0c subdevice is my soundcard's "mix" channel, as the other one is my mic input.

When you found out what number you need (ie *not* the mix device), you can form the "device" parameter of the alsasrc like this:
device=plughw:0,X
Here "0" is the ID of your soundcard (remember, /proc/asound/card0), X is the number of the subdevice to use (0 on my system, from pcm0c, might be something else on yours).

If you cant get things working like this, just try some values until you found the correct one ;-)
Make sure your capture device is enabled on the alsa-side etc though, as otherwise it won't ever work!
PermalinkPermalink 06/15/06 @ 10:39
Comment from: zach [Visitor] · http://musics-free.info
What should I say? In fact I think there is no need to write a lot. Just thanks. I enjoyed the info above.
PermalinkPermalink 08/25/06 @ 14:42

This post has 4 feedbacks awaiting moderation...

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))

Categories

Who's Online?

  • Guest Users: 151

Misc

XML Feeds

What is RSS?