28 template<uint16_t NUM_TABLE_CELLS, uint16_t UPDATE_RATE, byte N_OSCIL>
55 template<
typename ... T >
void setOscils(
Oscil<NUM_TABLE_CELLS, UPDATE_RATE>* first,T... elements)
57 oscillators[current_rank]=first;
58 if (current_rank == 0) current_osc=oscillators[0];
60 setOscils(elements...);
71 cutoff_freqs[current_rank]=first;
73 setCutoffFreqs(elements...);
77 void setCutoffFreqs() {};
84 cutoff_freqs[rank] = freq;
96 void setTable(
const int8_t * TABLE_NAME, byte rank) {oscillators[rank]->setTable(TABLE_NAME);}
101 void setPhase(
unsigned int phase) {current_osc->setPhase(phase);}
129 void setFreq(
int frequency,
bool apply =
true)
131 if (frequency < cutoff_freqs[0])
133 oscillators[0]->setPhaseFractional(current_osc->getPhaseFractional());
134 current_osc = oscillators[0];
135 current_osc->setFreq(frequency);
138 else if (frequency > cutoff_freqs[N_OSCIL-1])
140 oscillators[N_OSCIL-1]->setPhaseFractional(current_osc->getPhaseFractional());
141 current_osc = oscillators[N_OSCIL-1];
142 current_osc->setFreq(frequency);
146 byte low_point = 0, high_point = N_OSCIL-1, mid_point = (N_OSCIL-1)>>1;
147 while(low_point != high_point)
149 if (frequency > cutoff_freqs[mid_point]) low_point = mid_point+1;
150 else if (frequency < cutoff_freqs[mid_point]) high_point = mid_point;
155 mid_point = (low_point + high_point)>>1;
157 oscillators[mid_point]->setPhaseFractional(current_osc->getPhaseFractional());
158 current_osc = oscillators[mid_point];
159 if (apply) current_osc->setFreq(frequency);
170 setFreq((
int) frequency,
false);
171 current_osc->setFreq(frequency);
180 setFreq((
int) (frequency>>8),
false);
181 current_osc->setFreq_Q24n8(frequency);
190 setFreq((
int) (frequency>>16),
false);
191 current_osc->setFreq_Q16n16(frequency);
208 unsigned long phaseIncFromFreq(
int frequency) {
return current_osc->phaseIncFromFreq(frequency);}
214 void setPhaseInc(
unsigned long phaseinc_fractional) {current_osc->setPhaseInc(phaseinc_fractional);}
219 Oscil<NUM_TABLE_CELLS, UPDATE_RATE> * oscillators[N_OSCIL];
220 Oscil<NUM_TABLE_CELLS, UPDATE_RATE> * current_osc =
NULL;
221 int cutoff_freqs[N_OSCIL];
222 byte current_rank = 0;
Oscil plays a wavetable, cycling through the table to generate an audio or control signal...
uint32_t Q24n8
unsigned fractional number using 24 integer bits and 8 fractional bits, represents 0 to 16777215 ...
uint32_t Q16n16
unsigned fractional number using 16 integer bits and 16 fractional bits, represents 0 to 65535...