Inserting software high-pass and gain between sound card and application software

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Hi all,

There is a field biologist on this forum who tries to monitor the sounds of migrating birds using microphone capsules, sound cards and special software on a Raspberry Pi, see https://www.diyaudio.com/forums/everything-else/352655-advice-weird-project.html

He needs to somehow increase gain and insert a high-pass filter between the microphone and the special bird recognition software. I can give him advice on how to do that in the analogue domain between microphone and sound card, but measurements show that a software solution between sound card and bird recognition software would result in almost the same noise floor.

Does anyone know how to insert a real-time software high-pass filter and gain stage in between the sound card and the bird recognition software? A second-order IIR filter at 1 kHz would be sufficient.

Best regards,
Marcel
 
The Raspberry Pi runs Linux. What this person needs is a volume control on the input that can apply gain to the signal. If there is not one built in to ALSA then he can create one with something called a softvol ALSA control. There are several examples on the web, so Google it.

If you/he cannot figure it out, post again or PM me and I will help.
 
Like I said, this is a very common problem. Use Google and your brain and you will get lots of tips, even code you can copy.

For example:
alsa - How do I increase the input volume of a microphone connected to pi .Its using the I2S interface - Raspberry Pi Stack Exchange

ALSA microphone volume configuration - Raspberry Pi Forums

Volume Boost with Alsa Pre-Amp Control

etc...

Also, it's possible to implement LADSPA plugins within ALSA, so you could do both using a custom asoundrc file. There are some threads on that topic in this forum.

As someone once wrote-ish: "Dog helps those who help themselves."
 
Last edited:
Like I said, this is a very common problem. Use Google and your brain and you will get lots of tips, even code you can copy.

For example:
alsa - How do I increase the input volume of a microphone connected to pi .Its using the I2S interface - Raspberry Pi Stack Exchange

ALSA microphone volume configuration - Raspberry Pi Forums

Volume Boost with Alsa Pre-Amp Control

etc...

Also, it's possible to implement LADSPA plugins within ALSA, so you could do both using a custom asoundrc file. There are some threads on that topic in this forum.

As someone once wrote-ish: "Dog helps those who help themselves."

Hey Charlie, I am the biologist trying to get this thing figured out. I currently use software developed in the UK for converting a rpi into an autonomous recording unit. The software website is: Solo: home

The software is built off of raspian buster lite. The software has the ability to control the sound card (sound blaster play 3!), but what I really need is the ability to incorporate a high-pass filter (as Marcel posted).

I will tinker tonight with some of your suggestions to see if I can incorporate them into the solo.img. This is all new to me and there will be a steep learning curve on my part. Thanks for your help!
 
Hey Charlie, I am the biologist trying to get this thing figured out. I currently use software developed in the UK for converting a rpi into an autonomous recording unit. The software website is: Solo: home

The software is built off of raspian buster lite. The software has the ability to control the sound card (sound blaster play 3!), but what I really need is the ability to incorporate a high-pass filter (as Marcel posted).

I will tinker tonight with some of your suggestions to see if I can incorporate them into the solo.img. This is all new to me and there will be a steep learning curve on my part. Thanks for your help!

Another potential solution (which I think phofman was alluding to) is to use another program in between your microphone and your recording software. In order to make that work, you need a way to pass the audio output from the first program to the audio input of the second program. There are two basic ways to do this under Linux:
(1) use a pipe:
In Linux you can chain the output of program P1 to the input of program P2 using a pipe. P1 must be able to write to stdout and P2 must be able to read from stdin, and there must be a common format for both.
(2) use an ALSA loopback:
ALSA comes with a module called a "loopback". You can enable it using sudo modprobe snd-aloop. This is essentially an audio-specific pipe. Since it is audio specific any audio processing program should be able use it. This is your best bet.

So, you use an audio program of your choosing to get audio from the microphone and apply gain and the filter. Then that program sends the audio to the ALSA loopback, e.g. hw:CARD=loopback,device=0. In your own sound processing program, you simple get input from the same loopback, but the "other end" (one end is device 1, and the other end is device 0), so use hw:CARD=loopback,device=1.

I have used this approach many time to pass audio between programs. Give it a try.

For a simple and lightweight program for getting mic audio, and applying gain and the filter, try "ecasound" (sudo apt install ecasound). The manpage is here:
ecasound
Gain adjustment is done using :
-eadb:gain-dB[,channel]
There is a built-in first order highpass filter:
-efh:cutoff-freq
Ecasound can implement the LADSPA filters I mentioned if the built in one is not what you need. LADSPA filtering tutorial with ecasound:
Digital Crossover/EQ with Open-Source Software: HOWTO | Richard's Stuff

Once you figure out which direction you want to go, post here for more help.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.