But when I try to put the coefficients in directly it messes up. I think it has to do with the decimal representation of the floats. With values so very close to whole numbers I guess you have to be correct to the last bit.
oddson wrote: But if I try to sub these values (calculated using Excel from the same formulas as above):
-0.999857659
1.999715319
-0.999857659
-1.999715301
0.999715337
...I get an unstable filter.
double floatsaren't available yet...well you can try in regular ASM.
oddson ·
infuzion wrote: double floatsaren't available yet...well you can try in regular ASM.
I know... I'm trying to over-determine the single float values so they will set to bit-level accuracy but it's not working. The max. resolution for floats does not correspond exactly to a certain number of decimal places but I thought SynthMaker's code module should be able to set them if there are more decimals than are needed but it does not seem to be working. I think it's a deficiency in the code module but I'm not 100% sure.
I wonder if I can assign them in ASM at the bit level?
infuzion ·
There are only so many bits in a 32bit float you can fill, no matter how you fill it. You could split up the math, but that could get messy & expensive, & the output will still be 32bit.
oddson ·
I'm only talking about getting the right 32 bits saved... somehow when I use the above numbers -- which should be more than accurate enough -- I get an unstable filter. But when I use calculation that should lead to the single float equivalents -- I get a filter that works quite well... but I waste a few cycles in stage zero calculating them every time -- even though they are the same every time...
1) this would appear to be a minor bug in the way SM converts decimal values into 32 bit floats
2) is there a workaround to avoid the calculation described?
MyCo ·
This could do it:
streamin in;
streamout out;
float lastin;
float lastout;
out = in-lastin + 0.9999*lastout;
lastin = in;
lastout = out;
coeffs are:
a0 = 1
a1 = -1
a2 = 0
b1=-0.9999
b2=0
oddson ·
Ok... 😊 well that's much simpler and seems to work nicely.
I've also discovered mine is inverting the signal... maybe I should leave filters for the DSP experts. 😉
It still makes me wonder about how SynthMaker's code module assigns decimal values to floats...
MyCo ·
if you want to know how a float is stored, you can just assign it to an output, and then connect my stream inspector to it. It can show you the exact hex value.
bootsy ·
And don't forget to scale the mult factor (frequency) depending on your samplerate, should be 1-(2*PI*frequency/samplerate).
hansdump ·
of course you can change that coeffs if you want a quick or slow dc adaption...
just have a read at this https://ccrma.stanford.edu/~jos/fp/DC_Blocker.html for more theoretical background.
dc tracking values from 1...0.9
//dctracking: a low value allows
// faster tracking