Skip to content

Audio Effects

Phil Schatzmann edited this page Feb 6, 2022 · 27 revisions

AudioEffects is the starting class to manage different type of audio effects (Distortion, Boost, Chorus etc). In the constructor of the AudioEffects class we pass the input to which we apply the effects. Finally we can use the GeneratedSoundStream class to convert the AudioEffects as an input stream source. Here is an example how to set up the different objects:

SineWaveGenerator<int16_t> sine;
AudioEffects<SineWaveGenerator<int16_t>> effects(sine);
GeneratedSoundStream<int16_t> in(effects); 
I2SStream out;
StreamCopy copier(out, in); 

In the setup() we then assign one or multiple Effect implementations.

ADSRGain adsr(0.0001,0.0001, 0.9 , 0.0002);

void setup() {
...
  // setup effects
  effects.addEffect(adsr);

  // Setup output
  auto cfg = i2s.defaultConfig(TX_MODE);
  i2s.begin(cfg);

  // Setup sound generation based on AudioKit settins
  sine.begin(cfg, 0);
  in.begin(cfg);
...
}

Apply Effects on Input Stream

We might want to apply effects on an input stream of audio data. We can do this by converting the input stream into a Generator with the help of the GeneratorFromStream class.

Clone this wiki locally