14 #include <mozzi_midi.h> 19 #include <tables/sin2048_int8.h> 43 aOsc.setTable(SIN2048_DATA);
44 aAmpEnv.setADLevels(255, 255);
45 aAmpEnv.setTimes(50, 300, 60000, 1000);
46 kResonantFreqEnv.setADLevels(255,100);
54 void noteOn(byte channel, byte pitch, byte velocity)
56 kResonantFreqEnv.noteOn();
59 aBaseCounter.setFreq(freq);
60 aResonanceFreqCounter.setFreq(freq);
69 void noteOff(byte channel, byte pitch, byte velocity)
72 kResonantFreqEnv.noteOff();
83 kResonantFreqEnv.setTimes(attack, decay, 60000, 1000);
84 kResonantFreqEnv.update();
86 float resonance_freq = freq + ((
float)freq * ((
float)kResonantFreqEnv.next()*PDM_SCALE));
87 aResonanceFreqCounter.setFreq(resonance_freq);
96 kResonantFreqEnv.update();
98 float resonance_freq = freq + ((
float)freq * ((
float)kResonantFreqEnv.next()*PDM_SCALE));
99 aResonanceFreqCounter.setFreq(resonance_freq);
106 static byte previous_base_counter;
107 byte base_counter = aBaseCounter.next()>>24;
110 if (base_counter<previous_base_counter) aResonanceFreqCounter.set(0);
111 previous_base_counter= base_counter;
114 unsigned int index = aResonanceFreqCounter.next()>>21;
117 byte amp_ramp = 255-base_counter;
120 return ((
long)aAmpEnv.next() * amp_ramp * aOsc.atIndex(index))>>16;
127 const float PDM_SCALE;
136 ADSR <CONTROL_RATE, CONTROL_RATE> kResonantFreqEnv;
int next()
Produce the audio output.
Oscil plays a wavetable, cycling through the table to generate an audio or control signal...
#define AUDIO_RATE
Holds the audio rate setting.
void update()
Update the filter sweep.
PDResonant is a simple midi instrument using Phase distortion used to simulate resonant filter...
void noteOn(byte channel, byte pitch, byte velocity)
Play a note in response to midi input.
Phasor repeatedly generates a high resolution ramp at a variable frequency.
void setPDEnv(int attack, int decay)
Set the resonant filter sweep parameters.
void noteOff(byte channel, byte pitch, byte velocity)
Stop a note in response to midi input.