14 #include <mozzi_midi.h>
19 #include <tables/sin2048_int8.h>
45 aAmpEnv.
setTimes(50, 300, 60000, 1000);
54 void noteOn(byte channel, byte pitch, byte velocity)
60 aResonanceFreqCounter.
setFreq(freq);
69 void noteOff(byte channel, byte pitch, byte velocity)
83 kResonantFreqEnv.
setTimes(attack, decay, 60000, 1000);
86 float resonance_freq = freq + ((float)freq * ((
float)kResonantFreqEnv.
next()*PDM_SCALE));
87 aResonanceFreqCounter.
setFreq(resonance_freq);
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;
unsigned char next()
Advances one audio step along the ADSR and returns the level.
void setFreq(int frequency)
Set the Phasor frequency with an unsigned int.
int next()
Produce the audio output.
float mtof(float midival)
Converts midi note number to frequency.
void setTimes(unsigned int attack_ms, unsigned int decay_ms, unsigned int sustain_ms, unsigned int release_ms)
Set the attack, decay and release times of the ADSR in milliseconds.
void noteOff()
Start the release phase of the ADSR.
void update()
Update the filter sweep.
void setTable(const int8_t *TABLE_NAME)
Change the sound table which will be played by the Oscil.
int8_t atIndex(unsigned int index)
Returns the sample at the given table index.
PDResonant is a simple midi instrument using Phase distortion used to simulate resonant filter...
void set(unsigned long value)
Set the current value of the phasor.
void noteOn(byte channel, byte pitch, byte velocity)
Play a note in response to midi input.
unsigned long next()
Increments one step along the phase.
void update()
Updates the internal controls of the ADSR.
void setADLevels(byte attack, byte decay)
Set the attack and decay levels of the ADSR.
void noteOn()
Start the attack phase of the ADSR.
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.