All times are UTC+01:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Jan 05, 2017 10:48 am 

Joined: Sat Dec 31, 2016 11:22 am
Posts: 5
Hello,
I decided to put down some lines to demonstrate how to use Liquidsoap in conjunction with Stereotool.
This is a sort of collection of info found on the internet and some personal test.
All work thanks to the great work of my friend vincenzo Rubano that solved the metadata issue.
I hope people can find this post useful.


The concept is quite simple:
Liquidsoap make all jobs about scheduling, containing playlist, stream etc. Stereotool process the sound.
I have a webradio on a vps, using Debian Jessie and icecast as stream server.

Use stereo_tool command line version.

You should download a setting preset from the stereotool forum section. It's really easy and there is a good choice.

Then create 2 files:

mkfifo /tmp/audioin.pcm
mkfifo /tmp/audioout.pcm

These are the files that must be read and write by liquidsoap and stereotool.
Liquidsoap generates the pcm audioin.pcm, stereotool reads it, processes, and write audioout.pcm; liquidsoap takes audioout.pcm and stream to icecast.

The stereotool side is really easy, you can give a simple:
./stereo_tool_cmd_64_xxx /tmp/audioin.pcm /tmp/audioout.pcm -s ./mySettings.sts &

where xxx is the version of stereotool.

The liquidsoap section instead:


I have a "radio" object that contain all playlists and scheduling options. So we must generate a wav file that will be read by stereotool, and then take the output file and stream by icecast.
Since manage metadata with liquidsoap seems quite tricky, we decide to pass all to icecast. So, first of all, we must define a function for metadata. Put it before you define your playlist.

The piece of code is follow:

#helper function to format metadata
#todo: evaluate using rewrite_metadata for a more elegant solution
def format_metadata(data)
artist = data["artist"]
title = data["title"]
if title != "" then
if artist != "" then
"#{artist} - #{title} - NV-Radio"
else
"#{title} - NV-Radio"
end
else
"NV-Radio"
end
end

#when using stereotool we loose metadata, so we send them to Icecast manually
def apply_metadata(data)
icy_data = [("song", format_metadata(data))]
icy.update_metadata(mount="/stream",
password = "cipcipcipcipcipcip!",
icy_data)
end

Then, before you send the streaming to icecast, metadata should be handled, so add this for completing the radio object:

#metadata handling
radio = on_metadata(apply_metadata, radio)

output.file(%wav(stereo=true, channels=2, samplesize=16, header=true, duration=1.),
"/home/radio/audioin.pcm",
radio
)

# put all stream processed by stereotool in the s object using the dd command
s = mksafe(input.external("dd if=/home/radio/audioout.pcm 2>/dev/null"))
s = rewrite_metadata([("title", "$(title) - NvRadio")], s)

#enable icecast streaming passing the S object and metadata, converting all strings to iso-8559-1 for avoiding problems with certain song title, I'm not sure you need this conversion on your station so make some try.

output.icecast(%mp3(
samplerate=44100,
stereo=true,
bitrate=128),
mount="/stream",
name="your Radio",
host="127.0.0.1",
port=8000,
password="ciopciopciopciopciopciopciop!",
genre="70's, 80's, 90's, easy listening, oldies, top 40/pop",
url="http://www.yourwebradio.com/",
icy_metadata="true",
encoding="ISO-8859-1",
description = "radio a tema accessibilità !!",
public=true,s)


Remember, start liquidsoap before, you will hear a silent streaming, then start stereo_tool and the magic sound will appear.

I think it is useful to check with monit or similar the stereo_tool process, because if it dies for some reason, you lost the streaming.
So at least it is a good idea to implement a script that notify you by email, put down liquidsoap and start the emergency streaming of icecast.

On some circumstance you should kill also the "dd" process, but in my server it was not necessary.
So if you make:
killall -9 radio.liq

You kill liquidsoap and stereotool goes down automatically because it doesn't find data on audioin.pcm.


Last edited by drein on Wed Apr 05, 2017 10:22 am, edited 1 time in total.

Top
   
PostPosted: Fri Jan 06, 2017 8:11 pm 
Site Admin
User avatar

Joined: Mon Mar 17, 2008 1:40 am
Posts: 10069
The Stereo Tool command line version doesn't contain a full wav file parser, so it's very likely that that's what's causing the loss of info. For now, If possible somehow fetch the data from the input file.


Top
   
PostPosted: Wed Mar 08, 2017 7:21 pm 

Joined: Sun Feb 12, 2017 9:13 pm
Posts: 11
Hey Drein,

All makes sense, I will try this soon! I basically want to generate a MPX stream (lossless flac via icecast)... One bit I'm not sure on...
Quote:
I have a "radio" object that contain all playlists and scheduling options. So we must generate a wav file that will be read by stereotool, and then take the output file and stream by icecast. The piece of code is follow:

output.file(%wav(stereo=true, channels=2, samplesize=16, header=true, duration=1.),
"/tmp/audioin.pcm",
radio
)
I've seen your posts on airtime forum, do you know what the airtime object would be called? I can't see any mention of 'radio' in ls_script.liq


Top
   
PostPosted: Sat Jul 18, 2020 4:48 pm 

Joined: Sat Jul 18, 2020 4:43 pm
Posts: 2
Is there somebody who can help me to fix Stereotool in Azuracast with liquidsoap?


Top
   
PostPosted: Mon Jul 27, 2020 12:54 am 

Joined: Sun Feb 05, 2017 4:10 pm
Posts: 5
Another script that's work. I have it running on my delicated linux server.

#!/usr/bin/liquidsoap
set("log.file.path","/tmp/stream.log")
set("frame.size",940)

# Input to Processing
input = input.pulseaudio(clock_safe=false)

# Processing
radio = pipe(process='/usr/bin/stereo_tool_cmd_64 - - -s /opt/optimod8100.sts -q -k "<3f1c........................................9ee>"', input)

# Processing to Output
output.icecast(
%mp3(bitrate = 192),
host = "server.nl",
user = "source",
port = 6830,
password = "************",
mount = "/",
genre = "Prog",
name = "Progressieve Rock",
url = "https://progressieverock.nl",
description = "Progressieve Rock",
mksafe(radio)
)

Pascal, many thanks !


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC+01:00


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited