Originally, flanging was produced by playing the same signal on two synchronized reel-to-reel tape recorders and making one of the reels slow down and speed up by pressing on the flange of the reel (hence the name). This is a type of comb filtering, and produces a harmonically-related series of peaks and notches in the audio spectrum.
This flanger uses a delay line, combining the original voice with only one sample from the delay line, but the position of that sample varies sinusoidally.
The effect can be represented as:
result = sample(0) + sample(dt + depth*sin(2*PI*Fe))
The value of the sine function is always a number from -1 to +1 and so the result of depth*(sin(Fe)) is always a number from -depth to +depth. Thus, the delayed sample will be selected from the range (dt-depth) to (dt+depth). This selection will vary at whatever rate is specified as the frequency of the effect, Fe. Typically a low frequency (a few Hertz) is used.
Port | Purpose |
---|---|
In 0 | Signal Input |
Out 0 | Flanged Output |
begin(delayBuffer, length, offset, depth, delayRate);
Create a flanger by specifying the address of the delayline, the total number of samples in the delay line (often done as an integer multiple of AUDIO_BLOCK_SAMPLES), the offset (how far back the flanged sample is from the original voice), the modulation depth (larger values give a greater variation) and the modulation frequency, in Hertz.
modify(offset, depth, delayRate);
Alters the parameters in a running flanger (previously started with begin).
File > Examples > Audio > Effects > Flange
The longer the length of the delay buffer, the more memory blocks are used.
Try these settings:
#define FLANGE_DELAY_LENGTH (2*AUDIO_BLOCK_SAMPLES)
and
int s_idx = 2*FLANGE_DELAY_LENGTH/4;
int s_depth = FLANGE_DELAY_LENGTH/4;
double s_freq = 3;
The flange effect can also produce a chorus-like effect if a longer
delay line is used with a slower modulation rate, for example try:
#define FLANGE_DELAY_LENGTH (12*AUDIO_BLOCK_SAMPLES)
and
int s_idx = 3*FLANGE_DELAY_LENGTH/4;
int s_depth = FLANGE_DELAY_LENGTH/8;
double s_freq = .0625;