SynthMaker

Lattice filter

Archive · 2007 3 old posts

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

tobiah ·

Hello everyone!

I want to make a VST with a lattice filter I have found from the tms5220 chip but I cant get it right.

My thoughts are that I might have to work in a lower bitrate but is that possible in SM?

What am I doing wrong?

Thank you in advance!

The source is here, search for lattice_filter: http://mamedev.org/source/src/emu/sound/tms5220.c.html

the code i have written in a code component is: ------------------------------------------------------------

streamin in; streamout out;

streamin res1; streamin res2; streamin res3; streamin res4; streamin res5; streamin res6; streamin res7; streamin res8; streamin res9; streamin res10;

float u[10]; float x[9];

u[10] = in;

u[9] = u[10] - (res10 * x[9]); u[8] = u[9] - (res9 * x[8]); u[7] = u[8] - (res8 * x[7]); u[6] = u[7] - (res7 * x[6]); u[5] = u[6] - (res6 * x[5]); u[4] = u[5] - (res5 * x[4]); u[3] = u[4] - (res4 * x[3]); u[2] = u[3] - (res3 * x[2]); u[1] = u[2] - (res2 * x[1]); u[0] = u[1] - (res1 * x[0]);

x[9] = x[8] + (res9 * u[8]); x[8] = x[7] + (res8 * u[7]); x[7] = x[6] + (res7 * u[6]); x[6] = x[5] + (res6 * u[5]); x[5] = x[4] + (res5 * u[4]); x[4] = x[3] + (res4 * u[3]); x[3] = x[2] + (res3 * u[2]); x[2] = x[1] + (res2 * u[1]); x[1] = x[0] + (res1 * u[0]);

x[0] = u[0];

out = u[0];

rl ·

Welcome tobiah! hmm... your code looks quite reasonable. For performance reasons I'd avoid arrays as much as possible. For indexing a float->int conversion is needed, which takes a fair amount of clock cycles. The following code is about 10 times faster ( and the frequency response looks quite lattice-ish):

streamin in; streamout out; streamin res1; streamin res2; streamin res3; streamin res4; streamin res5; streamin res6; streamin res7; streamin res8; streamin res9; streamin res10;

float u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10; float x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x9;

u10 = in;

u9 = u10 - (res10 * x9); u8 = u9 - (res9 * x8); u7 = u8 - (res8 * x7); u6 = u7 - (res7 * x6); u5 = u6 - (res6 * x5); u4 = u5 - (res5 * x4); u3 = u4 - (res4 * x3); u2 = u3 - (res3 * x2); u1 = u2 - (res2 * x1); u0 = u1 - (res1 * x0);

x9 = x8 + (res9 * u8); x8 = x7 + (res8 * u7); x7 = x6 + (res7 * u6); x6 = x5 + (res6 * u5); x5 = x4 + (res5 * u4); x4 = x3 + (res4 * u3); x3 = x2 + (res3 * u2); x2 = x1 + (res2 * u1); x1 = x0 + (res1 * u0);

x0 = u0;

out = u0;

BTW: there are differences to the C-code (scaling down / 32768), but I guess this is by intention.

tobiah ·

Thank you rl.

Now it works as it should. And if it is as you say ten times faster, my CPU will love you.

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.