|
|
|
@ -332,14 +332,14 @@ float mdaEPiano::getParameter(int32_t index) { |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
void mdaEPiano::process(int16_t *outputs_r, int16_t *outputs_l, int32_t sampleFrames) |
|
|
|
|
void mdaEPiano::process(int16_t *outputs_r, int16_t *outputs_l) |
|
|
|
|
{ |
|
|
|
|
int16_t v; |
|
|
|
|
float x, l, r, od = overdrive; |
|
|
|
|
int32_t i; |
|
|
|
|
int16_t frame; |
|
|
|
|
|
|
|
|
|
for (frame = 0; frame < sampleFrames; frame++) |
|
|
|
|
for (frame = 0; frame < AUDIO_BLOCK_SAMPLES; frame++) |
|
|
|
|
{ |
|
|
|
|
VOICE *V = voice; |
|
|
|
|
l = r = 0.0f; |
|
|
|
@ -348,25 +348,21 @@ void mdaEPiano::process(int16_t *outputs_r, int16_t *outputs_l, int32_t sampleFr |
|
|
|
|
V->frac += V->delta; //integer-based linear interpolation
|
|
|
|
|
V->pos += V->frac >> 16; |
|
|
|
|
V->frac &= 0xFFFF; |
|
|
|
|
if (V->pos > V->end) V->pos -= V->loop; |
|
|
|
|
//i = waves[V->pos];
|
|
|
|
|
//i = (i << 7) + (V->frac >> 9) * (waves[V->pos + 1] - i) + 0x40400000; //not working on intel mac !?!
|
|
|
|
|
//x = V->env * (*(float *)&i - 3.0f); //fast int->float
|
|
|
|
|
//x = V->env * (float)i / 32768.0f;
|
|
|
|
|
if (V->pos > V->end) |
|
|
|
|
V->pos -= V->loop; |
|
|
|
|
i = waves[V->pos] + ((V->frac * (waves[V->pos + 1] - waves[V->pos])) >> 16); |
|
|
|
|
//x = V->env * (float)i / 32768.0f;
|
|
|
|
|
|
|
|
|
|
x = V->env * static_cast<float>(i) / 32768.0f; |
|
|
|
|
V->env = V->env * V->dec; //envelope
|
|
|
|
|
|
|
|
|
|
//if(x>0.0f) { x -= od * x * x; if(x < -V->env) x = -V->env; } //+= 0.5f * x * x; } //overdrive
|
|
|
|
|
|
|
|
|
|
//l += V->outl * x;
|
|
|
|
|
//r += V->outr * x;
|
|
|
|
|
if (x > 0.0f) { |
|
|
|
|
x -= od * x * x; //overdrive
|
|
|
|
|
if (x < -V->env) x = -V->env; |
|
|
|
|
} |
|
|
|
|
l += V->outl * x; |
|
|
|
|
r += V->outr * x; |
|
|
|
|
|
|
|
|
|
V++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
tl += tfrq * (l - tl); //treble boost
|
|
|
|
|
tr += tfrq * (r - tr); |
|
|
|
|
r += treb * (r - tr); |
|
|
|
@ -377,35 +373,16 @@ void mdaEPiano::process(int16_t *outputs_r, int16_t *outputs_l, int32_t sampleFr |
|
|
|
|
l += l * lmod * lfo1; |
|
|
|
|
r += r * rmod * lfo1; //worth making all these local variables?
|
|
|
|
|
|
|
|
|
|
outputs_l[v] = int16_t(l * 0xFFFF) >> REDUCE_LOUDNESS; |
|
|
|
|
outputs_r[v] = int16_t(r * 0xFFFF) >> REDUCE_LOUDNESS; |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
outputs_l[v] = i >> REDUCE_LOUDNESS; |
|
|
|
|
outputs_r[v] = i >> REDUCE_LOUDNESS; |
|
|
|
|
} |
|
|
|
|
/*
|
|
|
|
|
if (frame < sampleFrames) |
|
|
|
|
{ |
|
|
|
|
if (activevoices == 0 && programs[curProgram].param[4] > 0.5f) |
|
|
|
|
{ |
|
|
|
|
lfo0 = -0.7071f; //reset LFO phase - good idea?
|
|
|
|
|
lfo1 = 0.7071f; |
|
|
|
|
} |
|
|
|
|
outputs_l[frame] = static_cast<int16_t>(l) >> REDUCE_LOUDNESS; |
|
|
|
|
outputs_r[frame] = static_cast<int16_t>(r) >> REDUCE_LOUDNESS; |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
if (fabs(tl) < 1.0e-10) tl = 0.0f; //anti-denormal
|
|
|
|
|
if (fabs(tr) < 1.0e-10) tr = 0.0f; |
|
|
|
|
|
|
|
|
|
for (v = 0; v < activevoices; v++) if (voice[v].env < SILENCE) voice[v] = voice[--activevoices]; |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
for (v = 0; v < sampleFrames; v++) |
|
|
|
|
{ |
|
|
|
|
outputs_r[v] = int16_t(o0[v] * 0xFFFF) >> REDUCE_LOUDNESS; |
|
|
|
|
outputs_l[v] = int16_t(o1[v] * 0xFFFF) >> REDUCE_LOUDNESS; |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
for (v = 0; v < activevoices; v++) |
|
|
|
|
if (voice[v].env < SILENCE) |
|
|
|
|
voice[v] = voice[--activevoices]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
|