Setup Multiple Wireless Microphone using Android (aka. No-mic Karaoke Night with Ultrastar)

Personal Project

Preface

Luckily both my sister and I this Christmas were able to celebrate with our family, since I only had work that I was able to do online, and she was on break from school. However, being at home all the time due to lockdown can get pretty boring, pretty fast. Therefore we decided we were gonna do what we do best: be a nuisance to our neighbor, specifically we decided that we were gonna have a Karaoke night.

Back in Turin our group of friends had THE ultimate app for Karaoke: Ultrastar. It is essentially a clone of the (in)famous Singstar developed by Sony; the basic principle is quite simple, the application applies FFT to your voice and with some magic post-processing can figure out whether you’re singing the correct note or not. Our setup was pretty basic, we had a laptop that already had a microphone jack, an external (cheap) USB sound card that allowed us to connect one extra microphone, and a third microphone connected through an application called WOMic. The main issue was that only one WOMic instance was allowed at a time, therefore unless we bought more external USB sound cards (which is both wasteful and expensive considering that we only had a friend that had a voice worth listening too…) we could only connect up to three people.

I’ve approached the problem of having more than one “smartphone-powered” microphone from multiple angles but never found a proper solution, additionally after a beer or two most people did not really care about their score so there was no real incentive in having additional microphones, therefore I just moved on with my life and forgot about it.

Things changed this Christmas break because in my family home we only had one microphone, and no external sound card, since desperate times call for desperate measures it was time to finally fix the problem once and for all.

The solution

After basically trying all possible Google searches I finally found a solution that not only was extremely simple and clean, but was also quite functional!

The key ingredients are:

  • Any Linux distribution with some version of Pulseaudio on it
  • The pulseaudio-virtualmic script, which allows turning any RTSP/HTTP stream into a Pulseaudio source
  • Any Android application that sends RTSP audio, personally I chose LANmic, but any other will work, you could even write your own since there are RTSP libraries already available

Setting up the microphones

If you’re familiar with Linux (and everything goes smoothly) setting everything up will take no more than 15 minutes.

The first step is to download the pulseaudio-virtualmic script from Github, this is necessary since otherwise, we are not able to create the audio device.

As with any other git repository, you can download the script using the clone command

$ git clone https://github.com/MatthiasCoppens/pulseaudio-virtualmic.git

Now let’s go ahead and test it, open up LANMic (or any other app as I’ve already said), select RTSP, which should theoretically provide slightly lower latency, and start the stream by pressing OFF (a bit counter-intuitive…).

To create the source cd into the folder in which you’ve cloned pulseaudio-virtualmic

cd pulseaudio-virtualmic

and run

./pulseaudio-virtualmic rtsp://my.ip.address.xxx:port

substituting the “my.ip.address.xxx:port” with the address LANMic is providing.

If everything went well, you can go into settings, go into sound and you should see in the input section an additional source (the name will be something around the lines of Unix FIFO source /tmp/xyz…) which corresponds to the stream coming from your phone. To set-up, an additional microphone iterating the previous procedure should be sufficient. I suggest you give each device a different name using the -n option, for example

./pulseaudio-virtualmic -n virtualmic rtsp://my.ip.address.xxx:port
./pulseaudio-virtualmic -n virtualmic2 rtsp://my.ip.address.xxx:port

And that’s it, now you can use your microphone for any app that supports Pulseaudio: Chrome, Zoom, Discord…

Unfortunately, my adventure was not over, since Ultrastar only supports ALSA devices, therefore we still need some tweaking before we can finally have our Karaoke night.

Create an ALSA device from a Pulseaudio source (aka. set up Ultrastar)

Ultrastar does not support pulseaudio devices, is all hope lost? Not really, it seems someone else already had the same problem in a slightly different context. In their case the device was a USB sound card that was not being detected as an ALSA device by Ultrastar, but was detected just fine by Pulseaudio; they fixed it with a small tweak to the .asoundrc, no reason why that shouldn’t work in our case.

Following their procedure, we create/edit the .asoundrc in our home folder and add the following block

pcm.pulse_mic1{
	type pulse
	device "virtualmic"
}
ctl.pulse_mic1{
	type pulse
	device "virtualmic"
}

Let’s analyze this code block a bit.

  • pcm and ctl, create two different alsa devices, from the ALSA Documentation: The ‘pcm’ options affect which card and device will be used for audio playback while the ‘ctl’ option affects which card is used by control utilities like alsamixer .
  • pulse_mic1 is simply the name that the ALSA device will take, in our case we will see this name in the Ultrastar menu. There are no specific requirements on this parameter and it can take any arbitrary name. Do not give the same name to two different devices otherwise you’ll have a conflict
  • The type pulse simply specifies that we have a PulseAudio sink
  • The “virtualmic” part is probably the most crucial part of this configuration. Specifically, this needs to match exactly the name that you have given to the device in the previous section using the -n option, otherwise, ALSA will not be able to find the device

Creating as many blocks as the microphones you want to connect will allow you to add as many devices as you want.

Now if you start pulseaudio-virtualmic and then Ultrastar you should see the microphone inside the list of available devices and you are ready to sing!