{"id":598,"date":"2008-11-08T01:01:31","date_gmt":"2008-11-08T08:01:31","guid":{"rendered":"http:\/\/mightyohm.com\/blog\/?p=598"},"modified":"2015-09-26T11:11:11","modified_gmt":"2015-09-26T18:11:11","slug":"building-a-wifi-radio-part-5-lets-make-some-noise","status":"publish","type":"post","link":"https:\/\/mightyohm.com\/blog\/2008\/11\/building-a-wifi-radio-part-5-lets-make-some-noise\/","title":{"rendered":"Building a Wifi Radio &#8211; Part 5, Let&#8217;s Make Some Noise!"},"content":{"rendered":"<p><em>This is the fifth part of an ongoing series at mightyOhm about building a low cost, open source streaming internet radio.\u00a0 If you haven&#8217;t already, check out the previous parts below for some background about the project.<\/em><\/p>\n<p><a href=\"http:\/\/mightyohm.com\/blog\/2008\/10\/building-a-wifi-radio-part-1-introduction\/\">Building a Wifi Radio &#8211; Part 1, Introduction<\/a><\/p>\n<p><a href=\"http:\/\/mightyohm.com\/blog\/2008\/10\/building-a-wifi-radio-part-2-choosing-an-embedded-platform\/\">Building a Wifi Radio &#8211; Part 2, Choosing an Embedded Platform<\/a><\/p>\n<p><a href=\"http:\/\/mightyohm.com\/blog\/2008\/10\/building-a-wifi-radio-part-3-hacking-the-asus-wl-520gu\/\">Building a Wifi Radio &#8211; Part 3, Hacking the Asus WL-520GU<\/a><\/p>\n<p><a href=\"http:\/\/mightyohm.com\/blog\/2008\/11\/building-a-wifi-radio-part-4-installing-openwrt\/\">Building a Wifi Radio &#8211; Part 4, Installing OpenWrt<\/a><\/p>\n<h4>Note:<\/h4>\n<p>The instructions that follow assume that you have an Asus WL-520GU wireless router with the following modifications: an externally accessible serial port, OpenWrt installed and working, and a configured network connection on the router.\u00a0 If not, check out the previous parts of the series to learn more.<\/p>\n<h3>Using opkg to customize OpenWrt:<\/h3>\n<p><a href=\"http:\/\/openwrt.org\">OpenWrt<\/a> includes a utility called <a href=\"http:\/\/wiki.openwrt.org\/OpenWrtDocs\/Packages#head-483764faec3e847c48e0794e875a7823eb4fd3aa\">opkg<\/a> that allows the end user to easily add and remove optional software packages.\u00a0 These packages include functionality that is not a part of the OpenWrt base image, such as hardware drivers (including USB), optional software, and utilities.\u00a0 Most packages are not installed by default (after all, the router only contains 4MB of flash storage).\u00a0 The <a href=\"http:\/\/wiki.openwrt.org\/OpenWrtDocs\">OpenWrt Community Wiki<\/a> includes a <a href=\"http:\/\/wiki.openwrt.org\/OpenWrtDocs\/Packages\">very helpful page about Packages<\/a> that contains a lot of useful information about configuring and using opkg.<\/p>\n<p>Before we can use opkg we need to configure it.\u00a0 The file <em>\/etc\/opkg.conf<\/em> contains a few options, including the URL of the server opkg uses to find and download packages.\u00a0 We need to change this server from the default by modifying the config file:<\/p>\n<blockquote>\n<pre>root@OpenWrt:~# vi \/etc\/opkg.conf<\/pre>\n<\/blockquote>\n<p>Modify the first line to look like this:<\/p>\n<blockquote>\n<pre>src\/gz snapshots <strong>http:\/\/mightyohm.com\/files\/kamikaze-2.4\/packages\/mipsel <\/strong><\/pre>\n<pre>dest root \/<\/pre>\n<pre>dest ram \/tmp<\/pre>\n<pre>lists_dir ext \/var\/opkg-lists<\/pre>\n<\/blockquote>\n<p>You can also download the <a href=\"http:\/\/mightyohm.com\/files\/kamikaze-wl520gu.zip\">complete set of packages<\/a> and set up a server of your own for opkg to access.\u00a0 I have had great success using the <a href=\"http:\/\/www.apache.org\/\">apache<\/a> server included with OS X, but I won&#8217;t cover the setup here.<\/p>\n<p>The following command tells opkg to fetch a list of available packages from the server:<\/p>\n<blockquote>\n<pre>root@OpenWrt:~# opkg update<\/pre>\n<\/blockquote>\n<p>You should see the following response:<\/p>\n<blockquote>\n<pre>Downloading http:\/\/mightyohm.com\/files\/kamikaze-2.4\/packages\/mipsel\/Packages.gz<\/pre>\n<pre>Connecting to mightyohm.com (72.32.209.132:80)<\/pre>\n<pre>Packages.gz\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 100% |*******************************|\u00a0 8326\u00a0 --:--:-- ETA<\/pre>\n<pre>Inflating http:\/\/mightyohm.com\/files\/kamikaze-2.4\/packages\/mipsel\/Packages.gz<\/pre>\n<pre>Updated list of available packages in \/var\/opkg-lists\/snapshots<\/pre>\n<pre>Signiture check for snapshots skipped because GPG support was not enabled in this build<\/pre>\n<\/blockquote>\n<p>Now we can start installing packages.\u00a0 To access our <a href=\"http:\/\/mightyohm.com\/blog\/2008\/10\/inside-the-syba-sd-cm-uaud-usb-stereo-audio-adapter\/\">USB-audio converter<\/a>, we need to install USB 1.1 (OHCI) support and some sound drivers:<\/p>\n<blockquote>\n<pre>root@OpenWrt:~# opkg install kmod-usb-audio kmod-usb-ohci<\/pre>\n<\/blockquote>\n<p>This should automatically install <em>kmod-usb-core<\/em> and <em>kmod-sound-core<\/em>, but if not you can also install them manually with the <em>opkg install<\/em> command.<\/p>\n<p>At this point you should insert the USB-audio converter if you haven&#8217;t already.\u00a0 Then reboot the router:<\/p>\n<blockquote>\n<pre>root@OpenWrt:~# reboot<\/pre>\n<\/blockquote>\n<p>As the router is booting again, watch for new status messages like these:<\/p>\n<blockquote>\n<pre>...\r\nusb-ohci.c: USB OHCI at membase 0xb8003000, IRQ 6<\/pre>\n<pre>usb-ohci.c: usb-00:03.0, PCI device 14e4:471a<\/pre>\n<pre>usb.c: new USB bus registered, assigned bus number 1<\/pre>\n<pre>usb.c: registered new driver audio<\/pre>\n<pre>audio.c: v1.0.0:USB Audio Class driver<\/pre>\n<pre>usbaudio: device 2 audiocontrol interface 0 has 1 input and 1 output AudioStreaming interfaces<\/pre>\n<pre>usbaudio: device 2 interface 2 altsetting 1 channels 1 framesize 2 configured<\/pre>\n<pre>usbaudio: valid input sample rate 48000<\/pre>\n<pre>usbaudio: valid input sample rate 44100<\/pre>\n<pre>usbaudio: device 2 interface 2 altsetting 1: format 0x00000010 sratelo 44100 sratehi 48000 attributes 0x01<\/pre>\n<pre>...\r\nusbaudio: registered dsp 14,3<\/pre>\n<pre>usbaudio: constructing mixer for Terminal 6 type 0x0301<\/pre>\n<pre>...<\/pre>\n<\/blockquote>\n<p>If you see this, the USB-audio converter is most likely working and the correct drivers have been loaded.\u00a0 At this point the green LED inside the USB-audio converter should be lit, another sign that everything is working correctly.<\/p>\n<h3>Installing mpd:<\/h3>\n<p>To actually play some tunes we need to install some additional software.\u00a0 We can use opkg to do this, as follows:<\/p>\n<blockquote>\n<pre>root@OpenWrt:~# opkg update\r\n\r\nroot@OpenWrt:~# opkg install mpd mpc<\/pre>\n<\/blockquote>\n<p>This command installs <a href=\"http:\/\/mpd.wikia.com\/wiki\/Music_Player_Daemon_Wiki\">mpd<\/a>, the music player daemon.\u00a0 mpd is an open source music server that can be accessed locally or across a network by using a variety of <a href=\"http:\/\/mpd.wikia.com\/wiki\/Clients\">clients<\/a>, which are available for many different platforms.\u00a0 This includes the command line client <a href=\"http:\/\/mpd.wikia.com\/wiki\/Client:Mpc\">mpc<\/a> which is also now installed on the router.<\/p>\n<p>mpd requires some setup before we can use it:<\/p>\n<blockquote>\n<pre>root@OpenWrt:~# cd ~<\/pre>\n<pre>root@OpenWrt:~# mkdir .mpd<\/pre>\n<pre>root@OpenWrt:~# mkdir music<\/pre>\n<pre>root@OpenWrt:~# mkdir .mpd\/playlists<\/pre>\n<pre>root@OpenWrt:~# vi \/etc\/mpd.conf<\/pre>\n<\/blockquote>\n<p>Scroll down and look for the audio_output section of the mpd configuration file, and change the reference to <em>\/dev\/dsp<\/em> to make it look like this:<\/p>\n<blockquote>\n<pre># An example of an OSS output:\r\n#\r\naudio_output {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 type\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"oss\"\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"My OSS Device\"\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 device\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <strong>\"\/dev\/sound\/dsp\"<\/strong>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 format\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"44100:16:2\"\r\n}<\/pre>\n<\/blockquote>\n<p>There are many other options you can play with; mpd is very powerful.\u00a0 There is a list of features <a href=\"http:\/\/mpd.wikia.com\/wiki\/Features\">here<\/a> and a lot more information on the <a href=\"http:\/\/mpd.wikia.com\/wiki\/Music_Player_Daemon_Wiki\">mpd wiki<\/a>.<\/p>\n<p>Exit vi, saving the changes to mpd.conf.\u00a0 Now launch mpd with the following command:<\/p>\n<blockquote>\n<pre>root@OpenWrt:~# mpd<\/pre>\n<\/blockquote>\n<p>The player should start silently, without errors.\u00a0 Run mpc and verify that it can talk to the server:<\/p>\n<blockquote>\n<pre>root@OpenWrt:~# mpc\r\nvolume:100%\u00a0\u00a0 repeat: off\u00a0\u00a0 random: off<\/pre>\n<\/blockquote>\n<p>If you see this, good news, the server is running and we have the ability to control it with mpc!<\/p>\n<p>Now would be a good time to connect speakers or headphones to the USB-audio adapter&#8217;s headphone output.\u00a0 <strong>Warning &#8211; the initial volume can be <\/strong><strong>VERY LOUD.<\/strong> Don&#8217;t wear headphones during testing!\u00a0 PC speakers with a volume control are best.\u00a0 Start at a low volume.\u00a0 (My ears are still ringing!)<\/p>\n<p>We can add a streaming radio server to the playlist by executing<\/p>\n<blockquote>\n<pre>root@OpenWrt:~# mpc add http:\/\/relay3.slayradio.org:8000\/\r\nadding: http:\/\/relay3.slayradio.org:8000\/<\/pre>\n<\/blockquote>\n<h3><strong>And finally, the moment of truth:<\/strong><\/h3>\n<blockquote>\n<pre>root@OpenWrt:~# mpc play<\/pre>\n<pre>http:\/\/relay3.slayradio.org:8000\/<\/pre>\n<pre>[playing] #1\/1\u00a0\u00a0 0:00\/0:00 (100%)<\/pre>\n<pre>volume:100%\u00a0\u00a0 repeat: off\u00a0\u00a0 random: off<\/pre>\n<pre>root@OpenWrt:~#<\/pre>\n<\/blockquote>\n<p>If all goes well, within a few seconds you should hear <a href=\"http:\/\/slayradio.org\/\">Slay Radio<\/a> playing on your headphones or speakers.\u00a0 The Air light on the router should flicker as traffic crosses the WiFi interface, and the green light on the USB-audio converter should flash repeatedly to indicate that audio is being sent to the device.<\/p>\n<p>If you&#8217;ve made it this far, I recommend celebrating with your <a href=\"http:\/\/www.flickr.com\/photos\/mightyohm\/2680813515\/\">favorite beverage<\/a> and enjoying some tunes!\u00a0 Congratulations!<\/p>\n<p>You can add other servers to the playlist by executing the <em>mpc add<\/em> command again, and then play them with the <em>mpc play n <\/em>command, where <em>n<\/em> is the position of the server in the playlist.\u00a0 <em>mpc playlist<\/em> will display the current playlist. <em>mpc help<\/em> will give you a list of available commands.<\/p>\n<p>One very powerful feature of mpd is that it operates as a server on port 6600 of the router, so it can be controlled from any other device on your local network.\u00a0 If you download an mpd client such as <a href=\"https:\/\/theremin.sigterm.eu\/cgi-bin\/trac.cgi\">Theramin<\/a>, you can control the router remotely from your desktop computer.\u00a0 There is an excellent <a href=\"http:\/\/www.katoemba.net\/makesnosenseatall\/mpod\/\">client for the iPhone<\/a> too.<\/p>\n<p>That&#8217;s it for part five.\u00a0  I hope you have enjoyed the series thus far.\u00a0 In part six, we&#8217;ll start writing some scripts to control mpd and talk about options for a user interface.\u00a0 If you are building a Wifi Radio of your own, I&#8217;d love to hear about it &#8211; leave a comment below!<\/p>\n<p><strong>Update:<\/strong> <a href=\"http:\/\/mightyohm.com\/blog\/2008\/12\/building-a-wifi-radio-part-6-a-conversation-with-mpd\/\">Part six<\/a> is now available.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the fifth part of an ongoing series at mightyOhm about building a low cost, open source streaming internet radio.\u00a0 If you haven&#8217;t already, check out the previous parts below for some background about the project. Building a Wifi Radio &#8211; Part 1, Introduction Building a Wifi Radio &#8211; Part 2, Choosing an Embedded &hellip; <a href=\"https:\/\/mightyohm.com\/blog\/2008\/11\/building-a-wifi-radio-part-5-lets-make-some-noise\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Building a Wifi Radio &#8211; Part 5, Let&#8217;s Make Some Noise!<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[443],"tags":[36,70,66,97,76,68,24,71,81,162],"class_list":["post-598","post","type-post","status-publish","format-standard","hentry","category-projects-2","tag-diy","tag-embedded-linux","tag-linux","tag-mpd","tag-music","tag-openwrt","tag-project","tag-streaming-radio","tag-usb","tag-wifiradio"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pioCd-9E","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":367,"url":"https:\/\/mightyohm.com\/blog\/2008\/10\/building-a-wifi-radio-part-2-choosing-an-embedded-platform\/","url_meta":{"origin":598,"position":0},"title":"Building a Wifi Radio &#8211; Part 2, Choosing an Embedded Platform","author":"Jeff","date":"October 17, 2008","format":false,"excerpt":"This is the second part of an ongoing series about building a low cost, open source streaming internet radio.\u00a0 if you haven't already, check out part one for some background about the project. Onward... In part one, I discussed the merits of streaming internet radio and the motivations for my\u2026","rel":"","context":"In &quot;Electronics&quot;","block_context":{"text":"Electronics","link":"https:\/\/mightyohm.com\/blog\/category\/electronics\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/10\/hammer_01-large-150x150.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":480,"url":"https:\/\/mightyohm.com\/blog\/2008\/10\/building-a-wifi-radio-part-3-hacking-the-asus-wl-520gu\/","url_meta":{"origin":598,"position":1},"title":"Building a Wifi Radio &#8211; Part 3, Hacking the Asus WL-520GU","author":"Jeff","date":"October 30, 2008","format":false,"excerpt":"This is the third part of an ongoing series about building a low cost, open source streaming internet radio.\u00a0 If you haven\u2019t already, check out part one and part two for some background about the project. Hacking the Asus WL-520GU Wireless Router: In the last part of this series, I\u2026","rel":"","context":"In &quot;Electronics&quot;","block_context":{"text":"Electronics","link":"https:\/\/mightyohm.com\/blog\/category\/electronics\/"},"img":{"alt_text":"","src":"http:\/\/www.awltovhc.com\/image-3238164-10440897","width":350,"height":200},"classes":[]},{"id":470,"url":"https:\/\/mightyohm.com\/blog\/2008\/10\/detailed-specs-for-the-asus-wl-520gu-uber-hacking-platform\/","url_meta":{"origin":598,"position":2},"title":"Detailed specs for the Asus WL-520GU uber hacking platform","author":"Jeff","date":"October 27, 2008","format":false,"excerpt":"In my previous post about the Wifi Radio project I'm working on, I concluded that the Asus WL-520GU wireless router was the perfect choice for an embedded wireless platform, thanks to its builtin 802.11g WiFi, Linux support, and extremely low cost. (In fact, the price after rebate has dropped since\u2026","rel":"","context":"In &quot;Projects&quot;","block_context":{"text":"Projects","link":"https:\/\/mightyohm.com\/blog\/category\/projects-2\/"},"img":{"alt_text":"Asus WL-520GU Wireless Router","src":"https:\/\/i0.wp.com\/mightyohm.com\/files\/flickr\/2950279643_374493fa81.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1902,"url":"https:\/\/mightyohm.com\/blog\/2009\/05\/sneak-peak-at-my-finished-wifi-radio-project\/","url_meta":{"origin":598,"position":3},"title":"Sneak peek at my finished Wifi Radio project!","author":"Jeff","date":"May 28, 2009","format":false,"excerpt":"While I'm busy working on part ten of my series on building a wireless router-based DIY streaming internet radio, I couldn't resist sharing a few photos of the finished project. If you want to see the radio in person, stop by Expo Hall Booth 166 at the Maker Faire in\u2026","rel":"","context":"In &quot;Electronics&quot;","block_context":{"text":"Electronics","link":"https:\/\/mightyohm.com\/blog\/category\/electronics\/"},"img":{"alt_text":"Finished Wifi Radio","src":"https:\/\/i0.wp.com\/mightyohm.com\/files\/flickr\/3567609195_79760d88fe.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":516,"url":"https:\/\/mightyohm.com\/blog\/2008\/11\/building-a-wifi-radio-part-4-installing-openwrt\/","url_meta":{"origin":598,"position":4},"title":"Building a Wifi Radio &#8211; Part 4, Installing OpenWrt","author":"Jeff","date":"November 3, 2008","format":false,"excerpt":"This is the fourth part of an ongoing series about building a low cost, open source streaming internet radio.\u00a0 If you haven\u2019t already, check out parts one, two, and three for some background about the project. At this point you should have an Asus WL-520GU wireless router with a serial\u2026","rel":"","context":"In &quot;Projects&quot;","block_context":{"text":"Projects","link":"https:\/\/mightyohm.com\/blog\/category\/projects-2\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/11\/openwrt_logo.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1655,"url":"https:\/\/mightyohm.com\/blog\/2009\/04\/video-hacking-the-asus-router-for-the-tweet-a-watt\/","url_meta":{"origin":598,"position":5},"title":"Video: Hacking the ASUS router for the Tweet-a-Watt","author":"Jeff","date":"April 6, 2009","format":false,"excerpt":"As I mentioned last week, Adafruit Industries is hacking the Asus WL-520gU wireless router to talk to the Tweet-a-Watt. Their hack is based on the work I did to create my Wifi Radio project. Check out the video below to learn more about their cool hack!","rel":"","context":"In &quot;Electronics&quot;","block_context":{"text":"Electronics","link":"https:\/\/mightyohm.com\/blog\/category\/electronics\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts\/598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/comments?post=598"}],"version-history":[{"count":28,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts\/598\/revisions"}],"predecessor-version":[{"id":4986,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts\/598\/revisions\/4986"}],"wp:attachment":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/media?parent=598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/categories?post=598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/tags?post=598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}