|
|
@ -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; |
|
|
|
int16_t v; |
|
|
|
float x, l, r, od = overdrive; |
|
|
|
float x, l, r, od = overdrive; |
|
|
|
int32_t i; |
|
|
|
int32_t i; |
|
|
|
int16_t frame; |
|
|
|
int16_t frame; |
|
|
|
|
|
|
|
|
|
|
|
for (frame = 0; frame < sampleFrames; frame++) |
|
|
|
for (frame = 0; frame < AUDIO_BLOCK_SAMPLES; frame++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
VOICE *V = voice; |
|
|
|
VOICE *V = voice; |
|
|
|
l = r = 0.0f; |
|
|
|
l = r = 0.0f; |
|
|
@ -348,64 +348,41 @@ void mdaEPiano::process(int16_t *outputs_r, int16_t *outputs_l, int32_t sampleFr |
|
|
|
V->frac += V->delta; //integer-based linear interpolation
|
|
|
|
V->frac += V->delta; //integer-based linear interpolation
|
|
|
|
V->pos += V->frac >> 16; |
|
|
|
V->pos += V->frac >> 16; |
|
|
|
V->frac &= 0xFFFF; |
|
|
|
V->frac &= 0xFFFF; |
|
|
|
if (V->pos > V->end) V->pos -= V->loop; |
|
|
|
if (V->pos > V->end) |
|
|
|
//i = waves[V->pos];
|
|
|
|
V->pos -= V->loop; |
|
|
|
//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;
|
|
|
|
|
|
|
|
i = waves[V->pos] + ((V->frac * (waves[V->pos + 1] - waves[V->pos])) >> 16); |
|
|
|
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
|
|
|
|
V->env = V->env * V->dec; //envelope
|
|
|
|
|
|
|
|
if (x > 0.0f) { |
|
|
|
//if(x>0.0f) { x -= od * x * x; if(x < -V->env) x = -V->env; } //+= 0.5f * x * x; } //overdrive
|
|
|
|
x -= od * x * x; //overdrive
|
|
|
|
|
|
|
|
if (x < -V->env) x = -V->env; |
|
|
|
//l += V->outl * x;
|
|
|
|
} |
|
|
|
//r += V->outr * x;
|
|
|
|
l += V->outl * x; |
|
|
|
|
|
|
|
r += V->outr * x; |
|
|
|
|
|
|
|
|
|
|
|
V++; |
|
|
|
V++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
tl += tfrq * (l - tl); //treble boost
|
|
|
|
tl += tfrq * (l - tl); //treble boost
|
|
|
|
tr += tfrq * (r - tr); |
|
|
|
tr += tfrq * (r - tr); |
|
|
|
r += treb * (r - tr); |
|
|
|
r += treb * (r - tr); |
|
|
|
l += treb * (l - tl); |
|
|
|
l += treb * (l - tl); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lfo0 += dlfo * lfo1; //LFO for tremolo and autopan
|
|
|
|
|
|
|
|
lfo1 -= dlfo * lfo0; |
|
|
|
|
|
|
|
l += l * lmod * lfo1; |
|
|
|
|
|
|
|
r += r * rmod * lfo1; //worth making all these local variables?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outputs_l[v] = int16_t(l * 0xFFFF) >> REDUCE_LOUDNESS; |
|
|
|
lfo0 += dlfo * lfo1; //LFO for tremolo and autopan
|
|
|
|
outputs_r[v] = int16_t(r * 0xFFFF) >> REDUCE_LOUDNESS; |
|
|
|
lfo1 -= dlfo * lfo0; |
|
|
|
*/ |
|
|
|
l += l * lmod * lfo1; |
|
|
|
|
|
|
|
r += r * rmod * lfo1; //worth making all these local variables?
|
|
|
|
|
|
|
|
|
|
|
|
outputs_l[v] = i >> REDUCE_LOUDNESS; |
|
|
|
outputs_l[frame] = static_cast<int16_t>(l) >> REDUCE_LOUDNESS; |
|
|
|
outputs_r[v] = i >> REDUCE_LOUDNESS; |
|
|
|
outputs_r[frame] = static_cast<int16_t>(r) >> 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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
if (fabs(tl) < 1.0e-10) tl = 0.0f; //anti-denormal
|
|
|
|
if (fabs(tl) < 1.0e-10) tl = 0.0f; //anti-denormal
|
|
|
|
if (fabs(tr) < 1.0e-10) tr = 0.0f; |
|
|
|
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 < 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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|