|
|
@ -200,7 +200,9 @@ void mdaEPiano::fillpatch(int32_t p, char *name, float p0, float p1, float p2, f |
|
|
|
programs[p].param[10] = p10; programs[p].param[11] = p11; |
|
|
|
programs[p].param[10] = p10; programs[p].param[11] = p11; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
float mdaEPiano::getParameter(int32_t index) { return programs[curProgram].param[index]; } |
|
|
|
float mdaEPiano::getParameter(int32_t index) { |
|
|
|
|
|
|
|
return programs[curProgram].param[index]; |
|
|
|
|
|
|
|
} |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
void mdaEPiano::setProgramName(char *name) { strcpy(programs[curProgram].name, name); } |
|
|
|
void mdaEPiano::setProgramName(char *name) { strcpy(programs[curProgram].name, name); } |
|
|
|
void mdaEPiano::getProgramName(char *name) { strcpy(name, programs[curProgram].name); } |
|
|
|
void mdaEPiano::getProgramName(char *name) { strcpy(name, programs[curProgram].name); } |
|
|
@ -355,83 +357,15 @@ void mdaEPiano::process(int16_t **outputs_r, int16_t **outputs_l, int32_t sample |
|
|
|
if (V->pos > V->end) V->pos -= V->loop; |
|
|
|
if (V->pos > V->end) V->pos -= V->loop; |
|
|
|
i = waves[V->pos]; |
|
|
|
i = waves[V->pos]; |
|
|
|
i = (i << 7) + (V->frac >> 9) * (waves[V->pos + 1] - i) + 0x40400000; |
|
|
|
i = (i << 7) + (V->frac >> 9) * (waves[V->pos + 1] - i) + 0x40400000; |
|
|
|
x = V->env * (*(float *)&i - 3.0f); //fast int->float
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
V++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
tl += tfrq * (l - tl); //treble boost
|
|
|
|
|
|
|
|
tr += tfrq * (r - tr); |
|
|
|
|
|
|
|
r += treb * (r - tr); |
|
|
|
|
|
|
|
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?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*out_r++ += static_cast<int16_t>(l * 0x8000); |
|
|
|
|
|
|
|
*out_l++ += static_cast<int16_t>(r * 0x8000); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(frame<sampleFrames) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(activevoices == 0 && programs[curProgram].param[4] > 0.5f)
|
|
|
|
|
|
|
|
{ lfo0 = -0.7071f; lfo1 = 0.7071f; } //reset LFO phase - good idea?
|
|
|
|
|
|
|
|
int32_t note = notes[event++]; |
|
|
|
|
|
|
|
int32_t vel = notes[event++]; |
|
|
|
|
|
|
|
noteOn(note, vel); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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]; |
|
|
|
|
|
|
|
notes[0] = EVENTS_DONE; //mark events buffer as done
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::processReplacing(float **inputs, float **outputs, int32_t sampleFrames) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
float* out0 = outputs[0]; |
|
|
|
|
|
|
|
float* out1 = outputs[1]; |
|
|
|
|
|
|
|
int32_t event=0, frame=0, frames, v; |
|
|
|
|
|
|
|
float x, l, r, od=overdrive; |
|
|
|
|
|
|
|
int32_t i; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(frame<sampleFrames) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
frames = notes[event++]; |
|
|
|
|
|
|
|
if(frames>sampleFrames) frames = sampleFrames; |
|
|
|
|
|
|
|
frames -= frame; |
|
|
|
|
|
|
|
frame += frames; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(--frames>=0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
VOICE *V = voice; |
|
|
|
|
|
|
|
l = r = 0.0f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(v=0; v<activevoices; v++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
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 - 3.0f); //fast int->float
|
|
|
|
//x = V->env * (float)i / 32768.0f;
|
|
|
|
x = V->env * (float(i) - 3.0f); |
|
|
|
i = waves[V->pos] + ((V->frac * (waves[V->pos + 1] - waves[V->pos])) >> 16); |
|
|
|
|
|
|
|
x = V->env * (float)i / 32768.0f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
V->env = V->env * V->dec; //envelope
|
|
|
|
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
|
|
|
|
if (x > 0.0f) { |
|
|
|
|
|
|
|
x -= od * x * x; //overdrive
|
|
|
|
|
|
|
|
if (x < -V->env) x = -V->env; |
|
|
|
|
|
|
|
} //+= 0.5f * x * x; }
|
|
|
|
|
|
|
|
|
|
|
|
l += V->outl * x; |
|
|
|
l += V->outl * x; |
|
|
|
r += V->outr * x; |
|
|
|
r += V->outr * x; |
|
|
@ -448,14 +382,17 @@ void mdaEPiano::processReplacing(float **inputs, float **outputs, int32_t sample |
|
|
|
l += l * lmod * lfo1; |
|
|
|
l += l * lmod * lfo1; |
|
|
|
r += r * rmod * lfo1; //worth making all these local variables?
|
|
|
|
r += r * rmod * lfo1; //worth making all these local variables?
|
|
|
|
|
|
|
|
|
|
|
|
*out0++ = l; |
|
|
|
*out_r++ = static_cast<int16_t>(l * 0x8000); |
|
|
|
*out1++ = r; |
|
|
|
*out_l++ = static_cast<int16_t>(r * 0x8000); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (frame < sampleFrames) |
|
|
|
if (frame < sampleFrames) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (activevoices == 0 && programs[curProgram].param[4] > 0.5f) |
|
|
|
if (activevoices == 0 && programs[curProgram].param[4] > 0.5f) |
|
|
|
{ lfo0 = -0.7071f; lfo1 = 0.7071f; } //reset LFO phase - good idea?
|
|
|
|
{ |
|
|
|
|
|
|
|
lfo0 = -0.7071f; //reset LFO phase - good idea?
|
|
|
|
|
|
|
|
lfo1 = 0.7071f; |
|
|
|
|
|
|
|
} |
|
|
|
int32_t note = notes[event++]; |
|
|
|
int32_t note = notes[event++]; |
|
|
|
int32_t vel = notes[event++]; |
|
|
|
int32_t vel = notes[event++]; |
|
|
|
noteOn(note, vel); |
|
|
|
noteOn(note, vel); |
|
|
@ -468,7 +405,6 @@ void mdaEPiano::processReplacing(float **inputs, float **outputs, int32_t sample |
|
|
|
notes[0] = EVENTS_DONE; //mark events buffer as done
|
|
|
|
notes[0] = EVENTS_DONE; //mark events buffer as done
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
float * param = programs[curProgram].param; |
|
|
|
float * param = programs[curProgram].param; |
|
|
@ -487,7 +423,10 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (v = 0; v < poly; v++) //find quietest voice
|
|
|
|
for (v = 0; v < poly; v++) //find quietest voice
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if(voice[v].env < l) { l = voice[v].env; vl = v; } |
|
|
|
if (voice[v].env < l) { |
|
|
|
|
|
|
|
l = voice[v].env; |
|
|
|
|
|
|
|
vl = v; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -496,7 +435,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
if (note > 60) l += stretch * (float)k; //stretch
|
|
|
|
if (note > 60) l += stretch * (float)k; //stretch
|
|
|
|
|
|
|
|
|
|
|
|
s = size; |
|
|
|
s = size; |
|
|
|
//if(velocity > 40) s += (int32_t)(sizevel * (float)(velocity - 40)); - no velocity to hardness in ePiano
|
|
|
|
//if(velocity > 40) s += (VstInt32)(sizevel * (float)(velocity - 40)); - no velocity to hardness in ePiano
|
|
|
|
|
|
|
|
|
|
|
|
k = 0; |
|
|
|
k = 0; |
|
|
|
while (note > (kgrp[k].high + s)) k += 3; //find keygroup
|
|
|
|
while (note > (kgrp[k].high + s)) k += 3; //find keygroup
|
|
|
@ -543,11 +482,82 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool mdaEPiano::processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
float* param = programs[curProgram].param; |
|
|
|
|
|
|
|
int32_t npos = 0; |
|
|
|
|
|
|
|
|
|
|
|
int32_t mdaEPiano::processEvents() |
|
|
|
switch (type) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case 0x80: //note off
|
|
|
|
|
|
|
|
notes[npos++] = 0; //delta
|
|
|
|
|
|
|
|
notes[npos++] = data1 & 0x7F; //note
|
|
|
|
|
|
|
|
notes[npos++] = 0; //vel
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 0x90: //note on
|
|
|
|
|
|
|
|
notes[npos++] = 0; //delta
|
|
|
|
|
|
|
|
notes[npos++] = data1 & 0x7F; //note
|
|
|
|
|
|
|
|
notes[npos++] = data2 & 0x7F; //vel
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 0xB0: //controller
|
|
|
|
|
|
|
|
switch (data1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case 0x01: //mod wheel
|
|
|
|
|
|
|
|
modwhl = 0.0078f * (float)(data2); |
|
|
|
|
|
|
|
if (modwhl > 0.05f) //over-ride pan/trem depth
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
rmod = lmod = modwhl; //lfo depth
|
|
|
|
|
|
|
|
if (param[4] < 0.5f) rmod = -rmod; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 0x07: //volume
|
|
|
|
|
|
|
|
volume = 0.00002f * (float)(data2 * data2); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 0x40: //sustain pedal
|
|
|
|
|
|
|
|
case 0x42: //sustenuto pedal
|
|
|
|
|
|
|
|
sustain = data2 & 0x40; |
|
|
|
|
|
|
|
if (sustain == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
notes[npos++] = 0; |
|
|
|
|
|
|
|
notes[npos++] = SUSTAIN; //end all sustained notes
|
|
|
|
|
|
|
|
notes[npos++] = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: //all notes off
|
|
|
|
|
|
|
|
if (data1 > 0x7A) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (int32_t v = 0; v < NVOICES; v++) voice[v].dec = 0.99f; |
|
|
|
|
|
|
|
sustain = 0; |
|
|
|
|
|
|
|
muff = 160.0f; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 0xC0: //program change
|
|
|
|
|
|
|
|
if (data1 < NPROGS) setProgram(data1); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (npos > EVENTBUFFER) |
|
|
|
|
|
|
|
npos -= 3; //discard events if buffer full!!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
notes[npos] = EVENTS_DONE; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
|
|
|
|
int32_t mdaEPiano::processEvents() |
|
|
|
|
|
|
|
{ |
|
|
|
float * param = programs[curProgram].param; |
|
|
|
float * param = programs[curProgram].param; |
|
|
|
int32_t npos=0; |
|
|
|
int32_t npos=0; |
|
|
|
|
|
|
|
|
|
|
@ -621,7 +631,8 @@ int32_t mdaEPiano::processEvents() |
|
|
|
event++; //?
|
|
|
|
event++; //?
|
|
|
|
} |
|
|
|
} |
|
|
|
notes[npos] = EVENTS_DONE; |
|
|
|
notes[npos] = EVENTS_DONE; |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|