Audio click/pop using selector & filters

For general discussion related FlowStone
Post Reply
Drnkhobo
Posts: 312
Joined: Sun Aug 19, 2012 7:13 pm
Location: ZA

Audio click/pop using selector & filters

Post by Drnkhobo »

Hey all, I have noticed a click in the audio when using a selector with a filter. The selector chooses the filters 'pole' which in my case is another filter. . . .

6dB = one filter
12dB = two filters (serial)
ect

so I understand that when the selector changes to either stream there will be a difference in the audio (naturally from the second filter) but how can I get around this?

I have thought about using a counter to trigger when the selectors index changes. This counter multiplys the stream from 0-1 so when you change the pole, it ramps up the audio from 0-1. but then the audio will drop when I ramp it up!

lol, I dont know if anyone has a work around? or if I have missed something?

Have a look at a quick fsm:

poleswitch.fsm
(10.98 KiB) Downloaded 1067 times


Has anyone used a pole select in their projects? Did you use a selector like this?
Morph
Posts: 53
Joined: Tue Jul 13, 2010 1:59 pm

Re: Audio click/pop using selector & filters

Post by Morph »

Hi

The selector recompile the schematic on change, so use multiply instead should work.

poleswitchmul.fsm
(11.48 KiB) Downloaded 1083 times


If it still pop, use de-zip between green and stream.
Drnkhobo
Posts: 312
Joined: Sun Aug 19, 2012 7:13 pm
Location: ZA

Re: Audio click/pop using selector & filters

Post by Drnkhobo »

Nice work around Morph! Thanks mate ;)

Dont know why I never thought to multiply the streams beforehand!

Just saw in the RBJ filter dsp module a line like this

Code: Select all

stage(0)
{
  abs = 3.4e38|0.999999|0.1;
}


Anyone know what the "|" is for???
Morph
Posts: 53
Joined: Tue Jul 13, 2010 1:59 pm

Re: Audio click/pop using selector & filters

Post by Morph »

Drnkhobo wrote:Anyone know what the "|" is for???

"Or".
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: Audio click/pop using selector & filters

Post by Nubeat7 »

one of the things which is not to find in the user guide!
Drnkhobo
Posts: 312
Joined: Sun Aug 19, 2012 7:13 pm
Location: ZA

Re: Audio click/pop using selector & filters

Post by Drnkhobo »

Guys, i dont understand that . . . :oops:

the code is telling me that abs is equal to: 3.4e38|0.999999|0.1

so where does the OR operator compare? And to what? BOOL?

I know that the purpose of this line is to assign abs a value of either one of those but i dont get how its doing it.
I have/had the understanding that the OR compares two values & outputs 0/1 depending on if any are true . . .

Hang on, is this actually saying that abs equals 1 if 3.4e38 or 0.999999 or 0.1 ????
User avatar
trogluddite
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: Audio click/pop using selector & filters

Post by trogluddite »

It is float number voodoo black magic! ;)

The result of the OR line is a special value used for creating an ABS function elsewhere in the code...
Drnkhobo wrote:I have/had the understanding that the OR compares two values & outputs 0/1 depending on if any are true . . .

That's basically right, but in code (not 'green'), AND and OR work along the bits in each number, and'ing and or'ing things one bit at a time - so bit 0 of the output comes from bit 0 of each input value, and so on...
When you do a comparison in code, the result is a value with either ALL of the bits on (true), or ALL of the bits OFF false) - different than the simple 0/1 of 'green'. And that gives us the familiar behaviour of comparisons in code, where "TRUE & x = x" and "FALSE & x = 0".
However if you start AND'ing and OR'ing other number combinations, things get a little more, erm, "interesting"...

A float number has 32bits (well, not always, but it does in FS) - and the very last of them is the sign-bit that says whether a number is positive or negative - when that bit is ON, the number is negative.

So to get the ABS of a float number, you could just make sure that the sign bit is off - the other bits would stay the same, and abracadabra, we would always have a positive number. Hmm, but how?

Well, there is a way using a bitmask - you just need a number with all of the bits set to ON except for the sign-bit. You then do an AND (&) operation (which works one bit at a time), to get a result something like this...

0 1111111111111111111111111111111 (Special bitmask)
AND
1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (A negative number because the sign bit is ON)
EQUALS
0 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (the same number but positive)

And somewhere in your code, i bet you will find exactly that... "answer = some_value & abs".

But there's a problem here; the bit 'pattern' in that special bitmask doesn't actually represent any particular float number that you could just write down in code - if you send 'abs' to a stream out and look at it with a readout, it will say "#.QNAN", the error message for "Not A Number".
However, like the AND '&' operator, the OR '|' also works one bit at a time - and by OR'ing those particular three numbers together, you can create exactly the bit pattern that you need for the ABS bitmask.

I first saw that very early on in my SM days, and I have no idea who worked it out - but it is a mighty fine bit of hacking, because doing "& abs" takes way less CPU than the usual ways of making an ABS() function.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Drnkhobo
Posts: 312
Joined: Sun Aug 19, 2012 7:13 pm
Location: ZA

Re: Audio click/pop using selector & filters

Post by Drnkhobo »

:o
Thanks a million Trog, you do know your stuff! LOL experience I guess!

Its still quite tricky!

Code: Select all

out = ((out&abs) > 1e-11)&out;


there's that & !!!!!

Its quite a clever trick :D
User avatar
MyCo
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany
Contact:

Re: Audio click/pop using selector & filters

Post by MyCo »

FIY a shorter version for the abs hack:

Code: Select all

stage(0)
{
  abs = 2|1.9999999;
}
Post Reply