Pure Data Radio: how to stream mp3 audio for free

Streaming audio in mp3 format from Pure Data (Pd) is quite easy if you have access to a streaming server, and thankfully there are a number of free hosts out there that you can use to broadcast your audio across the web.

What can you do with this?

Streaming audio from Pd gives they the potential to run your own internet radio station. But, there's more you can do than just that. For one, this gives you the opportunity to create Pd patches that will broadcast live, generative audio streams like Markus Brandt's new production, which you can listen to on a browser that supports .ogg (Firefox 3.5 works), or with VLC, here: http://master.radiofabrik.at:8000/goa.ogg (thanks for sonofsol for posting this on the Pd forums). Alternately you could use it to share your latest Pd compositions, or route the audio from other software into Pd using Jack OS X or similar other tools.

Here's how you do it.

Register for a free account

There are a number of free hosts to choose from, but the one I am most familiar with is freestreamhosting.org. The important thing is that the server be able to support mp3 streaming (Pd can also stream in ogg, but here I will be dealing with mp3 only). Those of you interested in setting up your own private Icecast, Shoutcast, or Darwin Streaming Server will probably not find what you're looking for here, and will be better off checking out the Pd or Icecast FLOSS manuals.

First things first, set up an account at freestreamhosting.org. Go to their website, and register for a free account. This is very easy and straightforward. Be sure to record the Server IP / Host address, which should look something like:

s1.myradiostream.com

You will need this in order to log into your account, and there is no convenient confirmation e-mail to back you up in case you forget. If you've already moved on past the welcome page, this information is available under Stream settings.

Build a simple broadcaster

Next, you need to build a broadcaster in Pure Data. If you don't already have the software, you can download Pd-extended here. For those who have never used Pure Data or its commercial cousin Max/MSP, you may want to do a little research into how these types of programs operate.

The basic broadcaster looks like this:

The elements are as follows:

  • mp3cast~
    The heart, body, mind, and soul of your broadcaster. You just need to provide it with some audio input and a few instructions to sculpt the stream and point it to your streaming server.
  • adc~
    This is the audio input. In this example I am streaming audio from my computer's built-in microphone, but you could substitute any audio source using a variety of Pd objects. If you want to play an audio file, for example, you can take a look at bb_sample in the Pure Data section of this site.
  • shoutcast
    Defines the type of server. Freestreamhosting.org uses Shoutcast servers. Other possible options include "icecast" and "icecast2".
  • passwd streampass
    Sets your password so mp3cast~ can authenticate with the server. This is not your admin password, but the stream password (they are the same by default but can be changed). You can find this on the Stream settings page, and it can be changed under Server management.
  • mpeg 44100 128 1 4
    This message determines your stream settings. Because you will be streaming in mp3, you will always want to start with "mpeg".


    • 44100 is the sample rate, and may be changed to something lower (22050 or even 8000) if desired.
    • 128 is the bitrate. This is measured in kilobits per second (kbps) and may not be set above 128 when using freestreamhosting.org. It may be set lower if you or your listeners only have access to slow internet connections, or if many computers will be connected from the same location. Other common bitrates are 96 and 64.
    • 1 sets the mode. Use 1 for joint stereo and 3 for mono. For other options consult the mp3cast~ help patch.
    • 4 determines the quality on a scale of 1 (highest) to 9 (lowest). The higher the quality setting the more strain on your CPU, so experiment to find a good balance.



  • connect s1.myradiostream.com 29140
    This is the connection message. It must be sent after all the above messages, as it will use their information to connect to your streaming server.


    • s1.myradiostream.com is your server URL / IP address. Your address may be different, and can be found in the Stream settings.
    • 29140 is the port number, which freestreamhosting.org uses as a unique identifier for your channel. Yours will almost definitely be different, and can also be found in the Stream settings.



  • disconnect
    As you would expect, this will disconnect your stream from the server.

The above values will all work as defaults except the password and connect messages, which you must change to match the values for your account.

For more of a graphic interface you can download the bb_mp3caster abstraction here.

Connect to your server

If you have set up your broadcaster correctly, all you have to do is send the configuration messages followed by the connect message. If mp3cast~ is able to create a connection it will output a 1 from its outlet (as seen in the above image), and you will be able to see the stream information on the Statistics page of your freestreamhosting.org account. If not, it's time to troubleshoot.

First, make sure that your password, host url, and port number are all correct. If they are, and you still can't connect, go to the Statistics page. If you see the following message, you need to restart (freestreamhosting.org seems to shut down accounts when they aren't in use in order to conserve system resources).

Listen to your stream

In order to listen to your stream, you must send your audience to a page on freestreamhosting.org, or follow their instructions for embedding a player (and advertisements) on your site. This information can all be found under Tune in links & scripts.

Edit 05-26-2010: sometimes there are extremely long delay times (many minutes) so if you don't hear anything right away but [mp3cast~] is outputting a 1 (meaning it's connected), then just be patient.

That's the basics, now go do something cool with it.