Minim core
ugens
analysis
Name Flanger
Description A Flanger is a specialized kind of delay that uses an LFO (low frequency oscillator) to vary the amount of delay applied to each sample. This causes a sweeping frequency kind of sound as the signal reinforces or cancels itself in various ways. In particular the peaks and notches created in the frequency spectrum are related to each other in a linear harmonic series. This causes the spectrum to look like a comb.

Inputs for the Flanger are:

  • delay (in milliseconds): the minimum amount of delay applied to an incoming sample
  • rate (in Hz): the frequency of the LFO
  • depth (in milliseconds): the maximum amount of delay added onto delay by the LFO
  • feedback: how much of delayed signal should be fed back into the effect
  • dry: how much of the uneffected input should be included in the output
  • wet: how much of the effected signal should be included in the output

A more thorough description can be found on wikipedia: http://en.wikipedia.org/wiki/Flanging

Examples
/* flangerExample
   <p>
   A Flanger is a specialized kind of delay that uses an LFO (low frequency oscillator) 
   to vary the amount of delay applied to each sample. This causes a sweeping frequency 
   kind of sound as the signal reinforces or cancels itself in various ways. In particular
   the peaks and notches created in the frequency spectrum are related to each other in 
   a linear harmonic series. This causes the spectrum to look like a comb and should be
   apparent in the visualization.
   <p>
   Inputs for the Flanger are:
   <ul>
   <li>delay (in milliseconds): the minimum amount of delay applied to an incoming sample</li>
   <li>rate (in Hz): the frequency of the LFO</li>
   <li>depth (in milliseconds): the maximum amount of delay added onto delay by the LFO</li>
   <li>feedback: how much of delayed signal should be fed back into the effect</li>
   <li>dry: how much of the uneffected input should be included in the output</li>
   <li>wet: how much of the effected signal should be included in the output</li>
   </ul>
   <p>
   A more thorough description can be found on wikipedia: http://en.wikipedia.org/wiki/Flanging
   <p>
   For more information about Minim and additional features, 
   visit http://code.compartmental.net/minim/
   <p>
   Author: Damien Di Fede
*/

import ddf.minim.*;
import ddf.minim.ugens.*;
import ddf.minim.analysis.*;

Minim       minim;
AudioOutput out;
Noise       noize;
Flanger     flange;

// we render the spectrum instead of the waveform
// because this lets you really see what the Flanger is doing.
FFT         fft;

void setup()
{
  size( 512, 512 );
  
  minim = new Minim(this);
  out   = minim.getLineOut();
  
  // we use white noise to demonstrate the Flanger effect
  // because the sound of the Flanger is more 
  // pronounced when the audio being flanged 
  // has high frequency content
  noize = new Noise( Noise.Tint.WHITE );
  
  flange = new Flanger( 1,     // delay length in milliseconds ( clamped to [0,100] )
                        0.2f,   // lfo rate in Hz ( clamped at low end to 0.001 )
                        1,     // delay depth in milliseconds ( minimum of 0 )
                        0.5f,   // amount of feedback ( clamped to [0,1] )
                        0.5f,   // amount of dry signal ( clamped to [0,1] )
                        0.5f    // amount of wet signal ( clamped to [0,1] )
                       );
                        
  noize.patch( flange ).patch( out );
  
  fft = new FFT( 1024, out.sampleRate() );
}

void draw()
{
  background( 0 );
  
  stroke( 200 );
  
  fft.forward( out.mix );
  
  for( int i = 0; i < fft.specSize(); ++i )
  {
    float val = fft.getBand( i );
    line( i, height, i, height - pow ( 10.0, (0.05 * val) )*2 );
  }
  
  fill( 255 );
  
  text( "delay: " + nf( flange.delay.getLastValue(), 1, 3 ) + " ms", 5, 15 );
  text( "depth: " + nf( flange.depth.getLastValue(), 1, 3 ) + " ms", 5, 30 );
}

void mouseMoved()
{
  flange.delay.setLastValue( map( mouseX, 0,      width, 0.01, 5 ) );
  flange.depth.setLastValue( map( mouseY, height, 0,     1.00, 5 ) );
}


Constructors
Flanger(delayLength, lfoRate, delayDepth, feedbackAmplitude, dryAmplitude, wetAmplitude);
Parameters
delayLength   float: the minimum delay applied to incoming samples (in milliseconds)
lfoRate   float: the frequency of the the LFO
delayDepth   float: the maximum amount added to the delay by the LFO (in milliseconds)
feedbackAmplitude   float: the amount of the flanged signal fed back into the effect
dryAmplitude   float: the amount of incoming signal added to the output
wetAmplitude   float: the amount of the flanged signal added to the output
Fields
audio   Where the input goes.

delay   How much does the flanger delay the incoming signal. Used as the low value of the modulated delay amount.

depth   How many milliseconds the LFO increases the delay by at the maximum.

dry   How much of the dry signal is added to the output.

feedback   How much of the flanged signal is fed back into the effect.

rate   The frequency of the LFO applied to the delay.

wet   How much of the flanged signal is added to the output.

Methods
channelCount ( )   Returns the number of channels this UGen has been configured to generate.

getLastValues ( )   Return the last values generated by this UGen. This will most often be used by sub-classes when pulling data from their inputs.

patch ( )   Send the output of this UGen to another UGen, UGenInput, or AudioOutput.

printInputs ( )   Prints all inputs connected to this UGen (for debugging)

sampleRate ( )   Returns the sample rate of this UGen.

setChannelCount ( )   Let this UGen know how many channels of audio you will be asking it for.

setSampleRate ( )   Set the sample rate for this UGen.

tick ( )   Generates one sample frame for this UGen.

unpatch ( )   Unpatch this UGen from an AudioOutput or other UGen.

Usage Web & Application
Related UGen