📜 ⬆️ ⬇️

Talk radio on the knee

At a certain point, suffering from laziness to update the OpenStreetMap news blog, I decided to make a weekly program about the project. Instead of three hours of extorting text - an hour to discuss with familiar OSM participants news and current issues. Great idea, glad and dispersed. Six months later, with the words “well, damn it is enough to idle, let's call Skype on the day after,” I began to figure out how to record sound from a microphone and Skype in your Linux while simultaneously transmitting it to the Internet. This story is about setting PulseAudio, about Skype and Mumbles, and about amazing JACK. It turned out that raising your own radio with guests on the air is easier than drawing a logo for it.


Labyrinths PulseAudio


Soon we decided - I quickly collect the broadcast. The presenters are combined into a Skype group, respectively, you need to record the input and output of the sound card (since Skype does not copy sound from the microphone into headphones). Around here I learned that PulseAudio is great: it has modules and a powerful audio routing application, which for some reason is called a volume control.

What does the “designer” of PulseAudio look like for the user? For each sound card there is a device-input ( source , usually a microphone) and a device-output ( sink , usually - speakers). Applications take the sound from the source and give it to the sink . But how then to record the sound from the speakers, i.e. give the application sound from the sink? For this, all the sinks have a monitor , which is also source. It turns out such a directed graph. And how to direct the sound from source to sink without the application in the middle? The module-loopback module is a virtual application that simply copies the sound. Often it is plugged in to hear a microphone in the headphones (and woe to you, if you start the loopback from the microphone into the speakers - I managed to include such a configuration in autorun, and I was very scared). We stick the headphones in the audio output and type without sudo:
')
pactl load-module module-loopback 

This module will allow you to make the simplest scheme for recording your own voice and co-hosts at the same time:



To configure the input and output of Skype, gstreamer (see below) and loopback, you need to start the corresponding sound consumers (for example, call Skype Sound Test Service) and find the application in the “volume control” ( pavucontrol ). In the "Playback" tab, select the sink (headphones in our case), in "Recording" - the source (microphone). To see the loopback module in the window, at the bottom, select “All Streams”.



In the picture, I choose the source for Skype. The two buttons on the right allow you to silence the input and adjust the volume of the left and right channels separately (by default, they are connected). Be sure to check that the signal level in all tabs is 100%, and decrease only if necessary.

The most difficult in this scheme was to speak. Yes, it is banal to pronounce coherent sentences. Because the loopback occurs with a delay of 0.2 seconds: as if you are constantly interrupting yourself. Reflex - silence and give to the one who is in headphones, speak out. But he, too, falls silent! Somehow reduced this effect, having muffled one channel in earphones.

Icecast Repeater


For a live broadcast on the Internet you need a server like shoutcast, the most popular of the open ones is icecast2. It is in all popular Linux distributions. After installation, it is enough to edit /etc/icecast2/icecast.xml , registering your passwords in the “authentication” section, and correcting just below the “hostname”. You also need to check that in /etc/default/icecast2 the ENABLE parameter is true. Next run the icecast2 daemon and write it into autorun. You may need to open tcp-ports (by default - 8000 and 8001).

Server status and statistics can be viewed by accessing port 8000 with a browser. I did not have enough distribution of listeners by countries and cities - for this I wrote a simple php script that uses the PECL GeoIP module.

Slow down, gstreamer writes


To send sound to the icecast server, strange people on the Internet put some kind of muddy programs like Darkice or LiquidSoap, but in reality, the usual gstreamer is enough. It is very easy for them to record sound from any source to an mp3 file (or ogg, to taste):

 SOURCE=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor DATE=$(date +%y%m%d-%H%M) gst-launch-0.10 pulsesrc device=$SOURCE ! audioconvert ! audio/x-raw-int,channels=1 ! lamemp3enc bitrate=64 cbr=true ! filesink location=radio-$DATE.mp3 

Available sources for the variable SOURCE will show the command

 pactl list short sources 

Although the source can simply be selected in the volume control. Other network instructions will tell you how to send sound to the server:

 gst-launch-0.10 pulsesrc device=$SOURCE ! audioconvert ! audio/x-raw-int,channels=1 ! lamemp3enc bitrate=64 cbr=true ! shout2send ip=$IP port=8000 password=$PASSWORD mount=radio 'streamname=Beta Radio' 

Finally, the thread mechanism allows you to do both with one command:

 gst-launch-0.10 pulsesrc device=$SOURCE ! audioconvert ! audio/x-raw-int,channels=1 ! lamemp3enc bitrate=64 cbr=true ! tee name=t ! queue ! shout2send ip=$IP port=8000 password=$PASSWORD mount=radio 'streamname=Beta Radio' t. ! queue ! filesink location=radio-$DATE.mp3 

Voila! I note that when I forgot to transfer the stream to mono, the computer could not cope with the encoding and sent some scraps to the Internet. So be sure to check the stream and the recorded file. You can run several gstreamers to record different devices in the files: for example, separate the microphone and skype to clean them separately and collect the podcast in the editor.

This is not an archiver, this is Audacity.


The transfer has passed, you need to publish a podcast on the Internet. You can immediately, but nekomilfo: the track is noisy, the voices are quiet, the pause for ten seconds is annoying. So black podkasterskoy work can not be avoided: run Audacity and open the record there. First you need to remove the void from the beginning and end, then - especially gaping pauses and random violations of the NDA by guests. I noticed that the correct background music does not prevent such shredding: the rhythm jumps are almost imperceptible. So the individual channel recordings are not yet useful.

Then we delete the clicks (Effect → Click Removal), we find a quiet place without music and without breathing (for this, it’s good to record the broadcast after the transfer when the music is over) and we get the noise profile from these 0.5-1 seconds (Effect → Noise Removal → Get Noise Profile). And, having dumped selection, in the same place we delete noise. I am not a professional, I have not changed the default settings. Just checking that the procedure did not remove the useful frequencies — I didn’t make the voice duller or louder — and am content with it.

Judging by the dozens of instructions in Russian only, the most difficult thing is sound compression (Effect → Compressor). There is nothing in common with archiving; it is a banal compression of a wave in amplitude. As I understand it, the algorithm takes fragments of a wave with an amplitude larger than “Threshold”, and these tops (not the whole wave) are compressed a number of times as specified in “Ratio”. I'm impatient, so I put 8: 1, but, they say, several approaches are better for 3-4. Here are some of the articles on the topic:


When saving to MP3 (File → Export → MP3 Files), select the “Preset / Standard” mode (this is a very good quality, believe me), and then be sure to enter the tag values. I put the genre "Vocal", although, probably, there are more suitable options.

VLC, DJ Thunderstorm


This configuration made it possible to record an awkward zero release, but did not fit the first one: I recorded several interviews on the tape recorder a week earlier on the “Live Evening Card Party” and wanted to reproduce them in the program. Also, many recommend putting under the voices of the leading quiet music, which not only masks long pauses and makes the transfer more dynamic, but also shows that the connection is not broken.

Music, of course, must be with an open license, the so-called. podsafe . Many sites advise musicalley , but it is creepy, so I went to dig in scraps for promodj . The requirements are simple: no vocals, no drums, preferably in the style of old consoles (impressed with the music from the Otaku video diaries). Of course, I didn’t find any good tracks from this data, but I collected some acceptable ones. I let one of them in the background, I switch on the rest half an hour before the broadcast, so that the early listeners do not get bored.

As the radio is on my knee, the VLC player is a source of music and an interview. In it, directly from the menu, you can specify in which sink to send the sound. But the challenge: the interview must be heard and the interlocutors in Skype, to know what to discuss.

Back to the graph


The second useful PulseAudio module is module-null-sink , a virtual device with input and output. It can be used as an intermediate one: in my example, the sound of a microphone and a VLC are put in there. The mixed result gets skype at the entrance, and co-hosts of the whole program listen to background music, and interviews sometimes. I recall:


It turned out a scheme that I used to broadcast and record several releases:



When the interview starts, the sound from Skype can be redirected to the headphones, and the microphone device can be muted (the button in the volume control) or sent directly to Skype. Finally, by slightly complicating the scheme, you can simultaneously transfer the entire “sandwich” to the Internet, and write only the speech of the presenters to the file, which, after processing, be put on the music files. Delighted with the routing capabilities of PulseAudio, I wrote and debugged a script to prepare for the broadcast . True, in the "production" I have never used it: right after writing, I found the strength to take and adjust JACK.

Blog on the knee


The main result of the weekly broadcasts is not fifteen satisfied listeners, but a podcast that hundreds of people will listen to. To publish and discuss it, you need a blog. Out of habit, I chose the Birman e2 : simple and easy, even supports audio files out of the box.

Comments did not appear, but the blog did not decide the main task, which I did not guess. Several listeners complained that the RSS blog does not accept their podcast app. It turns out that RSS entries should contain links to audio files in the enclosure and a dozen of their parameters in special tags. Egea doesn’t know how to do that, but I didn’t want to put something heavy, so I started a copy of the podcast on rpod.ru : about 10% of the audience listened to us through this site, but it’s easy to subscribe to. And there is a volume control on the player.

It would be correct not to show off and go stop the German podcast about OSM, which rolled the Podlove plugin on regular WordPress. The result is somewhat technologically monstrously, but pleasing in appearance, and allows, for example, fast navigation within the podcast through tags. I found another option this week: the We Build podcast blog is hosted on GitHub Pages , i.e. on static jekyll templates.

To publish only on rpod is fraught with: so, I could not download the fifth transfer because of an idiotic error about exceeding the amount, which is not explained (files of 40 megabytes in total), only a couple of disappointed replicas of the same podcasters.

JACK time


Experts of sound processing in our little chapters made me switch to the advanced audio subsystem JACK, and I, of course, could not resist, pushed by curiosity, the desire to get rid of the 200 ms loopback delay and hope for the charm of IDJC (see below). It turned out that 1) to work with JACK, you no longer need to remove or disable PulseAudio, and it can be turned on and off as desired - for example, only to record a program. And 2) for some reason all the necessary packages are already installed in Fedora out of the box. It remains only to install qjackctl and run it.

Of course, this panel immediately complained about the curve setting. He says, let's turn on realtime scheduling in your Linux. Again, it turned out that for this you do not need to change the kernel , it is enough to edit /etc/security/limits.conf . And again, someone in Fedor did it for me: judging by /etc/security/limits.d/95-jack.conf , it suffices to add yourself to the jackuser group. And for this you need to re-log. I never logged out to KDE, I had to google it.

Run QjackCtl again. In the settings I specified the required microphone and output, and most importantly - in the “Misc” tab, enable “Enable D-Bus interface”, and the next tick, about turning off JACK on exit. It seems that these are all settings of the audio subsystem, you can click Start - and launch the desired Internet DJ Console.

And finally, the IDJC


This console, many advise for the organization of a simple radio station. She is tuned to the broadcast of music and mixes, but she is able to properly handle the voice of a DJ. As it should be an advanced console, it scares the number of buttons and levers:



In fact, all, of course, easy. Two panels of music, below - a crossfader to switch between them (the “Pass” button switches smoothly). There is a DJ channel and a broadcast channel (“Stream”), they are separate: for example, you can turn off the music for the DJ, or vice versa, check the second playlist while the first is playing on the radio. On the right is a bunch of indicators, the most interesting is the number under the headphones, the number of listeners. The buttons below include the broadcast of the presenter's voice and streams from other channels (in the picture - the final version, after Mumble, about which further). A few descriptions and a link to the textbook is on the project website .

All settings are hidden under the button on the bottom left. In the Preferences, I included separate volume controls for playlists: in the first one there is a quiet background melody repeated in a circle, in the second pre-air songs and interviews. The “Channels” tab can confuse: at the same time, the buttons at the bottom of the player, which open the channels, and these channels themselves are configured. It shows that the sound from the microphone is driven through a bunch of filters, including the High Pass, limiter, noisegate, etc. If you spend time setting up (not only for yourself, but also for the co-facilitators), post-processing may not be necessary. I have not spent. For starters, the first channel is enough, which is with a microphone.

The translation is configured in the "Output". They can be up to six (in different quality and formats). Below - a button to write to the file. For me, for some reason, it only works once per session, I have to restart. What is not obvious in this window is to activate the broadcast, you need to open "Individual Controls" and click the button with the server address there. Perhaps it's easier to turn on the checkboxes above and click "Connect", I do not know.



This vermicelli is the QjackCtl window under the Connect button. The system section is a microphone and speakers, in PulseAudio only Skype is broadcasting, so I did not make a separate sink for it. JACK does all this routing by default, I just added vectors from PulseAudio to the voip_in section of the IDJC. This makes the buttons with phones workable: red is useless, but green mixes sound from Skype to broadcast. When I need to launch an interview, I pull in additional links from str_out to PulseAudio (with a simple drag and drop). To remove the connection, you need to select the source on the left, the receiver on the right, click on the last right button and "Disconnect".

The problem of the loopback delay, the new configuration, however, did not solve. All the same 0.2 seconds. But it is easier to raise, and somehow in an adult way.

Do you sell go mic?


Less than a month later, as a lavalier microphone finally knocked me out with noises and low volume, and I decided to replace it. All manuals for newcomers to the podcasts recommended taking a USB microphone, and between the $ 200 Rode and the two- handed Samson Go Mic, I chose the latter. It is easy to find it in stores, it is more difficult to keep a serious face expression, dictating the name to the seller. It is about the size of a good lighter.

And, of course, in comparison with my past microphones - heaven and earth. Sensitivity is such that you can hear the purring of a cat sleeping in the next room, and draining the water three floors below. But you do not need to shout, you do not need to hold the microphone in your mouth, and thanks to the USB connector, a cheap external sound device went to the shelf (my laptop does not have a microphone input). The pop filter does not seem to be critical for this microphone, but the rack needs to be searched.

Suddenly, Go Mic solved the problem with the loopback delay in the headphones: he has his own sound card inside, which mixes the signal from the computer with the voice in the microphone. Since the signal does not scroll in the computer, the delay is zero. Finally, my own echo doesn't bother me. It was not easy to turn off the loopback in IDJC: I found the “In The DJ's Mix” checkboxes, but if you press the VoIP button, the echo returns, and what to do with it is incomprehensible. I decided to abandon the buttons with the phones, screwing Skype on the fourth channel and making for it the button next to the “DJ” - as for Mumble.

Mumble instead of Skype


The problem with voice conferencing on Skype is unpredictability. The presenter with the broadcast will almost certainly not be the admin, and the voices of the co-presenters will go long and hard. Someone accidentally turns off - and takes with them all the interlocutors. Finally, Linux skype sometimes crashes out just like that, unmotivated. Several alternatives, I chose the most popular and open source: Mumble. The presence of clients attracted not only under all desktop OSes, but also for iOS and Android.

The server, Murmur, is put in two accounts at all: register the server password in /etc/murmur/murmur.ini (the default settings are adequate), start and register the daemon’s autorun, open port 64738 for tcp and udp.

With the client more difficult. After installation, of course, you need to go through the setup wizard. Required. Do not forget to plug in headphones, because there will be an echo. I managed to connect to the server somehow after a couple of restarts, but to connect Mumble with JACK - no. It turned out that this subsystem is simply not supported. The corresponding patch was loaded almost four years ago, but was never accepted. Therefore, you need to download the source, roll the patch yourself and build the application.

It sounds difficult, but from my past with ArchLinux, I remember about AUR. This is an amazing repository, the best I've ever seen in Linux, and the only thing I regret is when I leave Archa. The AUR database entries are instructions for preparing an installation package of dirt and sticks of source codes and patches, while the user is no more difficult than the usual pacman -S . For Mumble, there is an assembly from snapshot, an assembly from a gita, an assembly from a gita using the JACK patch and an assembly from the sources of a stable version with this patch. Open the pkgbuild last , download the patch and execute the instructions from prepare() and build() . Assembly instructions (without patch) are in the mumble wiki . The main thing - do not forget about the package jack-...-devel . The assembled application did not install in /usr , I run from the build directory. In the settings you will need to enable JACK and disable all tinsel, such as echo and positional audio.

I can't get rid of Skype: I want to leave it for receiving calls from listeners and for guests who do not have time to set up a mumble. The signal routing graph turned into an incomprehensible vermicelli:



I'll try to explain. The sound from the microphone goes to 1 and 2 channels IDJC (as usual), to the mumble and to Skype. Only dj_out from IDJC goes into headphones. The output of the mumble is bolted to channel 3, Skype to 4 (stereo to mono), no shamanism with voip. Finally, Skype and Mumble are connected in both directions so that the guest and the presenter can hear each other.

What to do with interview recordings that should be heard on skype and mumble? Alas, hands to stretch a few more links, from str_out there and there. And turn off the broadcast of all four channels in the IDJC, of ​​course. Despite the complexity of the system, I don’t want to roll back to PulseAudio: communication in QjackCtl is faster and clearer to correct than in the “volume control” and it is easier to work in one IDJC than to coordinate VLC, gstreamer and “control”.

Headless Radio


Even regardless of the technical part (I am sure, the podcasting professionals will criticize me), there is much to develop the system. Now I do not like the dependence of the broadcast on my laptop. And what if I'm on the road, or forgot a laptop? For this purpose, I plan to push the robot murmur to the server, which will include all the buddies in the file in an hour - (as the Mumble desktop client can do), and with a button somewhere on the web under the password will start and then stop the broadcast on the icecast server. The main thing is to maintain the weekly schedule online, and you can collect the podcast later. In this configuration, I will be able to broadcast even from a smartphone.

Need a bar and a pop filter for the microphone, yes. Still lazy to poke connectors in JACK, you need to write a script. Adjust the microphone filters so that you do not have to clean the recording from noise every time in Audacity. Fix, finally, the RSS in the podcast blog.All this stuff, the main thing - we took and did, now our community has a predictable, regular broadcast, in which you can participate both through the IRC channel and with your voice. Hearing the voices of the participants, after all, is not at all like reading them on the forum: the community seemed to have received a new dimension, people became visible behind the words.

Source: https://habr.com/ru/post/239541/


All Articles