-
-
Notifications
You must be signed in to change notification settings - Fork 282
Audio Effects
Phil Schatzmann edited this page Mar 8, 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:
#include "AudioTools.h"
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);
...
}
We might want to apply effects on an input stream of audio data that we e.g. get from a microphone. We can do this by converting the input stream into a Generator with the help of the GeneratorFromStream class.
You need to make sure that the source stream contains one audio channel only!