30 template<uint16_t NUM_TABLE_CELLS, uint16_t UPDATE_RATE, byte N_OSCIL>
38 template<
class... T>
MetaOscil(
Oscil<NUM_TABLE_CELLS, UPDATE_RATE>* first, T*... elements):oscillators{first, elements...} {
39 current_osc=oscillators[0];};
57 template<
typename ... T >
void setOscils(
Oscil<NUM_TABLE_CELLS, UPDATE_RATE>* first,T... elements)
59 oscillators[current_rank]=first;
60 if (current_rank == 0) current_osc=oscillators[0];
62 setOscils(elements...);
73 cutoff_freqs[current_rank]=first;
75 setCutoffFreqs(elements...);
79 void setCutoffFreqs() {};
86 cutoff_freqs[rank] = freq;
98 void setTable(
const int8_t * TABLE_NAME, byte rank) {oscillators[rank]->setTable(TABLE_NAME);}
103 void setPhase(
unsigned int phase) {current_osc->setPhase(phase);}
131 void setFreq(
int frequency,
bool apply =
true)
133 if (frequency < cutoff_freqs[0])
135 oscillators[0]->setPhaseFractional(current_osc->getPhaseFractional());
136 current_osc = oscillators[0];
137 current_osc->setFreq(frequency);
140 else if (frequency > cutoff_freqs[N_OSCIL-1])
142 oscillators[N_OSCIL-1]->setPhaseFractional(current_osc->getPhaseFractional());
143 current_osc = oscillators[N_OSCIL-1];
144 current_osc->setFreq(frequency);
148 byte low_point = 0, high_point = N_OSCIL-1, mid_point = (N_OSCIL-1)>>1;
149 while(low_point != high_point)
151 if (frequency > cutoff_freqs[mid_point]) low_point = mid_point+1;
152 else if (frequency < cutoff_freqs[mid_point]) high_point = mid_point;
157 mid_point = (low_point + high_point)>>1;
159 oscillators[mid_point]->setPhaseFractional(current_osc->getPhaseFractional());
160 current_osc = oscillators[mid_point];
161 if (apply) current_osc->setFreq(frequency);
172 setFreq((
int) frequency,
false);
173 current_osc->setFreq(frequency);
182 setFreq((
int) (frequency>>8),
false);
183 current_osc->setFreq_Q24n8(frequency);
192 setFreq((
int) (frequency>>16),
false);
193 current_osc->setFreq_Q16n16(frequency);
210 unsigned long phaseIncFromFreq(
int frequency) {
return current_osc->phaseIncFromFreq(frequency);}
216 void setPhaseInc(
unsigned long phaseinc_fractional) {current_osc->setPhaseInc(phaseinc_fractional);}
221 Oscil<NUM_TABLE_CELLS, UPDATE_RATE> * oscillators[N_OSCIL];
222 Oscil<NUM_TABLE_CELLS, UPDATE_RATE> * current_osc =
NULL;
223 int cutoff_freqs[N_OSCIL];
224 byte current_rank = 0;