[Csnd] Plugin opcodes for broadcasting via Shoutcast and Icecast streaming servers

Hi
I have been doing some work with Shoutcast (internet radio) recently and thought it would be fun to make a plugin to stream directly to a server from within Csound. The plugin is in my git repo here:
https://git.1bpm.net/csound-shout/about/

I'm running a test at the moment which you can hear here:
http://1bpm.net:8000/salad.mp3

Not tested extensively so interested for feedback if anyone has use for it.
Internally it uses LAME to stream as MP3 - might be interesting to explore that mechanism between networked Csound instances, as I've had difficulty with socksend/sockrecv for audio - seemingly due to the bandwidth required.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        GitHub · Where software is built
Discussions of bugs and features can be posted here

That's really interesting. Some years ago, I remember Tarmo set up a stream like that where we could go and interact with the server, submitting code to be played.

Using it as a means of sending audio to other instances is also an interesting idea.

Prof. Victor Lazzarini
Maynooth University
Ireland

Hi Richard!
Super interesting work!

But i don’t get how and where you run the Csound file for streaming?

Greetings,
Philipp

Hi Richard!

Brilliant! This is very nice, thank you! I built in and tested on local openSuse Linux machine with icecast server - everything went smoothly and worked as expected.
The only thing I noticed is that running this plugin, Csound eats a lot of CPU - that is a bit of a problem.

It is so convenient to have such and opcode to stream straight from Csound to the broadcasting server! Before I used to use Csound->Jack->DarkIce for sending up the stream but this is so much more convenient.

You mentioned ‘might be interesting to
explore that mechanism between networked Csound instances’

  • how can the other side to receive the sound from the broadcasing server?

And of course then there is the latency problem, that is at least 5 but probably more seconds.

Just to mention - for low-latency audio transfer I find jacktrip a very good tool or Jamulus platform https://jamulus.io/ if you want to play together with several people (or Sonobus, but then the routing from/to Csound can be more difficult to achineve)

Thanks!
tarmo

Kontakt Philipp Neumann (<0000119f78f3a4f9-dmarc-request@listserv.heanet.ie>) kirjutas kuupäeval N, 20. märts 2025 kell 09:32:

Hi Richard!
Super interesting work!

But i don’t get how and where you run the Csound file for streaming?

Greetings,
Philipp

Hi
I have been doing some work with Shoutcast (internet radio) recently and thought it would be fun to make a plugin to stream directly to a server from within Csound. The plugin is in my git repo here:
https://git.1bpm.net/csound-shout/about/

I’m running a test at the moment which you can hear here:
http://1bpm.net:8000/salad.mp3

Not tested extensively so interested for feedback if anyone has use for it.
Internally it uses LAME to stream as MP3 - might be interesting to explore that mechanism between networked Csound instances, as I’ve had difficulty with socksend/sockrecv for audio - seemingly due to the bandwidth required.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Nice!

tor. 20. mars 2025 kl. 01:49 skrev Richard Knight <richard@1bpm.net>:

Hi
I have been doing some work with Shoutcast (internet radio) recently and
thought it would be fun to make a plugin to stream directly to a server
from within Csound. The plugin is in my git repo here:
https://git.1bpm.net/csound-shout/about/

I’m running a test at the moment which you can hear here:
http://1bpm.net:8000/salad.mp3

Not tested extensively so interested for feedback if anyone has use for
it.
Internally it uses LAME to stream as MP3 - might be interesting to
explore that mechanism between networked Csound instances, as I’ve had
difficulty with socksend/sockrecv for audio - seemingly due to the
bandwidth required.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Hi, the streaming happens within Csound itself.
So the connection to the server is setup with the opcodes shoutinit and shoutopen , and then you can pass audio to the shoutsend opcode.

There's a simple example in the repository here, which shows establishing the connection, and then sending a sound to the server:
https://git.1bpm.net/csound-shout/tree/examples/example.csd

I did wonder about something interactive like that. That sounds interesting, would be intrigued to hear more about that setup Tarmo!

Hi, thank you, and really interesting to hear you’ve done things with Csound and streaming before, and glad it is useful!
The MP3 encoding particularly adds some CPU usage but I haven’t found it limiting - in fact it seems lower usage than liquidsoap which I’m currently on the same machine to stream static files. But I would like to get to the bottom of it more and see how it can be optimised - what is your ksmps and does that make a difference on the load? Also maybe the quality setting might make a difference, and would you know roughly how much CPU usage it adds to your csd, just so I get an idea of how bad the problem is? I'm seeing maybe 5 additional CPU on a slow (atom type cpu) box, but with high ksmps.

With the idea between networked Csound instances, I was thinking of a new plugin that would send/receive mp3 encoded streams. And you have a great point I didn’t consider before about the latency, so maybe that’s not such a great idea. These are reallyy useful suggestions, thank you - I will have a look at jacktrip and jamulus.

If

If the goal is to broadcast audio over the network I would look into libaao (audio over osc): https://git.iem.at/aoo/aoo,

it is the underlying protocol used by sonobus and in my own experience it offers low latency while being cross-platform than other tools like jack trip.

That seems good and not heard of it before, I will have a look, thanks.