I was never quite happy with my old implementation of the AudioEffects class because it was not very intuitive with the required type parameters and I thought it is about time to improve.
So I finally managed to provide a proper Stream implementation that works like many other converting Streams, so that we can now apply the effects both on the input and the output side:

Effects on the Input Side

We just provide an input stream from which the audio data will be read to the AudioEffectStream constructor

SineWaveGenerator<int16_t> sine;
GeneratedSoundStream<int16_t> stream(sine);            
AudioEffectStream effects(stream);
I2SStream out;
StreamCopy copy(out, effects);

We create a stream that generates a sine wave and apply the effects. Then the result is copied to the I2S output.

Effects on the Output Side

We just provide the final output Stream/Print to which the audio data will be written, after applying the effects to the AudioEffectStream constructor:

SineWaveGenerator<int16_t> sine;
GeneratedSoundStream<int16_t> stream(sine);            
I2SStream out;
AudioEffectStream effects(out);
StreamCopy copy(effects, stream);

In this case we copy the sine wave data to the effects and after applying the effects the output is passed to the I2S output.

You can easily replace the generated sound with any other sound source.
The complete documentation can be found in the Wiki

You can also listen to some effects using the Jupyter nbviewer


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *