Dynamically Change Chorus and Flange Sample Lengths?

Status
Not open for further replies.

lerxstrulz

Well-known member
Hi All,

Just started experimenting with the chorus effect and flanger effects, and the docs say the only modification you can make to the chorus is the number of voices once you have called begin. On the flanger, you can change offset, depth and freq after calling begin.

I have noticed a difference in sounds if you call begin with different size sample arrays (makes sense lol) and was wondering if it was possible to dynamically change the delay length and buffer as well, but not sure if this is possible without causing memory leaks?

Can I just declare a longer buffer array and then change the delay time as long as it's shorter than the original length? Does it need to match?

For example:

Code:
#define CHORUS_DELAY_LENGTH (16*AUDIO_BLOCK_SAMPLES)
// Allocate the delay line
short delayline[CHORUS_DELAY_LENGTH];

So I have a max of (16*128), but if I say, call begin again to change the delayline with a smaller length:

Code:
chorus1.begin(delayline, 8 * AUDIO_BLOCK_SAMPLES, n_chorus)

would this cause an issue?

Wanting to give the user a way to change the sample length if at all possible without causing memory leaks or crashing the app.

Thank you!
 
Seems like your plan should work. You set the delayline[] size statically and then tell the chorus object how much to use. It doesn't know how much space you've really reserved, just what you tell it. So, as long as you always tell it less than or equal to the real size you shouldn't have a buffer overrun. Since it's all static, there shouldn't be a memory leak.

Give it a try.
 
Status
Not open for further replies.
Back
Top