mardi 5 mars 2013

Stream your music to remote speakers

If you want to listen to music playing on your Macbook on remote speakers, this post is for you.

My setup :
- a Macbook playing music with Spotify
- a Google TV hooked up with great speakers

Simple $25 solution:
- install Airfoil on the mac
- install any airplay app on the Google TV, such as Airtight
- the setup is straightforward

Other solution (free or  $40 if you cannot live with relaunching the app every hour):
- install Nicecast on the mac
- install tinyPlayer on the Google TV
- in Nicecast, open the Source tab, select your source app (for example Spotify)
- in Nicecast, click on Start Broadcast
- in Nicecast, open the Share tab and note the streaming address. (for example http://192.168.1.2:8000/listen.m3u)
- in tinyPlayer, click on the menu button ( ⋮ ) and select More
- in tinyPlayer displayed menu, in the Stream category, click on URL and enter the previous address without the listen.m3u, for example http://192.168.1.2:8000

I prefer the Nicecast solution over the Airfoil one because with Nicecast you can stream the music to any device/app that can open an audio stream. Also, from my experience, Nicecast is less prone to network congestion.

But my current favorite solution uses some cool open source apps:
- icecast: a streaming server, it streams any sound data sent to it to the network
- soundflower: a sound app router, it redirects sound from one app to another
- butt: a streaming tool,  it sends sound from a sound device to icecast (or shoutcast)

The setup will look like :
spotify → soundflower → butt → icecast → any device that can stream http audio

By the way, soundflower is necessary because it can mute the macbook's speakers while redirecting spotify's output to butt.

Installation
Soundflower and butt both have .dmg package. To install icecast I suggest using another really useful tool for MacOS: brew. It's an apt-like tool. Once installed, just run brew install icecast.
Note that soundflower need a restart of MacOS.

Configuration
During the configuration I suggest you leave Spotify playing some music so you know where the sound is going.
icecast need a configuration file. You can use this simple one : icecast.conf.
In the soundflower menu, select None for both output:


Then click on the Audio Setup item. In the following dialog, right click on the Soundflower (2CH) item and select "Use this device for sound output".


At this step, you should have no sound at all.

You can now run icecast: icecast -c ~/path/to/icecast.conf

You can finally configure butt. Select Soundflower (2CH) in the Audio Device menu. Click on ADD on the Server category and fill it with the info from icecast.conf.


At this step, there should be no sound yet but you should see that butt is receiving sound.
To start streaming, click on the butt's Play button.


You should now be able open the music stream by accessing http://192.168.1.2:8000 from another device with a browser, VLC, or any other audio player.





2 commentaires:

Michael Cinquin a dit…

Hi

thanks for the solutions, appreciate the documentation details.

Any idea how to do the same, but with very little audio delay ? Currently it looks like 10 sec delay, I would need < .5 seconds delay

cheers

Maxime Rafalimanana a dit…

I know http://jackaudio.org/ is specialized in low latency audio. But I have not tried it yet.