12 #include <mozzi_midi.h>
17 #include <tables/sin2048_int8.h>
43 aAmpEnv.
setTimes(50, 300, 60000, 1000);
52 void noteOn(
byte channel,
byte pitch,
byte velocity)
58 aResonanceFreqCounter.
setFreq(freq);
67 void noteOff(
byte channel,
byte pitch,
byte velocity)
81 kResonantFreqEnv.
setTimes(attack, decay, 60000, 1000);
84 float resonance_freq = freq + ((float)freq * ((
float)kResonantFreqEnv.
next()*PDM_SCALE));
85 aResonanceFreqCounter.
setFreq(resonance_freq);
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;
void update()
Updates the internal controls of the ADSR.
void noteOff()
Start the release phase of the ADSR.
void setADLevels(byte attack, byte decay)
Set the attack and decay levels of the ADSR.
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.
unsigned char next()
Advances one audio step along the ADSR and returns the level.
void noteOn(bool reset=false)
Start the attack phase of the ADSR.
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 noteOff(byte channel, byte pitch, byte velocity)
Stop a note in response to midi input.
void setPDEnv(int attack, int decay)
Set the resonant filter sweep parameters.
void noteOn(byte channel, byte pitch, byte velocity)
Play a note in response to midi input.
int next()
Produce the audio output.
void update()
Update the filter sweep.
uint32_t next()
Increments one step along the phase.
void set(uint32_t value)
Set the current value of the phasor.
void setFreq(int frequency)
Set the Phasor frequency with an unsigned int.
float mtof(float midival)
Converts midi note number to frequency.