Matthew O'Connell
Member
I'm having an issue with a very basic low pass filter sketch on the Teensy 3.6.
The filter works great when the resonance is above ~2. But once I turn down the resonance and open up the cutoff of the filter I get a really loud static sound.
Basically the safe zone seems to be Resonance > 2, Cutoff set anywhere.
The danger zone is Resonance < 2, Cutoff > ~10000Hz.
Has anyone experienced this issue or know why this might happen? Do I need to attenuate the signal somehow before feeding it to the filter?
Here's a really basic sketch that I'm using and video of the issue. In the video, the left knob is the cutoff frequency, mapped from 0-22000Hz and the right knob is the resonance, mapped from .7 to 5.
Thanks so much for any help or ideas. I really appreciate it.
GUI Design:
Video of issue:
The filter works great when the resonance is above ~2. But once I turn down the resonance and open up the cutoff of the filter I get a really loud static sound.
Basically the safe zone seems to be Resonance > 2, Cutoff set anywhere.
The danger zone is Resonance < 2, Cutoff > ~10000Hz.
Has anyone experienced this issue or know why this might happen? Do I need to attenuate the signal somehow before feeding it to the filter?
Here's a really basic sketch that I'm using and video of the issue. In the video, the left knob is the cutoff frequency, mapped from 0-22000Hz and the right knob is the resonance, mapped from .7 to 5.
Thanks so much for any help or ideas. I really appreciate it.
GUI Design:
Video of issue:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
// GUItool: begin automatically generated code
AudioSynthWaveform voice1a; //xy=198.42857360839844,141.42858028411865
AudioSynthNoiseWhite voice1n; //xy=198.42857360839844,217.42858028411865
AudioSynthWaveform voice1b; //xy=199.42857360839844,178.42858028411865
AudioMixer4 voice1mix; //xy=347.42857360839844,163.42858028411865
AudioFilterStateVariable masterFilter; //xy=539.4285888671875,169.4285888671875
AudioOutputI2S i2s1; //xy=703.4285888671875,163.4285888671875
AudioConnection patchCord1(voice1a, 0, voice1mix, 0);
AudioConnection patchCord2(voice1n, 0, voice1mix, 2);
AudioConnection patchCord3(voice1b, 0, voice1mix, 1);
AudioConnection patchCord4(voice1mix, 0, masterFilter, 0);
AudioConnection patchCord5(masterFilter, 0, i2s1, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=692.4285888671875,117.4285888671875
// GUItool: end automatically generated code
void setup() {
AudioMemory(160);
Serial.begin(115200);
sgtl5000_1.enable();
sgtl5000_1.volume(.8);
}
void loop() {
voice1mix.gain(0,.33);
voice1mix.gain(1,.33);
voice1mix.gain(2,.33);
voice1a.begin(.5, 220, WAVEFORM_SQUARE);
voice1b.begin(.5, 440, WAVEFORM_SQUARE);
voice1n.amplitude(.1);
int knob1 = analogRead(A21);
int filterCutoffMapped = map(knob1, 0, 1023, 0, 22000);
masterFilter.frequency(filterCutoffMapped);
int knob2 = analogRead(A19);
float filterResonanceMapped = mapfloat(knob2, 0, 1023, .7, 5);
masterFilter.resonance(filterResonanceMapped);
}
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
Last edited: