[LAD] Mixing audio: Noiseless volume changes

Fons Adriaensen fons at linuxaudio.org
Tue Mar 19 15:08:18 UTC 2013


On Tue, Mar 19, 2013 at 03:02:19PM +0100, Tim Goetze wrote:

> > for (i = 0; i < nframes; i++)
> > {
> >     g1 += w * (gt - g1 - a * g2);
> >     g2 += w * (b * g1 - g2);
> >     out [i] = g2 * in [i];
> > }
> 
> Surely you realise this version executes exactly as many additions and
> multiplications per sample as a biquad?

Yes. In this case it's possible to remove one multiplication:

a = 0.07f;
b = 1 + a;

// ...

gm = b * gt;
for (i = 0; i < nframes; i++)
{
     g1 += w * (gm - g1 - a * g2);
     g2 += w * (g1 - g2);
     out [i] = g2 * in [i];
}


But CPU usage is not the point. For a biquad the result
can depend on small differences between the coefficients,
with consequent loss of precision. It's a problem mainly
with LF filters. Try a 10 Hz highpass at 96 kHz.

Ciao, 

-- 
FA

A world of exhaustive, reliable metadata would be an utopia.
It's also a pipe-dream, founded on self-delusion, nerd hubris
and hysterically inflated market opportunities. (Cory Doctorow)



More information about the Linux-audio-dev mailing list