<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tender Lovemaking &#187; raop</title>
	<atom:link href="http://tenderlovemaking.com/category/raop/feed/" rel="self" type="application/rss+xml" />
	<link>http://tenderlovemaking.com</link>
	<description>The act of making love, tenderly.</description>
	<lastBuildDate>Sat, 26 Jun 2010 02:57:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Streaming KEXP with Ruby</title>
		<link>http://tenderlovemaking.com/2007/07/23/streaming-kexp-with-ruby/</link>
		<comments>http://tenderlovemaking.com/2007/07/23/streaming-kexp-with-ruby/#comments</comments>
		<pubDate>Mon, 23 Jul 2007 16:23:38 +0000</pubDate>
		<dc:creator>Aaron Patterson</dc:creator>
				<category><![CDATA[computadora]]></category>
		<category><![CDATA[raop]]></category>

		<guid isPermaLink="false">http://tenderlovemaking.com/2007/07/23/streaming-kexp-with-ruby/</guid>
		<description><![CDATA[A while back, I ported JustePort from C# to Ruby so that I could play music on my AirportExpress. The result was a library called raop-client. Unfortunately, after writing that, I found that there were no libraries in Ruby to decode MP3s. So I wrote a wrapper around Lame called icanhasaudio. Right now, it only [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, I ported <a href="http://nanocr.eu/software/justeport/">JustePort</a> from C# to Ruby so that I could play music on my <a href="http://www.apple.com/airportexpress/">AirportExpress</a>.  The result was a library called <a href="http://raop.rubyforge.org/raop-client/">raop-client</a>.  Unfortunately, after writing that, I found that there were no libraries in Ruby to decode MP3s.  So I wrote a wrapper around <a href="http://lame.sourceforge.net/">Lame</a> called <a href="http://seattlerb.rubyforge.org/icanhasaudio/">icanhasaudio</a>.  Right now, it only lets you decode MP3s, but I plan on adding new features soon.</p>
<p>So, I decided to write a little program that will stream music from <a href="http://kexp.org/">KEXP</a> to my Airport Express.</p>
<pre class="brush: ruby;">
require 'rubygems'
require 'raop'
require 'icanhasaudio'
require 'socket'

rd, wr = IO.pipe

decoder = Thread.new(rd, wr) { |read, write|
  reader = Audio::MPEG::Decoder.new
  socket = TCPSocket.new('kexp-mp3-128k.cac.washington.edu', '8000')
  socket.puts(&quot;GET / HTTP/1.0\r\n\r\n&quot;)
  until(socket.readline == &quot;\r\n&quot;); end
  reader.decode(socket, write);
  write.close
}

sleep 2

raop = Net::RAOP::Client.new('192.168.1.173')
raop.connect
raop.play rd
raop.disconnect
rd.close

decoder.join
</pre>
<p>I&#8217;ll try to explain a little how this works.  First I open a pipe which will be used to buffer my decoded mp3.  The pipe is passed in to a new thread where my poor mans shoutcast client hooks up to KEXP and starts decoding the mp3 into the pipe.</p>
<p>Meanwhile the main thread waits a couple seconds to make sure there is data in the buffer, connects to the Airport Express, then starts streaming the data from the pipe.</p>
]]></content:encoded>
			<wfw:commentRss>http://tenderlovemaking.com/2007/07/23/streaming-kexp-with-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Stream music to your Airport Express with Ruby!</title>
		<link>http://tenderlovemaking.com/2007/06/14/stream-to-your-airport-express-with-ruby/</link>
		<comments>http://tenderlovemaking.com/2007/06/14/stream-to-your-airport-express-with-ruby/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 15:54:35 +0000</pubDate>
		<dc:creator>Aaron Patterson</dc:creator>
				<category><![CDATA[computadora]]></category>
		<category><![CDATA[raop]]></category>

		<guid isPermaLink="false">http://tenderlovemaking.com/2007/06/14/stream-to-your-airport-express-with-ruby/</guid>
		<description><![CDATA[I just released raop-client which lets you stream music to your Airport Express with ruby. Just install the gem: gem install raop-client [/sourcecode] Here is a sample program which takes decoded input from stdin: require 'raop-client' raop = Net::RAOP::Client.new(ARGV[0]) raop.connect raop.play $stdin raop.disconnect Just use the program like this: % lame --decode -q some_song.mp3 - [...]]]></description>
			<content:encoded><![CDATA[<p>I just released <a href="http://raop.rubyforge.org/">raop-client</a> which lets you stream music to your Airport Express with ruby.</p>
<p>Just install the gem:<br />
<code><br />
gem install raop-client<br />
[/sourcecode]</p>
<p>Here is a sample program which takes decoded input from stdin:</p>
<pre class="brush: ruby;">
require 'raop-client'

raop = Net::RAOP::Client.new(ARGV[0])
raop.connect
raop.play $stdin
raop.disconnect
</pre>
<p>Just use the program like this:<br />
<code><br />
% lame --decode -q some_song.mp3 - | ruby streamer.rb 192.168.1.173<br />
[/sourcecode]</p>
<p>You'll have to supply your own mp3 and Airport Express IP address.  Also, raop-client currently doesn't decode music, so you'll have to decode the music yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://tenderlovemaking.com/2007/06/14/stream-to-your-airport-express-with-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
