[linux-audio-dev] Re: LADSPA_Data audio values

Ben Loftis ben at glw.com
Fri Dec 22 14:25:35 UTC 2006


> Message: 3
> Date: Thu, 21 Dec 2006 21:19:04 +0000
> From: iain at g7iii.net (Iain Young)
> Subject: [linux-audio-dev] LADSPA_Data audio values
> To: linux-audio-dev at music.columbia.edu
> Message-ID: <20061221211903.GA14158 at g7iii.net>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi All,
>
> I'm trying to write a LADSPA plugin to do the following:
>
> Given n inputs (lets say 4), and one output, It should present the
> highest "priority" input on the output. Input 1 is the lowest priority,
> with Input 4 being the highest.
>
> In order to write this in code, within the runPriomux function, I do
> this:
>
>    y=-1;
>    for (i=0; i<=3; i++)
>    {
>       pfBuffer=*(pfInput[i]++);
>       if (pfBuffer > -1.0f)
>         y=i;
>     }
>     if (y!=-1)
>       *(pfOutput++)=pfBuffer;
>
>   
Hi Iain,

I don't know your application, but this looks wrong.  If you are trying 
to choose between various microphones, and only output the microphone 
with the highest priority that has audio on it, (i.e. an automixer), 
then you're going to have to do a bit more work than this.

Here are the immediate problems I see (Chris Cannam already indicated 
the first 2)

1)  0.0f indicates silence, not -1.0f
2)  A microphone input will have some noise on it, you'll need an 
adjustable threshold value which separates the "on" state from the "off"
3)  You can't do this on a sample-by-sample basis, you need some time 
averaging:
3a)  you need to implement a rectified, running average value of all 4 
inputs
3b)  you'll need to mix the values of all four buffers into the output, 
with a smoothly changing level control on each input controlled by the logic
4)  Make sure the "decay" of the envelope is kinda long ...this will 
keep a speaker from getting cut off if someody else coughs or whatever

There are other subtleties that apply to an automixer, but this is 
enough to get started.

-Ben Loftis





More information about the Linux-audio-dev mailing list