Hi, I am working on an audio project using the Teensy 3.6. The audio portion of the project consists of reading a wav file using the 3.6's built-in SD card reader, adding some effects processing, and playing it via the built-in dac outputs. Additionally, I would like the brightness of some LED lighting to follow the amplitude of the sound, envelope follower style. To accomplish this, I was trying to use AudioEffectRectifier along with AudioFilterBiquad (set as a lowpass) to make a simple envelope follower, which I would then convert to a value readable by the main loop using AudioAnalyzePeak.
I was getting some issues where the audio sounded like it was experiencing dropouts or sample rate underruns, where my output got really crackly and distorted sounding. In the process of debugging this I tracked it down to the point where AudioEffectRectifier is connected to another object via a patch cord. The rest of the much more processing intensive effects objects worked fine, but as soon as rectifier effect was added, the output started to distort heavily. Looking at the source code this doesn't make any sense, the update process for AudioEffectRectifier is pretty minimal compared to other objects I was using like AudioEffectGranular and AudioEffectFreeverb. It seems like something else is going on here beyond a simple cpu overload.
I've made an example patch that strips this issue down to its most basic elements so that it is easier to test and recreate. In the example patch, as soon as the AudioEffectRectifier patchcord is uncommented, the output will begin to distort. For reference, one can also uncomment the a patchcord connecting to the Freeverb object, and hear how this produces no difference in the output.
Can anyone explain why AudioEffectRectifier is behaving in this way, and what I can do to fix / work around this issue?
This project has a deadline in about 3 weeks, so if anyone can suggest an alternative method of getting an envelope follower signal that would be much appreciated.
Here is the example code demonstrating this issue:
I was getting some issues where the audio sounded like it was experiencing dropouts or sample rate underruns, where my output got really crackly and distorted sounding. In the process of debugging this I tracked it down to the point where AudioEffectRectifier is connected to another object via a patch cord. The rest of the much more processing intensive effects objects worked fine, but as soon as rectifier effect was added, the output started to distort heavily. Looking at the source code this doesn't make any sense, the update process for AudioEffectRectifier is pretty minimal compared to other objects I was using like AudioEffectGranular and AudioEffectFreeverb. It seems like something else is going on here beyond a simple cpu overload.
I've made an example patch that strips this issue down to its most basic elements so that it is easier to test and recreate. In the example patch, as soon as the AudioEffectRectifier patchcord is uncommented, the output will begin to distort. For reference, one can also uncomment the a patchcord connecting to the Freeverb object, and hear how this produces no difference in the output.
Can anyone explain why AudioEffectRectifier is behaving in this way, and what I can do to fix / work around this issue?
This project has a deadline in about 3 weeks, so if anyone can suggest an alternative method of getting an envelope follower signal that would be much appreciated.
Here is the example code demonstrating this issue:
Code:
#include <Audio.h>
#include "SD.h"
AudioPlaySdWav sample;
AudioEffectRectifier rect;
AudioOutputAnalogStereo dacs1;
AudioEffectFreeverb verb;
AudioConnection patchCord1(sample, 0, dacs1, 0);
AudioConnection patchCord2(sample, 0, dacs1, 1);
//connecting sample output to rect causes dropouts
//AudioConnection patchCord3(sample, 0, rect, 0);
//adding much more processing heavy effect of reverb sounds fine
//AudioConnection patchCord3(sample, 0, verb, 0);
void setup() {
Serial.begin(9600);
delay(3000);
Serial.println("starting");
if (!(SD.begin(BUILTIN_SDCARD))) {
// stop here, but print a message repetitively
while (1) {
delay(500);
}
}
AudioMemory(100);
sample.begin();
verb.roomsize(1);
verb.damping(0.5);
dacs1.analogReference(INTERNAL);
}
void loop() {
if(!sample.isPlaying()){
sample.play("TRAX.WAV");
delay(100);
}
}