Streaming Internet Radio

I would like to be able to play internet radio music.
Can someone provide me with some guidelines/code example how it can be done?
All the discussions in the forum on this topic were not useful…

Thanks,
Yair

There are a lot of tools and services made for this before. Some are services that you should pay for, and some are free tools that you can configure and use to build this system.

BUT if you want to make it yourself:
You basically need to use a music player library and a server. You must have all of the sound files that needs to be streamed on the server. The server constantly streams the queue to the server. If there is a host platform involved (like you want to stream on YouTube), the server must be connected to the streaming service through its API. If the radio is part of a website, I recommend making the radio a separate service which the website uses.

I think the easiest way would be to code this with Python. If you have more time, you can use Django/Django REST/Flask to make a proper service that also has a ui that enables you to:

  1. Change/edit the song queue and add new songs to it.
  2. Add some controls for starting and stopping the streams
  3. Add some controls for managing the API keys and the base urls. (if you have a host platform)

However I’m sure they have made tools for Django and Flask to make this job way more easier to implement. Also, if you want to stream music on a video platform like YouTube/Twitch, you need to first convert the music stream to a video stream and then stream the video.

Check out this link, there are a lot of useful softwares and libraries there.

I need to develop the player, that will be able to connect to free internet radio stations and play their content.
I would like to use JUCE, as there are several DSP processing features I would like to add to such a player.

Unfortunately all AudioFormatReaders, that JUCE implements, are only geared towards file reading, none is streaming capable. MP3 would theoretically allow streaming, but the JUCE implementation needs the file length to be known in advance, which is the major difference in streams.

I once did this, I licensed https://www.un4seen.com/

Take a look also at superpowered SDK. Advanced features may cost some license fee but when I used their C++ “advanced” player a couple years ago it was pretty powerful.


It’s lately gearing towards web player/framework (I suppose they use wasm) so you could also take a web route, at the price of maybe giving up some DSP features.

Player (c++ version) could do http streaming , play hls, play protected content by setting up appropriate headers/tokens, synchronize streams and apply some basic fx.

When you say “Player (c++ version)” do you mean the Superpowered player?

Also, my main reason to use JUCE is its ability to allow me to perform the required DSP processing on the audio .

Do you know of any way/solution that will allow me to do it in C++?

Yes,
C++ “Advanced Player” has all the possible playback/sync features.

The web counterpart is (at least was last time a checked) much simpler due to lots of multithreading happening behind the scenes in the advanced audio player, even tough if you look ad the docs it looks like it’s catching up.

As far as I remember Superpowered has a “processAudioBuffer” callback paradigm very similar to JUCE, so you could link superpowered sdk in a juce audio app project, and have the advanced audio player work along with the juce callback (properly feeding what superpowered needs in term of audio buffers- time advance). warning : Superpowered advanced audio player costs a license fee.

Of course a playing back “local” audio + applying DSP is perfectly in the scope of juce … you only miss the http stream or HLS part, which SuperpoweredAdvancedplayer would give you out of the box.

As alternatives I’d explore:

  • linking some streaming libraries to JUCE, such as the libraries used by ffmpeg, videolan or gstreamer (yes it’s gonna be painful :slight_smile: ).
  • set up some DIY http streaming class, maybe starting from @adamski juce rest request or the Juce URL barebone class: http streaming is pretty much an async resource web download where you wait 'til you get a “decent amount of frames” before starting playback.
  • look around github for some thin media playback C++ classes/frameworks
    • tip: as far as industry size audio streaming is very tiny if compared to video streaming, so you can broaden your search with terms like “VOD” or “http streaming video C++” to get a more complete picture of what’s available … http video streaming is after all the download of mp4 frames of video+audio instead of the mp3 or aac frames that you download for audio).
2 Likes