I made a group of oscillators with the code found below ( I also attached the sketch mozzi_trial3.ino). I am trying to use a low pass filter on the group of oscillators called "out." In updateControl(), when I replace the last line with the second to last line (replace return (int) out; with return (int) lpf.next(out); I don't hear the oscillators being passed through a low pass filter, but rather a series of clicks on top of the unfiltered sound. I've attached two (my apologies: due to weird circumstances I had to record the audio with a field recorder listening to laptop speakers) audio clips showing what I hear, so you don't have to build the circuit. The circuit is simply the arduino pin9 running to a headphone jack's hot pin and the jack's pin grounded to the arduino. Thank you in advance for any assistance/advice! It's much appreciated. -Nick
//drone in F minor
#include <MozziGuts.h>
#include <Oscil.h>
#include <tables/sin2048_int8.h>
#include <LowPassFilter.h>
#include <ReverbTank.h>
#define CONTROL_RATE 128
Oscil<2048, AUDIO_RATE> aSin1(SIN2048_DATA);
Oscil<2048, AUDIO_RATE> aSin2(SIN2048_DATA);
Oscil<2048, AUDIO_RATE> aSin3(SIN2048_DATA);
Oscil<2048, AUDIO_RATE> aSin4(SIN2048_DATA);
Oscil<2048, AUDIO_RATE> aSin5(SIN2048_DATA);
Oscil<2048, AUDIO_RATE> aSin6(SIN2048_DATA);
Oscil<2048, AUDIO_RATE> aSin7(SIN2048_DATA);
Oscil<2048, AUDIO_RATE> aSin0(SIN2048_DATA);
Oscil<2048, CONTROL_RATE> kVol1(SIN2048_DATA);
Oscil<2048, CONTROL_RATE> kVol2(SIN2048_DATA);
Oscil<2048, CONTROL_RATE> kVol3(SIN2048_DATA);
Oscil<2048, CONTROL_RATE> kVol4(SIN2048_DATA);
Oscil<2048, CONTROL_RATE> kVol5(SIN2048_DATA);
Oscil<2048, CONTROL_RATE> kVol6(SIN2048_DATA);
Oscil<2048, CONTROL_RATE> kVol7(SIN2048_DATA);
Oscil<2048, CONTROL_RATE> kVol0(SIN2048_DATA);
Oscil<2048, CONTROL_RATE> kFilterMod(SIN2048_DATA);
char v1,v2,v3,v4,v5,v6,v7,v0;
LowPassFilter lpf;
void setup() {
lpf.setResonance(1);
byte cutoff_freq = 80;
lpf.setCutoffFreq(cutoff_freq);
aSin1.setFreq(174.61f); // F3
aSin2.setFreq(196.0f); // G3
aSin3.setFreq(207.65f); // Ab3
aSin4.setFreq(233.08f); // Bb3
aSin5.setFreq(261.63f); // C4
aSin6.setFreq(277.18f); // Db
aSin7.setFreq(311.13f); // Eb
aSin0.setFreq(349.23f); // F4
kVol1.setFreq(4.43f);
kVol2.setFreq(0.0245f);
kVol3.setFreq(0.019f);
kVol4.setFreq(0.07f);
kVol5.setFreq(0.047f);
kVol6.setFreq(0.031f);
kVol7.setFreq(0.0717f);
kVol0.setFreq(0.041f);
v1=v2=v3=v4=v5=v6=v7=v0=127;
startMozzi(CONTROL_RATE);
}
void updateControl(){
v1 = kVol1.next()>>1; // going at a higher freq, this creates zipper noise, so reduce the gain
v2 = kVol2.next();
v3 = kVol3.next();
v4 = kVol4.next();
v5 = kVol5.next();
v6 = kVol6.next();
v7 = kVol7.next();
v0 = kVol0.next();
}
int updateAudio(){
long out =
(long)
aSin1.next()*v1 +
aSin2.next()*v2 +
aSin3.next()*v3 +
aSin4.next()*v4 +
aSin5.next()*v5 +
aSin6.next()*v6 +
aSin7.next()*v7 +
aSin0.next()*v0;
out >>= 9;
//return (int) lpf.next(out);
return (int) out;
}
void loop() {
audioHook();
}