# Implementation of the Dyna-Flanger (Homework Ch15) | 2nd Ed FX Book Questions | Forum

guest

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

Implementation of the Dyna-Flanger (Homework Ch15)
Member
Members
September 27, 2021 - 5:35 am
Member Since: September 27, 2021
Forum Posts: 5
Offline

Hello Will,

```I have recently bought your excellent book for making audio plugins.

Iâ€™ve got a question for the implementation of the Dyna-Flanger on the Chapter 15 (Modulation Delay).

My idea to implement it is to set the delay time to 0 when the envelope doesnâ€™t detect a value higher than the threshold.

However, it creates a Â«Â clickÂ Â» when the flanger is applied.

How is it possible to fix itÂ ?```

Â

Best regards, Johan.

October 2, 2021 - 11:08 am
Member Since: January 1, 2020
Forum Posts: 103
Offline

Hi Johan,

Sometimes Will is away from the forum for a whiles but I can probably help you here.

Since your delay time of 0 is equal to the dry. Then you can just set up a cross-fading mechanism to smoothly switch between dry and delayed signal.Â

You can do this in a couple of ways, there was a recent forum discussion on here about exponential smoothing but linear ramping is probably the best choice for this case.

I believe there is code for a linear ramp/smoothing function in Will's fxobects.h file though it's also not too hard to write one yourself.

Â

If output = (1.- x) * inputdry + (x) * inputdelayed;

then you need x to be a value of 1 above the threshold and 0 below it.

so simply smooth x first via your choice of filter.

To avoid audible clicks you will probably need the smoothing time to be at least 5ms. It's easiest to check for clicks in this context using a low frequency sine wave.

Â

Great idea by the way.Â

Member
Members
October 6, 2021 - 6:24 am
Member Since: September 27, 2021
Forum Posts: 5
Offline

Hello and thank you for the answer !

I solve the problem

Instead of having a value of 0 or 1, I take the output of the envelope detector (which is between [0, 1] and smooth) and set it as the delay time.

October 7, 2021 - 11:02 am
Member Since: January 1, 2020
Forum Posts: 103
Offline

Awesome, but now volume dynamics are pitch modulating the effect? Very cool stuff.

Â

Incidentally I'd like to reconsider my recommendation of an equal gain crossfading curve as opposed to an equal power one would probably suit better.

i.e something akin to sqrt(x) and sqrt(1-x) rather than x and 1-x - for values of x clamped between 0 and 1.

This can just be achieved by waveshaping the linear xfade with the sqrt or some equivalent type of function.Â  sin(pi/2*x), cos(pi/2*x)

This avoids volume dips when the signals are uncorrelated though it will raise the volume slightly otherwise but is a less noticeable estimate in this context

Cheers

Member
Members
October 11, 2021 - 9:54 am
Member Since: September 27, 2021
Forum Posts: 5
Offline

Hello Jim,

When I said it was working, it's not exactly true.

I recorded some wave file with my guitar to test the plugin.

The audio level is very low so when I strum stronger, you can hear the effect.

However, when I use an audio file with higher level, the effect is always on.

It seems necessary to use a threshold.

In an article for a reverse delay, there is this function for smoothing the reverse signal :

double getGain(double coef) {return 4.0 * coef * (1.0 - coef);}

where coef is the i th element of the delayed signal divide by the delay time.

Â

If I understand what you say previously, you suggest to fade the signal with

output = sqrt(1-x) * inputdry + sqrt(x) * inputdelayed;

Where x is the ouput of a sinus function ?

Â

Best Regards, Johan.

October 12, 2021 - 10:03 am
Member Since: January 1, 2020
Forum Posts: 103
Offline

Hi Johan,Â

Yep you'll probably want the delay fully off when the effect is not meant to be on.

so x is just a linear ramp from 0 to 1 or 1 to 0;

x = fmin(fmax( x + c, 0.0),1.0);Â  where is c is + or - some small value i.e .001

you'd typically set the condition c of being positive or negative according to whether or not the threshold has been met.

The sqrt is then just a waveshaper which approximates that ramp to a sinus function although you could use trigonometry or various other functions.

You have the output equation right.

Member
Members
October 13, 2021 - 6:44 am
Member Since: September 27, 2021
Forum Posts: 5
Offline

Thank you very much for the answer !

I have found a solution.

Like you said, you must have a linear ramp from 0 to 1 or 1 to 0 to prevent the discontinuities.

With the EnvelopeFollower object, when the value detected is above a threshold, you modulate the distance between the threshold and the detected value.

For that, you can do like you explain with :

x = fmin(fmax( x + c, 0.0),1.0);

Or normalize the value between a min and max with the function doUnipolarModulation.

I have test it by modulating the depth and the rate and it's working

Now, the way to do the duck delay is clear.

Thank you very much for the help

October 14, 2021 - 10:04 am
Member Since: January 1, 2020
Forum Posts: 103
Offline

Great to hear, pleasure Johan. Feel welcome to post any further further questions .

Also I'd encourage you to keep experimenting with options for modulating the delay time with an envelope or lp filter.

Cheers,

Jim

Forum Timezone: America/New_York

Most Users Ever Online: 152

Currently Online:
10 Guest(s)

1 Guest(s)

Top Posters:

Chaes: 56

Skyler: 48

StevieD: 46

Derek: 46

Frodson: 45

Peter: 43

TheSmile: 43

Nickolai: 43

clau_ste: 39

jeanlecode: 37

Member Stats:

Guest Posters: 1

Members: 768

Moderators: 1