Archivio dei tag radio

Automatic check for unbalanced audio, or bad level

I have a radio show and I’m also one of the people much involved in all the tech-related stuff in the Radio. There are multiple system that automatically, and manually, record the podcast of a show, upload it online and similar stuff.

Sometimes the recorded podcasts have some problems, typically:

  • The audio of the left channel is unbalanced with the respect of the right channel, or viceversa (Unbalanced volume level)
  • The audio is too high
  • The audio is too low

It may happen because the analogic audio system, before the audio card sampler, was misconfigured, or someone move some knobs, or maybe the cable are too long and of bad quality. Anyway, when this happen, there is no way I can understand it other than listen to all the recorded files. 

We are around 40 speakers, we broadcast liver from 8:00 to 24:00… it’s not something that a human want (and can) do. So for this type of problem computer systems is the way. I need

something that automatically can understand if a file is unbalanced, too high or too low in volume

I think that Linux is a super operating system and it’s full of library, tool, script and community that can help you find the right solution, but sometimes it’s not so simple. The siwss-knife I was looking for is called sox. Sox is a command line tool that can do tons of stuff (see here for the documentation). What I used for this is the stats option

sox FILE_NAME.mp3 -n stats

stats returns a lot of info, and what I was looking at was the RMS db level, global and for each channel (left right). To filter out these result we can use a simple grep command:

sox FILE_NAME.mp3 -n stats | grep 'RMS lev dB'

And with some ‘magic’ get the numeric info about TOTAL level, LEFT and RIGHT level:

LINE=$(sox FILE_NAME.mp3 -n stats | grep 'RMS lev dB')

TOTAL=$(echo $LINE | tr -s ' ' | cut -d ' ' -f 4)
LEFT=$(echo $LINE | tr -s ' ' | cut -d ' ' -f 5)
RIGHT=$(echo $LINE | tr -s ' ' | cut -d ' ' -f 6)
BAL_DIFF=$(echo "($LEFT)-($RIGHT)" | bc)

What we have done here? Saved the output of the sox command to the variable LINE:

LINE=$(sox FILE_NAME.mp3 -n stats | grep 'RMS lev dB')

and then we’ve parsed it 3 times:

TOTAL=$(echo $LINE | tr -s ' ' | cut -d ' ' -f 4)
LEFT=$(echo $LINE | tr -s ' ' | cut -d ' ' -f 5)
RIGHT=$(echo $LINE | tr -s ' ' | cut -d ' ' -f 6)

and stored the LEFT/RIGHT difference to a variable BAL_DIFF

BAL_DIFF=$(echo "($LEFT)-($RIGHT)" | bc)

from now on what you need to do with these value is up to you, you can check if values are less then a threshold and send an email, store the value somewhere, push an alert.

 

How to listen http webradio stream in an https site (Chrome > 80)

Since October 3, 2019 Chrome is gradually rolling out the new security feature that will block mixed content in the websites (info here). So that, if you have a webradio site in https and your streaming is in http, then none will listen to your webradio stream in your site. This is gradually happening at the beginning of 2020. There are multiple solutions, obviously the easiest and the smarter one is to move your streaming to an https connection. 

To do so you can ask your streaming provider to move/modify your server to a secure one. 

But this could take times, could be expansive or impossible (if your streaming provider service do not have this option). A good solution is to proxy the stream using a php script hosted in your website. So suppose you have a website at the address

https://www.myradiowebsite.com

And suppose your stream is at

http://mystreamprovider.mywebradio.com:someport/streamendpoint

Let’s create a file, let’s call it stream.php and let’s wrote in it:

<php?
$filename = "http://mystreamprovider.mywebradio.com:someport/streamendpoint";
header("Content-Type: audio/mpeg");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$filename);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 500);
curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($curl, $data) {
    echo $data;
    return strlen($data);
});
curl_exec($ch);
curl_close($ch);

With the usage of the curl function in php, basically we are proxying the non-secure connection to the stream with the secure connection of your website. And we’ve also removed the cross-site problem (side effect: we’ve also hidden your streaming provider info, so that, none will know who is hosting your streaming service and can’t know the number of your listeners…). All you have to do now, is to modify in your website, all the references to the original stream so search/replace or configure your website according to this substitution

 

find http://mystreamprovider.mywebradio.com:someport/streamendpoint and replace with https://www.myradiowebsite.com/stream.php

Katzenjammer del 14 gennaio 2018

Il blackout alla più grande fiera tecnologica del mondo, i lanci segretissimi di space X, le novità discografiche e i ricordi musicali con le celebrazioni di date importanti. Tutto questo è stato Katzenjammer del 14 gennaio 2018.

  1. I Don’t Wanna Stop – Good Charlotte
  2. Water Slide – Wooly Mammoths
  3. Girlfriend – Kaufman
  4. Catch You Dreaming – Ride
  5. Lotto In Reverse – Alex Lahey
  6. Life On Mars? – David Bowie
  7. La Bomba In Testa – Fabrizio De André
  8. Turtle Neck – Bosnian Rainbows
  9. All Nerve – The Breeders
  10. Animali – Cosmo
  11. Il caffè del teatro – La municipàl
  12. Annabelle – Fast Animals and Slow Kids
  13. Wicked – Cycle
  14. Don’t Kiss Me Goodbye – Ultra Orange Emmanuelle
  15. Smells Like Teen Spirit – Radio Edit – Patti Smith
  16. This Mess We’re In – PJ Harvey
  17. Typical Situation – Dave Matthews Band
  18. Mao – Bolla di sapone
  19. Parklife – Blur
  20. Let Go – Frou Frou

Katzenjammer podcast del 8 ottobre 2017

Onde gravitazionali, radio e del mare. Foto di Jedi in libri di scuola, riconoscimento facciale. Musica dalla Spagna, dall’Italia, dalla Francia (come una barzelletta con protagonista un fantasma formagino…) e ospiti casuali. Questo è stato Katzenjammer di Domenica 8 ottobre 2017.

  1. (Feeling Like A) Demon Again – Primal Scream
  2. The Culling – Chelsea Wolfe
  3. Sinnerman – Nina Simone
  4. Never Wanna Know – MØ
  5. Metti una sera a cena – La band del Brasiliano
  6. Le Villejuif Underground – Le Villejuif Underground
  7. Radioactivity – Damien Jurado Richard Swift
  8. Mina – Verdena
  9. Giorni – Diaframma
  10. La taberna del Buda – Café Quijano
  11. Tu Puto Grupo – Los Punsetes
  12. California Dreamin’ – The Mamas & The Papas
  13. Radical Eyes – Prophets Of Rage
  14. Vecchie dogane – La Municipàl
  15. Lessons In Love – Level 42
  16. The Violence – Rise Against
  17. Walk On Water – Thirty Seconds To Mars
  18. Senza Vento – Timoria
  19. Susan’s House – Eels