Skip to content

Adding Volume Control and Filters

Phil Schatzmann edited this page Feb 23, 2022 · 7 revisions

In the following example we use I2S as final output

I2SStream i2s;

If we want control the volume, so we can wrap it in a VolumeStream

VolumeStream volume(i2s); // volume support

The mp3 recordings have usually some silence in the beginning or at the end. We can try to remove this with the help of a converter. So we can wrap further to apply some additional converter:

SilenceRemovalConverter<int16_t> silence(8,2); // suppress silence
ConvertedStream<int16_t, SilenceRemovalConverter<int16_t>> out(volume,silence);

This will remove all samples with silence from the output. The remainder is as known. We just need to use the last wrapped Stream as output:

MP3DecoderHelix mp3;
AudioDictionary dictionary(ExampleAudioDictionaryValues);
NumberUnitToText utt;
TextToSpeech tts(utt, out, mp3, dictionary);

To summarize this implements the following output chain

   mp3 (output) ->  ConvertedStream with SilenceRemovalConverter -> VolumeStream -> I2S

The full source code can be found in the examples

Clone this wiki locally