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?