21 template <
unsigned int CONTROL_UPDATE_RATE>
30 MICROS_PER_CONTROL_STEP(1000000/CONTROL_UPDATE_RATE)
40 control_steps_per_portamento = convertMsecToControlSteps(milliseconds);
48 target_freq = Q16n16_mtof(Q8n0_to_Q16n16(note));
49 aPortamentoLine.set(target_freq, control_steps_per_portamento);
50 countdown = control_steps_per_portamento;
60 aPortamentoLine.set(target_freq, control_steps_per_portamento);
61 countdown = control_steps_per_portamento;
73 if (portamento_on==
true){
76 aPortamentoLine.set(target_freq, target_freq, control_steps_per_portamento);
80 return aPortamentoLine.next();
86 int control_steps_per_portamento;
89 const unsigned int MICROS_PER_CONTROL_STEP;
95 static const unsigned int convertMsecToControlSteps(
unsigned int msec){
96 return (uint16_t) (((uint32_t)msec*CONTROL_UPDATE_RATE)>>10);
Q16n16 Q16n16_mtof(Q16n16 midival)
Converts midi note number to frequency with speed and accuracy.
A simple portamento (pitch slide from one note to the next) effect, useful for note-based application...
void setTime(unsigned int milliseconds)
Set how long it will take to slide from note to note, in milliseconds.
void start(Q16n16 note)
Call this at note-on, it initialises the portamento.
For linear changes with a minimum of calculation at each step.
uint32_t Q16n16
unsigned fractional number using 16 integer bits and 16 fractional bits, represents 0 to 65535...
Q16n16 next()
Use this in updateControl() to provide a frequency to the oscillator it's controlling.