frac32 phase
frac32buffer.bipolar sine wave
frac32.u.map phase
objref Table containing the amplitudes (32bit)
objref Tuning table
class osc_cheapsaw_dual {
public:
void init() {}
void render(int32_t *pOut, int32_t amp1, int32_t freq1, int32_t phase1,
int32_t amp2, int32_t freq2, int32_t phase2) {
// out: pointer to s32 output buffer, adds values
// amp: s32 amplitude
amp1 = amp1 >> 4;
amp2 = amp2 >> 4;
int i;
for (i = 0; i < BUFSIZE; i++) {
int32_t out = *pOut;
phase1 += freq1;
out = __SMMLA(phase1, amp1, out);
phase2 += freq2;
out = __SMMLA(phase2, amp2, out);
*pOut = out;
pOut++;
}
}
};
static const int n_octaves = 8;
class chroma {
int phase;
public:
osc_cheapsaw_dual octaves[n_octaves / 2];
void init() {
phase = 0;
int i;
for (i = 0; i < n_octaves; i++) {
octaves[i].init();
}
};
void render(int freq, int32_t *pOut, int32_t *amp, uint32_t x) {
phase += freq << 4;
uint32_t p = phase;
uint32_t f = freq;
int i;
for (i = 0; i < n_octaves / 2; i++) {
octaves[i].render(pOut, amp[0], f, p + x, amp[12], f << 1, (p << 1) + x);
amp += 24;
p = p << 2;
f = f << 2;
}
}
};
chroma chromas[12];
int i;
for (i = 0; i < 12; i++) {
chromas[i].init();
}
int i;
for (i = 0; i < BUFSIZE; i++) {
outlet_wave[i] = 0;
}
for (i = 0; i < 12; i++) {
chromas[i].render(attr_tuning.array[i] >> 5, &outlet_wave[0],
&attr_amplitudes.array[i],
(param_phase + inlet_phase) << 5);
}