First order filter equation?

Official support for: sonicbirth.sourceforge.net
Post Reply New Topic
RELATED
PRODUCTS

Post

I would like to implement a simple first order (6dB /oct ) filter using an equation in SB because the existing filters are too steep.

Has anyone had any luck?

Post

I sort-of tried that and what it amounted too was adding delayed versions of the signal back to the signal - you know, adding adjacent samples will attenuate high frequencies since rapidly changing component frequencies in the waveform will likely be significantly out of phase. I found that you could basically do any FIR filter you wanted ie y(n) = a*x(n-1) + b*x(n-1) + ...
and that you can even do an IIR where say, y(n) = c*y(n-1) - d*y(n-2) + ... by using the feedback and feed-forward comb filter elements. But then you probably know all this already too.

Anyway I made a very simple FIR low pass this way and understood how to turn it into a high pass after a little reading. But when it started to get deep into calculating the darn filter coefficients a, b, c etc. which I assume would have to be calculated in real time based on input sliders I got weary and gave up - Z-transforms, desired filter slopes and all that. But my simple LPF definitely worked and I see absolutely no reason that you couldn't (if you knew how to calculate the coefficients using equations based on input slider values) implement any filter including a Linear Phase one if you wanted (I didn't).

Post

Thansk, that's very interesting.. how did it -sound-?

Here is a textbook example, but I cannot get the syntax correct in Sonicbirth... any suggestions?



lowShelf: H(s) = A * (s^2 + (sqrt(A)/Q)*s + A)/(A*s^2 + (sqrt(A)/Q)*s + 1)

b0 = A*( (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha )
b1 = 2*A*( (A-1) - (A+1)*cos(w0) )
b2 = A*( (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha )
a0 = (A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alpha
a1 = -2*( (A-1) + (A+1)*cos(w0) )
a2 = (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha



highShelf: H(s) = A * (A*s^2 + (sqrt(A)/Q)*s + 1)/(s^2 + (sqrt(A)/Q)*s + A)

b0 = A*( (A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alpha )
b1 = -2*A*( (A-1) + (A+1)*cos(w0) )
b2 = A*( (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha )
a0 = (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha
a1 = 2*( (A-1) - (A+1)*cos(w0) )
a2 = (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha

Post

When I say that I sort of gave up, that's what I'm talking about. I can't translate or rather transform that into particular weightings of samples from the audio stream in SB. What exactly are H(s), s, wo, alpha, A, and Q? I'm guessing that Q is bandwidth as it always is and wo (really omega-naught) is the cutoff frequency. There are apparently a few ways to look at filters just as Fourier Analysis transforms Amplitude-Time space into Amplitude-Frequency space; either a Hilbert Transform or a Z Transform. But I don't know what those are. Somehow, the coefficients to produce the desired filter characteristics are obtained that way which looks like what you've got there.

Post

I've never used SonicBirth so i don't know how you handle inits and stuff but it goes something like this:
You need 3 float variables.
float input,output,frequency;
output needs to be initialized to 0.0 and frequency should be in the 0.0 to 1.0 range.

Then it's a simple matter of
output = input * (1.0 - frequency) + output * frequency;

That's your 6 dB/oct filter.

Post

jupiter8 wrote:I've never used SonicBirth so i don't know how you handle inits and stuff but it goes something like this:
You need 3 float variables.
float input,output,frequency;
output needs to be initialized to 0.0 and frequency should be in the 0.0 to 1.0 range.

Then it's a simple matter of
output = input * (1.0 - frequency) + output * frequency;

That's your 6 dB/oct filter.
Would a frequency of "1" in the above equation be 1/2 nyquist?

Post

zmix wrote:
jupiter8 wrote:I've never used SonicBirth so i don't know how you handle inits and stuff but it goes something like this:
You need 3 float variables.
float input,output,frequency;
output needs to be initialized to 0.0 and frequency should be in the 0.0 to 1.0 range.

Then it's a simple matter of
output = input * (1.0 - frequency) + output * frequency;

That's your 6 dB/oct filter.
Would a frequency of "1" in the above equation be 1/2 nyquist?
A frequency of 1.0 would add input * 0.0 (out = in * (1.0 -1.0)) so that would be 0 hz.

Post

jupiter8 wrote:
zmix wrote:
jupiter8 wrote:I've never used SonicBirth so i don't know how you handle inits and stuff but it goes something like this:
You need 3 float variables.
float input,output,frequency;
output needs to be initialized to 0.0 and frequency should be in the 0.0 to 1.0 range.

Then it's a simple matter of
output = input * (1.0 - frequency) + output * frequency;

That's your 6 dB/oct filter.
Would a frequency of "1" in the above equation be 1/2 nyquist?
A frequency of 1.0 would add input * 0.0 (out = in * (1.0 -1.0)) so that would be 0 hz.
If the frequency was 0.5 the transfer function would be: output = input /2 +output/2

it's recursive, right?

This seems like a high level syntax form MAX or some object oriented system.... anyone implement this in SB?

Post

zmix wrote:
jupiter8 wrote:
zmix wrote:
jupiter8 wrote:I've never used SonicBirth so i don't know how you handle inits and stuff but it goes something like this:
You need 3 float variables.
float input,output,frequency;
output needs to be initialized to 0.0 and frequency should be in the 0.0 to 1.0 range.

Then it's a simple matter of
output = input * (1.0 - frequency) + output * frequency;

That's your 6 dB/oct filter.
Would a frequency of "1" in the above equation be 1/2 nyquist?
A frequency of 1.0 would add input * 0.0 (out = in * (1.0 -1.0)) so that would be 0 hz.
If the frequency was 0.5 the transfer function would be: output = input /2 +output/2

it's recursive, right?

This seems like a high level syntax form MAX or some object oriented system.... anyone implement this in SB?
Yes it's recursive. It takes the previous output and feeds that back to the present output.

The way i wrote it is pseudo C/C++ code. I have never used SonicBirth so i have no idea what syntax it expects.

Post

As far as I can tell SB does not allow the output of the equation to be used as a variable... :help:

Post

zmix wrote:As far as I can tell SB does not allow the output of the equation to be used as a variable... :help:
I just had a look at the SB site. I thought you could program your own modules but that does'nt seem to be the case. You probably can't use feedback paths. You usually can't.

Post

the feedback element is limited to some number of milliseconds so that's useless. But can't you use the feedback comb filter module to do this? I think that's what I was going to try way back when.

Post

zmix wrote:I would like to implement a simple first order (6dB /oct ) filter using an equation in SB because the existing filters are too steep.

Has anyone had any luck?
Well, I have the same problem!
I also use synthedit, and there is a useful 1 pole filer in default installation; a more CPU expensive 1 pole 1 zero from Scoofster http://scp.web.elte.hu/synthedit/modules.html is even better.
From these filters you can virtually generate every other non-resonant filter, by summing/chaining/subtracting from themself or from original audio.
I think coding a 1 pole filter is less difficult respect coding higher-order filters. So, why there are only 2 poles filters? EVERY other thing works really well! :)
Is it possible to code third party modules in sonicbirth?

nck

[edit]

maybe i just found a solution:
I created a circuit with 2 input(input and f).
In circuit:
12dbHP(input,f)
12dbLP(input,f)
equation with 3 input:
i0=input
i1=12dbHP(input,f)
i2=12dbLP(input,f)
=> (i0-i1-i2)*0.5

3 output:
1pole HP: 12dbHP(input,f)+equation
1pole LP: 12dbLP(input,f)+equation
1pole BandPass: equation

maybe i just discovered warm water, maybe not, but it seems to work!
'cause ORIGINAL-LP12db-HP12db=2xBP6db

Let me know, am I totally wrong? :)

cheers, nck
[/edit]
nobody knows whether we were catalysts or invented something, or just the froth riding on a wave of its own. we were all three, i suppose. (ginsberg)

Post

nck wrote:
zmix wrote:I would like to implement a simple first order (6dB /oct ) filter using an equation in SB because the existing filters are too steep.

Has anyone had any luck?
Well, I have the same problem!
I also use synthedit, and there is a useful 1 pole filer in default installation; a more CPU expensive 1 pole 1 zero from Scoofster http://scp.web.elte.hu/synthedit/modules.html is even better.
From these filters you can virtually generate every other non-resonant filter, by summing/chaining/subtracting from themself or from original audio.
I think coding a 1 pole filter is less difficult respect coding higher-order filters. So, why there are only 2 poles filters? EVERY other thing works really well! :)
Is it possible to code third party modules in sonicbirth?

nck

[edit]

maybe i just found a solution:
I created a circuit with 2 input(input and f).
In circuit:
12dbHP(input,f)
12dbLP(input,f)
equation with 3 input:
i0=input
i1=12dbHP(input,f)
i2=12dbLP(input,f)
=> (i0-i1-i2)*0.5

3 output:
1pole HP: 12dbHP(input,f)+equation
1pole LP: 12dbLP(input,f)+equation
1pole BandPass: equation

maybe i just discovered warm water, maybe not, but it seems to work!
'cause ORIGINAL-LP12db-HP12db=2xBP6db

Let me know, am I totally wrong? :)

cheers, nck
[/edit]
Hi Nck!

Would you be willing to post or email that circuit?

zmix at zmix dot net

Post

zmix wrote:
nck wrote:
zmix wrote:I would like to implement a simple first order (6dB /oct ) filter using an equation in SB because the existing filters are too steep.

Has anyone had any luck?
Well, I have the same problem!
I also use synthedit, and there is a useful 1 pole filer in default installation; a more CPU expensive 1 pole 1 zero from Scoofster http://scp.web.elte.hu/synthedit/modules.html is even better.
From these filters you can virtually generate every other non-resonant filter, by summing/chaining/subtracting from themself or from original audio.
I think coding a 1 pole filter is less difficult respect coding higher-order filters. So, why there are only 2 poles filters? EVERY other thing works really well! :)
Is it possible to code third party modules in sonicbirth?

nck

[edit]

maybe i just found a solution:
I created a circuit with 2 input(input and f).
In circuit:
12dbHP(input,f)
12dbLP(input,f)
equation with 3 input:
i0=input
i1=12dbHP(input,f)
i2=12dbLP(input,f)
=> (i0-i1-i2)*0.5

3 output:
1pole HP: 12dbHP(input,f)+equation
1pole LP: 12dbLP(input,f)+equation
1pole BandPass: equation

maybe i just discovered warm water, maybe not, but it seems to work!
'cause ORIGINAL-LP12db-HP12db=2xBP6db

Let me know, am I totally wrong? :)

cheers, nck
[/edit]
Hi Nck!

Would you be willing to post or email that circuit?

zmix at zmix dot net
Yeah! Image
nobody knows whether we were catalysts or invented something, or just the froth riding on a wave of its own. we were all three, i suppose. (ginsberg)

Post Reply

Return to “SonicBirth”