SynthMaker

Smooth transitions in code.

Archive · 2012 13 old posts

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

MDMA ·

Hi guys, So I've just recently decided to dive into code and am trying to create a kind of sidechain effect for a vst with 2 separate midi channels.

I need "In" to be "0" (or whatever its recieved in "amt") when I recieve a true value in "streamboolin" and it to be "In" again when the "streamboolin" is false.

The following code works for me but I have lots of clips in the sound because I don't know how to make things smoother.

streamboolin On; streamin In; streamin amt; streamout out1; float out;

out = (On==1) & (In * amt) + (On==0) & (In); out1 = min(1,max(out,0));

I've been looking but cant understand how I can make this go from "0" to "x" and back with a bit of smoothing. So instead of having a chage like this: 0 1 I'd like to achieve something like this: 0 0.1 0.2 0.3 0.4 etc...

How is this done? A Loop in the code? Transitional Delay? Envelope Follower?

Thanks in advace!

Xtinct ·

+1 I usualy smooth out with an env follower but would also like to find out how to do it in code. If only there was a asm to code converter as asm is way beyond me.

Mo ·

MDMA wrote: I've been looking but cant understand how I can make this go from "0" to "x" and back with a bit of smoothing.

By using a simple lowpass filter:

streamin in; streamout out; streamin cutoff; out=out*(1.0-cutoff)+in*cutoff;

MDMA ·

Mo wrote: MDMA wrote: I've been looking but cant understand how I can make this go from "0" to "x" and back with a bit of smoothing.

By using a simple lowpass filter:

streamin in; streamout out; streamin cutoff; out=out*(1.0-cutoff)+in*cutoff;

Thanks for the reply but how would I implement that in this code? Like this:

streamboolin On; streamin In; streamin amt; streamout out1; float out;

out = (On==1) & (In * amt) + (On==0) & (In); out1 = out*(1.0-amt)+in*amt;

Mo ·

For a simple selector, here is a better solution using less cpu:

Add a LP before the Select input for a more smooth transition.

Here's an ASM version of the selector including smooth/LP with denormal remover build in:

//Smooth Stream Select//Mo streamin On; streamin In; streamin amt; streamout out; float F1=1; float LP=0; float true=0; float F1eM008=1e-008; //smooth movaps xmm0,On; subps xmm0,LP; mulps xmm0,amt; addps xmm0,LP; addps xmm0,F1eM008; subps xmm0,F1eM008; movaps LP,xmm0; //selector movaps xmm0,F1; movaps xmm1,LP; subps xmm0,xmm1; mulps xmm0,In; mulps xmm1,true; addps xmm0,xmm1; movaps out,xmm0; Set "amt" to something like 0.01 to avoid the clips in sound.

MDMA ·

Thanks a lot Mo!!! It works perfectly now!

Just one thing, I can't understand how the lowpass filter code really works and is it a 6db filter? I'd like to create more things with code, like filters, envelopes, oscillators, etc. I've read quite a fair bit of the SOS synth secrets articles but can't seem to find a resorce that actually shows us how to build these elements with code.

Could you please point the right direction to learn about this?

Thanks again for the support!

Mo ·

Yes, it is a first order/1-pole/6 Db lowpass filter.

There's a lot of coding tips here on forum and wiki. For me it is the easiest to make the code in ASM.

MDMA ·

Mo wrote: Yes, it is a first order/1-pole/6 Db lowpass filter.

There's a lot of coding tips here on forum and wiki. For me it is the easiest to make the code in ASM.

Cheers, I'll have a look arround! You rather use ASM? I thought ASM was a lot more complicated???

Mo ·

MDMA wrote: You rather use ASM? I thought ASM was a lot more complicated???

Yes. It takes some time to learn well but then i think it is more easy to read, write, troubleshoot and optimize.

Acrobat ·

MDMA wrote: I can't understand how the lowpass filter code really works and is it a 6db filter?

Let me chat about it in my way, you or other people here might appreciate:

One cool thing spreading out of the filter subject is that filters are like "differential delays". If you let yourself see them this way, you'll discover that they're just influencing frequencies: in a LP the faster are attenuated, the lower ones are preserved.

The steepness (6, 12, 18 24dB) actually represents the width of the grey-zone between attenuation and preservation. Since the grey-zone is particularly wide for 6db filters, they act like smoothers because they interact also with particularly slow value changes, like knob movements, and to do that it's only the case of setting them in a strategic frequency range.

A.

bootsy ·

why not use the de-zipper?

oddson ·

bootsy wrote: why not use the de-zipper?

I was going to ask the same thing when this thread was new but I looked into the code's performance and it seems like a pretty light way of doing the same thing.

infuzion ·

Surprised the question of "Linear or dB?" has not been raised yet... since "smooth" would be relative to dB in my eyes, ur ears, yet the code seems to linear.

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.