jlinkels
Posts: 2
Joined: Sun Jun 09, 2019 3:01 pm

PiRadio playing custom stream

Sun Jun 09, 2019 3:30 pm

Hello all,

I am trying to figure out how to use PiRadio for a custom (that is, non-standard) audio stream.

I would like to use PiRadio to play (mainly) a collection of special audio files, and also internet radio stations. Where it was designed for.

Some more explanation. I listen a lot to radio stations in the EU. But I am located in UTC-4. Which means radio programmes are 5 or 6 hours ahead. It is not nice to listen to nighttime radio in the evening.

So I have written some scripts. One to record the audio of the radio stations in 70 minutes chunks. Inlcuding provisions to restart the recording process when the stream is interrupted. The files are not all equally large as a new file is created when the recording process starts or restarts. The files are time stamped. The recording script does not run on the Pi but on my home server.

Then I have created a script to play back the recorded streams at a given time delay, 5 or 6 hours in this case. As the recorded files are arbitrary in length and start time, provisions are made to skip into any recorded file. So at any moment, playback is exactly 5 or 6 hours delayed. I use the Pi for executing the playback scripts. The recorded files are on a shared drive. The playback script uses mplayer to play back a given file with a given time offset. But I also could use mpg123 or whatever.

Which means I cannot simply stream this collection of files. I need a process which calculates which file is to be played, and where playback of this file should start to achieve exactly this time delay.

The recording and playback is working fine, both processes are robust. I have built a nice subwoofer audio system around the Pi and all is fine. Except for one thing. I don't have a user interface. Which make it difficult to change settings. I do that through SSH now. Which includes selection local, non-time delayed radio stations.

Ideally, I would use PiRadio as base for my sound system. The problem is, how do I get the output of my customized playback scripts into piRadio? I have thought about 2 appraoches:
  1. Run the playback scripts on the Pi where the PiRadio runs. PiRadio uses MPD to playback a stream. I could try to pipe my input in a named pipe and have MPD reading the stream from the named pipe. I would have to hack PiRadio to enable this. And MPD must be able to read from a named pipe. The first, hacking PiRadio should be doable. The second, make MPD read from a name pipe I am much more unsure. There is no documentation about this option op MPD. It seems no one ever needed this.
  2. Next option would be to run the playback script on my server, and pipe the output into something like IceCast. Advantage is that I can use PiRadio unmodified on my sound system. But then again, I have shifted the same problem to the server side. How to I pipe the custom audio stream (output from my playback script) into IceCast? I seems I only have shifted the problem upstream.
Any ideas?

jlinkels

Return to “Graphics, sound and multimedia”