Category Archive Technology

Listen microphone with your computer speaker: Audio monitor (for Mac)

How to listen your microphone with your speaker? How can you direct, or redirect, input from microphone to a different audio device?

Using your mac there is a freeware that you can download, it’s called Audio Monitor. The MTCoreAudio framework is a Cocoa-flavored Objective-C wrapping around the Hardware Abstraction Layer (HAL) of Apple’s CoreAudio library.

As you can see here you can send audio from your microphone to your speakers, as you can imagine this means also that there’ll be a lot of echo, but another things that you can do is send audio from your microphone to another output device. In conjunction with a setup like the one described here: Audio virtual device for MAC you can enable a lot of configuration like send your microphone audio and music to another listener connected with you with skype.

 

Audio virtual device for MAC

If you play with streaming, podcast, mixing, webradio or you want to setup an audio recording studio at home you may find difficult to get audio from some sources and record or use in your live set. 

While in a real analog world, this can be solved with cables and mixers, by splitting some output to other inputs and similar stuff, in a digital world this seems difficult and it’s complicated, for example, record the audio from the browser, or get the audio from skype or similar. There are some solution that I want to share with you, 2 out of 3 of them are completely free:

Soundflower

FREEWARE. MacOS system extension that allows applications to pass audio to other applications. Soundflower works on macOS Catalina. Follow the instruction at this link (official link) after a restart you’ll see 2 new output device available on your menu. You can set the output to soundflower and set soundflower as input, in your record software and done!

 

 

 

 

BlackHole

FREEWARE. BlackHole is a modern macOS virtual audio driver that allows applications to pass audio to other applications with zero additional latency. Follow the instruction at this link (official link). It works just like Soundflower: it adds a new virtual device Blackhole 16ch and you can use the input of Blackhole 16ch to get the audio of every app, just setting the output to Blackhole 16ch.


 

 

 

 

 

 

 

LOOPBACK

99$, 14 days trial. It creates virtual audio devices to take the sound from apps and audio input devices, then pass it to any audio processing software. With an easy-to-use wire-based interface, Loopback gives you the power of a high-end studio mixing board, right inside your computer. Details here while Loopback is not a free software, it has the power of super easy to understand user interface where you can configure multiple sources as a new virtual device.

And then you can use this new created virtual device in your recording software

My use case it’s something a little bit complicated than record from an internal source in my computer: I want to stream my webradio show from home, and have someone else talking with me in the show, but he/she is at home. What I’m using is MIXX a free software that can easily stream audio to shoutcast or icecast server, you can add multiple microphones (up to 4 microphones) so I want that Skype output is seen as a microphone, to do this I’ve installed Soundflower and used as output device in Skype

And set Soundflower 2ch as mic in MIXX

And it works! This is just a use case, but you can solve a lot of problem with these solutions. Then you probably want also and additional feature like: sending a source to two different device (for example real speakers and one of the virtual device) so that you can listen to what you are recording, or using as a source (the skype virtual microphone in my use case). This can be done using the built in Audio device of the Apple MAC, just open Audio device click on + button on the left bottom corner and select “create multi output device”

You can then select something like Built-in output (the speakers) and Soundflower output (set Drift correction, better result)

When Multi-output device is selected from the sound menu….

..everything that is sent to the Built-in output will also be sent to the Soundflower.

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.

 

WebRadio, FM Radio, streaming and similiar stuff. A Webinair

Mirobarsa, speaker at https://www.radiocittaperta.it with a 30 minutes Webinair about: WebRadio, FM Radio, streaming and similiar stuff. Also some usefull resources on How to start your webradio.

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

Driver 7610u for raspberry pi

TL;DR

jump to UPDATE DAY#3 there is the solution I’ve found for this problem.


Stuff like “looking for linux drivers” can make you incredible sad and happy at the same time. I’m helping out a friend of mine to setup a wifidongle on his raspberry pi. The product seems to be a TP Link AC600 but, like all the computer related hardware, brands are only brands… we need to see the chip and the chipset..

So it seems there is a mediatek chip 7610u in it, and that it’s not automatically recognized as a wifi dongle. How do I know it? Simple!! just type 

dmesg

and something about “can not find 7610u.bin” will appear.

Looking around (google) it seems that Mr. Engman wrote and distributed a super script that can install everything you want in a snap. But the script it’s not where it’s supposed to be (no…this link won’t work https://dl.dropboxusercontent.com/u/80256631/install-wifi.tar.gz ) But there are alternatives, or so it seems, download and install the scripts from here:

sudo wget http://downloads.fars-robotics.net/wifi-drivers/install-wifi -O /usr/bin/install-wifi
sudo chmod +x /usr/bin/install-wifi

The command:

sudo install-wifi -h
will show details on using it. To install the driver on your current kernel you just need to run command

sudo install-wifi

This will select the driver you need and automatically download and install it. Done? Solved? No, Unfortunately “A driver does not exist for this update” and by “this update” it means kernel 4.19.97-v7+

When someone tells you that windows and mac works out-of-the-box, please do not start nerdy talking about the beauty of the open source and Richard Stallman … Linus Torvalds… just believe him/her.

And now what? Well… why don’t you compile your driver? Super!! There is a fabulous page here 

https://config9.com/linux/ubuntu/how-to-install-mediatek-mt7610u-rt2860-driver-2/

On How to do it, but it’s not the one you are looking for (move to day2 and you’ll find some clue). Right now, I’m laying on the floor (because I can use only the TV as a monitor) downloading 1Gb of Linux Kernel, just to setup the environment to compile the driver. It’ll be a long night/day.

 

UPDATE DAY#2

I need to compile driver from scratch, it seems the right documentation is this one

https://groenholdt.net/Computers/RaspberryPi/MediaTek-MT7601-USB-WIFI-on-the-Raspberry-Pi/MediaTek-MT7601-USB-WIFI-on-the-Raspberry-Pi.html

But no, it won’t work so do not follow that guide: there is something wrong in the MAKE file (or that what I’ve understood) because the make command exit with a status of 2 (status must be 0, when everything is ok) without particular informations on the reason why.

 

 

 

 

 

 

 

No way for this to work.

UPDATE DAY#3

After more struggling with make files, import and some changes in .c and .h files, I found good “how-to” here https://askubuntu.com/questions/674116/how-to-install-tp-link-t2uh-wireless-adapter-driver-ralink-mt7610u I re-write the same information here:

If you would install the driver you will need to compile the source. To do this you will need install git and clone the repository in your home directory.

sudo apt install git
cd ~
git clone https://github.com/xtknight/mt7610u-linksys-ae6000-wifi-fixes.git
cd mt7610u-linksys-ae6000-wifi-fixes

Then type

sudo apt-get install build-essential linux-headers-$(uname -r)
make clean
make
sudo make install

You will need to work in the directory “mt7610u-linksys-ae6000-wifi-fixes” otherwise the process will not work. And finally

sudo apt-get install dkms  
sudo cp -R . /usr/src/mt7610u_sta-1.0
sudo dkms add mt7610u_sta/1.0
sudo dkms build mt7610u_sta/1.0
sudo dkms install mt7610u_sta/1.0

AND IT WORKS!

NOTE: I’ve only used command sudo dkms install mt7610u_sta/1.0 because, probably, kernel was already builded. Anyway… I had to modify the rtmp.h files, because there is a double definition of an ENUM. If you have the same errore, just remove the enum definition in the rtmp.h file.

This is the final result. You can see the dropdown menu for all the available wifi network, and I can navigate to a website (www.radiocittaperta.it the radio where I have a show every Sunday at 22.00 called Katzenjammer)