12 #include <mozzi_midi.h>
17 #include <tables/sin2048_int8.h>
41 aOsc.setTable(SIN2048_DATA);
42 aAmpEnv.setADLevels(255, 255);
43 aAmpEnv.setTimes(50, 300, 60000, 1000);
44 kResonantFreqEnv.setADLevels(255,100);
52 void noteOn(byte channel, byte pitch, byte velocity)
54 kResonantFreqEnv.noteOn();
57 aBaseCounter.setFreq(freq);
58 aResonanceFreqCounter.setFreq(freq);
67 void noteOff(byte channel, byte pitch, byte velocity)
70 kResonantFreqEnv.noteOff();
81 kResonantFreqEnv.setTimes(attack, decay, 60000, 1000);
82 kResonantFreqEnv.update();
84 float resonance_freq = freq + ((
float)freq * ((
float)kResonantFreqEnv.next()*PDM_SCALE));
85 aResonanceFreqCounter.setFreq(resonance_freq);
94 kResonantFreqEnv.update();
96 float resonance_freq = freq + ((
float)freq * ((
float)kResonantFreqEnv.next()*PDM_SCALE));
97 aResonanceFreqCounter.setFreq(resonance_freq);
104 static byte previous_base_counter;
105 byte base_counter = aBaseCounter.next()>>24;
108 if (base_counter<previous_base_counter) aResonanceFreqCounter.set(0);
109 previous_base_counter= base_counter;
112 unsigned int index = aResonanceFreqCounter.next()>>21;
115 byte amp_ramp = 255-base_counter;
118 return ((
long)aAmpEnv.next() * amp_ramp * aOsc.atIndex(index))>>16;
125 const float PDM_SCALE;
129 Phasor <MOZZI_AUDIO_RATE> aBaseCounter;
130 Phasor <MOZZI_AUDIO_RATE> aResonanceFreqCounter;
132 Oscil <SIN2048_NUM_CELLS, MOZZI_AUDIO_RATE> aOsc;