SynthMaker

more efficent Code for env

Archive · 2008 1 old post

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

infuzion ·

example for the "D" env in 1.0.9: hop(16) { // Make D at least 16 samples d = (d < 16)&16 + (d >= 16)&d; tmp = 0.0625*d - 0.4999; d = 16*rndint(tmp);

// Get Decay step size dStep = 16/d; }

// Reset on retrigger val = val&(env!=1) + (env>1)&(prevEnv==1)&1; out = out&(env!=1) + (env>1)&(prevEnv==1)&1; cnt = cnt&(env!=1);

A few simple optimizations can save average 20 or so cycles here, likely 25+ in the ADHSR, just by a few simple changes. I think the hop()s can be merged. Using max & having cloned condition checks run once & saved as a variable will save a few clocks also: hop(16) { // Make D at least 16 samples tmp = 0.0625*max(d,16) - 0.4999; d = 16*rndint(tmp); // Get Decay step size dStep = 16/d; }

// Reset on retrigger envNot1 = env!=1; tmp = (env>1)&(prevEnv==1)&1; val = val&envNot1 + tmp; out = out&envNot1 + tmp; cnt = cnt&envNot1;

Of course, an ASM version would be better, like Exo's with some of my tips. But even these simple Code changes can save enough energy for Gore to air another radio broadcast whining about global warming or something. 😉 == Also, I've learned way back it is best practice not to use "reserved words" as variable names. Luckily, SM is very forgiving here. Still, it might be a good idea not to use inc as a variable name, since it is an x86 ASM opcode. Perhaps incr is better?

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.