Skip to content

Commit 0485819

Browse files
committed
Fix broken AudioEffects
1 parent 5b6c9ce commit 0485819

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

examples/examples-audiokit/player-sd-audiokit/player-sd-audiokit.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const char* ext="mp3";
1919
int speedMz = 10;
2020
AudioSourceSdFat source(startFilePath, ext, PIN_AUDIO_KIT_SD_CARD_CS, speedMz);
2121
AudioKitStream kit;
22-
MP3DecoderHelix decoder; // or MP3DecoderMAD
22+
MP3DecoderHelix decoder; // or change to MP3DecoderMAD
2323
AudioPlayer player(source, kit, decoder);
2424

2525
void next(bool, int, void*) {

examples/examples-audiokit/streams-synthbasic2-audiokit/streams-synthbasic2-audiokit.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
AudioKitStream kit;
1313
SineWaveGenerator<int16_t> sine;
14-
AudioEffects effects(sine);
14+
AudioEffects<SineWaveGenerator<int16_t>> effects(sine);
1515
ADSRGain adsr(0.0001,0.0001, 0.9 , 0.0002);
1616
GeneratedSoundStream<int16_t> in(effects);
1717
StreamCopy copier(kit, in);

examples/examples-audiokit/streams-synthbasic3-audiokit/streams-synthbasic3-audiokit.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SynthAction : public MidiAction {
3030

3131
MidiBleServer ble("MidiServer", &action);
3232
AudioKitStream kit;
33-
AudioEffects effects(sine);
33+
AudioEffects<SineWaveGenerator<int16_t>> effects(sine);
3434
GeneratedSoundStream<int16_t> in(effects);
3535
StreamCopy copier(kit, in);
3636

examples/examples-webserver/streams-effect-webserver_wav/streams-effect-webserver_wav.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ float tremoloDepth = 0.5;
2727

2828
// Audio
2929
SineWaveGenerator<int16_t> sine;
30-
AudioEffects effects(sine);
30+
AudioEffects<SineWaveGenerator<int16_t>> effects(sine);
3131
GeneratedSoundStream<int16_t> in(effects);
3232

3333
// Audio Format

src/AudioEffects/AudioEffects.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,22 @@ namespace audio_tools {
1414
* @brief AudioEffects: the template class describes the input audio to which the effects are applied:
1515
* e.g. SineWaveGenerator, SquareWaveGenerator, GeneratorFromStream etc.
1616
* We support only one channel of int16_t data!
17+
*
18+
* We subclass the AudioEffects from GeneratorT so that we can use this class with the GeneratedSoundStream
19+
* class to output the audio.
20+
*
1721
* @author Phil Schatzmann
1822
* @copyright GPLv3
1923
*/
2024

25+
2126
template <class GeneratorT>
22-
class AudioEffects {
27+
class AudioEffects : public GeneratorT {
2328
public:
29+
/// Default constructor
2430
AudioEffects() = default;
2531

32+
/// Copy constructor
2633
AudioEffects(AudioEffects &copy) {
2734
LOGI(LOG_METHOD);
2835
// create a copy of the source and all effects
@@ -33,15 +40,21 @@ class AudioEffects {
3340
LOGI("Number of effects %d -> %d", copy.size(), this->size());
3441
}
3542

43+
/// Constructor which is assigning a generator
44+
AudioEffects(GeneratorT &generator) {
45+
setInput(generator);
46+
}
47+
48+
/// Destructor
3649
~AudioEffects(){
3750
LOGD(LOG_METHOD);
3851
for (int j=0;j<effects.size();j++){
3952
delete effects[j];
4053
}
4154
}
42-
55+
4356
/// Defines the input source for the raw guitar input
44-
void setInput(SoundGenerator<int16_t> &in){
57+
void setInput(GeneratorT &in){
4558
LOGD(LOG_METHOD);
4659
generator_obj = in;
4760
}
@@ -60,7 +73,7 @@ class AudioEffects {
6073
}
6174

6275
/// provides the resulting sample
63-
virtual effect_t readSample() {
76+
effect_t readSample() {
6477
effect_t input = generator_obj.readSample();
6578
int size = effects.size();
6679
for (int j=0; j<size; j++){
@@ -70,7 +83,7 @@ class AudioEffects {
7083
}
7184

7285
/// deletes all defined effects
73-
virtual void clear() {
86+
void clear() {
7487
LOGD(LOG_METHOD);
7588
effects.clear();
7689
}
@@ -110,4 +123,6 @@ class AudioEffects {
110123
};
111124

112125

126+
127+
113128
} // namespace

0 commit comments

Comments
 (0)