SynthMaker

Tobybear Filter code problem

Archive · 2008 7 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

oddson ·

Can anyone tell me why this code (taken directly from FilterExplorer's C++ output and only slightly adapted) does not work as a peak cut filter.

streamin x; streamout y; streamin t0; // c0=t0 so cut out a step streamin c1; streamin c2; float a0,a1,a2,b1,b2,t1,t2,t3,t4,xold1,xold2,yold1,yold2;

// calculate temporary variables hop(128){ t1=tan1(t0); // t1=tan(pi*t0/2) t2=10*c1+0.001; t3=1-c2; t4=1+(t1/t2)+t1*t1; // calculate coefficients a0=(1+(t3*t1/t2)+t1*t1)/t4; a1=(2*(t1*t1-1))/t4; a2=(1-(t3*t1/t2)+t1*t1)/t4; b1=(2*(t1*t1-1))/t4; b2=(1-(t1/t2)+t1*t1)/t4; }

// process input yold2=yold1; yold1=y; y= a2*xold2+ a1*xold1+ a0*x -b2*yold2 -b1*yold1; xold2=xold1; xold1=x;

The problem seems to occur in the output function and the lagged y values but I can't seem to figure out why (the a/b coefs are calculating to valid non-zero floats but the bi-quad won't calculate and returns a '#IND' result).

MyCo ·

I'm not sure, but shouldn't this:

t1=tan1(t0); // t1=tan(pi*t0/2)

be translated that way:

t1=tan1(t0*0.25); // t1=tan(pi*t0/2)

t0 is in the range of 0..1 so t1 should be tan(0...pi/2) which is tan1(0..0.25)

just a guess... may be the original code could help

oddson ·

Thanks MyCo... other than that line this is the original code.

I put the comment in to make sure I hadn't introduced the problem there.

Now that I look it over it does seem wrong... but I still don't see why the output function blows up on me.. all the component values seem well behaved even if they're not correct.

MyCo ·

So the problem still exist with my change?

may be you could provide a test schematic... It's hard to understand if you can't see/hear anything 🙂

oddson ·

No... it's sorted. Thanks.

infuzion ·

Is this the Badboy from the SM WIKI?

oddson ·

No... I'm trying to use Tobybear's Filter Explorer to generate C++ code and alter that for SM use. It gets you 90% of the way there but you still have to know what you're doing and not make stupid math mistakes. 😊

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.