|
|
@ -35,13 +35,8 @@ mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Fs = SAMPLE_RATE; iFs = 1.0f / Fs; //just in case...
|
|
|
|
Fs = SAMPLE_RATE; iFs = 1.0f / Fs; //just in case...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
programs = new mdaEPianoProgram[NPROGS]; |
|
|
|
programs = new mdaEPianoProgram[NPROGS]; |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
if (programs) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//fill patches...
|
|
|
|
|
|
|
|
int32_t i = 0; |
|
|
|
|
|
|
|
fillpatch(i++, "Default", 0.500f, 0.500f, 0.500f, 0.500f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.146f, 0.000f); |
|
|
|
fillpatch(i++, "Default", 0.500f, 0.500f, 0.500f, 0.500f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.146f, 0.000f); |
|
|
|
fillpatch(i++, "Bright", 0.500f, 0.500f, 1.000f, 0.800f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.146f, 0.500f); |
|
|
|
fillpatch(i++, "Bright", 0.500f, 0.500f, 1.000f, 0.800f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.146f, 0.500f); |
|
|
|
fillpatch(i++, "Mellow", 0.500f, 0.500f, 0.000f, 0.000f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.246f, 0.000f); |
|
|
|
fillpatch(i++, "Mellow", 0.500f, 0.500f, 0.000f, 0.000f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.246f, 0.000f); |
|
|
@ -50,10 +45,20 @@ mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) |
|
|
|
fillpatch(i++, "(default)", 0.500f, 0.500f, 0.500f, 0.500f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.146f, 0.000f); |
|
|
|
fillpatch(i++, "(default)", 0.500f, 0.500f, 0.500f, 0.500f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.146f, 0.000f); |
|
|
|
fillpatch(i++, "(default)", 0.500f, 0.500f, 0.500f, 0.500f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.146f, 0.000f); |
|
|
|
fillpatch(i++, "(default)", 0.500f, 0.500f, 0.500f, 0.500f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.146f, 0.000f); |
|
|
|
fillpatch(i++, "(default)", 0.500f, 0.500f, 0.500f, 0.500f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.146f, 0.000f); |
|
|
|
fillpatch(i++, "(default)", 0.500f, 0.500f, 0.500f, 0.500f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.146f, 0.000f); |
|
|
|
setProgram(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fillpatch(0, "Default", 0.500f, 0.500f, 0.500f, 0.500f, 0.500f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.146f, 0.000f); |
|
|
|
|
|
|
|
|
|
|
|
setDecay(0.500f); |
|
|
|
|
|
|
|
setRelease(0.500f); |
|
|
|
|
|
|
|
setHardness(0.500f); |
|
|
|
|
|
|
|
setTreble(0.500f); |
|
|
|
|
|
|
|
setPanTremolo(0.500f); |
|
|
|
|
|
|
|
setPanLFO(0.650f); |
|
|
|
|
|
|
|
setVelocitySense(0.250f); |
|
|
|
|
|
|
|
setStereo(0.500f); |
|
|
|
|
|
|
|
setMaxPolyphony(1.0f); |
|
|
|
|
|
|
|
setTune(0.500f); |
|
|
|
|
|
|
|
setDetune(0.146f); |
|
|
|
|
|
|
|
setOverdrive(0.000f); |
|
|
|
|
|
|
|
|
|
|
|
waves = (short*)epianoDataXfade; |
|
|
|
waves = (short*)epianoDataXfade; |
|
|
|
|
|
|
|
|
|
|
@ -106,8 +111,6 @@ mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) |
|
|
|
|
|
|
|
|
|
|
|
//initialise...
|
|
|
|
//initialise...
|
|
|
|
reset_voices(); |
|
|
|
reset_voices(); |
|
|
|
|
|
|
|
|
|
|
|
curProgram = 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::reset_voices(void) // reset all voices
|
|
|
|
void mdaEPiano::reset_voices(void) // reset all voices
|
|
|
@ -124,15 +127,15 @@ void mdaEPiano::reset_voices(void) // reset all voices |
|
|
|
tl = tr = lfo0 = dlfo = 0.0f; |
|
|
|
tl = tr = lfo0 = dlfo = 0.0f; |
|
|
|
lfo1 = 1.0f; |
|
|
|
lfo1 = 1.0f; |
|
|
|
|
|
|
|
|
|
|
|
//guiUpdate = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vol = VOLUME; |
|
|
|
vol = VOLUME; |
|
|
|
update(); |
|
|
|
update(); |
|
|
|
// suspend();
|
|
|
|
// suspend();
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::update() //parameter change
|
|
|
|
void mdaEPiano::update() //parameter change
|
|
|
|
{ |
|
|
|
{ |
|
|
|
float * param = programs[curProgram].param; |
|
|
|
float * param = programs[ 0].param; |
|
|
|
size = (int32_t)(12.0f * param[2] - 6.0f); |
|
|
|
size = (int32_t)(12.0f * param[2] - 6.0f); |
|
|
|
|
|
|
|
|
|
|
|
treb = 4.0f * param[3] * param[3] - 1.0f; //treble gain
|
|
|
|
treb = 4.0f * param[3] * param[3] - 1.0f; //treble gain
|
|
|
@ -159,7 +162,7 @@ void mdaEPiano::resume() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Fs = SAMPLE_RATE; |
|
|
|
Fs = SAMPLE_RATE; |
|
|
|
iFs = 1.0f / Fs; |
|
|
|
iFs = 1.0f / Fs; |
|
|
|
dlfo = 6.283f * iFs * (float)exp(6.22f * programs[curProgram].param[5] - 2.61f); //lfo rate
|
|
|
|
dlfo = 6.283f * iFs * (float)exp(6.22f * programs[ 0].param[5] - 2.61f); //lfo rate
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -168,38 +171,76 @@ mdaEPiano::~mdaEPiano () //destroy any buffers... |
|
|
|
if (programs) delete [] programs; |
|
|
|
if (programs) delete [] programs; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
void mdaEPiano::setDecay(float value) |
|
|
|
void mdaEPiano::setProgram(int32_t program) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
curProgram = program; |
|
|
|
setParameter(MDA_EP_DECAY, value); |
|
|
|
update(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::setParameter(int32_t index, float value) |
|
|
|
void mdaEPiano::setRelease(float value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
programs[curProgram].param[index] = value; |
|
|
|
setParameter(MDA_EP_RELEASE, value); |
|
|
|
update(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::setHardness(float value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setParameter(MDA_EP_HARDNESS, value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::fillpatch(int32_t p, char *name, float p0, float p1, float p2, float p3, float p4, |
|
|
|
void mdaEPiano::setTreble(float value) |
|
|
|
float p5, float p6, float p7, float p8, float p9, float p10, float p11) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
strcpy(programs[p].name, name); |
|
|
|
setParameter(MDA_EP_TREBLE, value); |
|
|
|
programs[p].param[0] = p0; programs[p].param[1] = p1; |
|
|
|
|
|
|
|
programs[p].param[2] = p2; programs[p].param[3] = p3; |
|
|
|
|
|
|
|
programs[p].param[4] = p4; programs[p].param[5] = p5; |
|
|
|
|
|
|
|
programs[p].param[6] = p6; programs[p].param[7] = p7; |
|
|
|
|
|
|
|
programs[p].param[8] = p8; programs[p].param[9] = p9; |
|
|
|
|
|
|
|
programs[p].param[10] = p10; programs[p].param[11] = p11; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
void mdaEPiano::setPanTremolo(float value) |
|
|
|
float mdaEPiano::getParameter(int32_t index) { |
|
|
|
{ |
|
|
|
return programs[curProgram].param[index]; |
|
|
|
setParameter(MDA_EP_PAN_TREM, value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::setPanLFO(float value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setParameter(MDA_EP_LFO_RATE, value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::setVelocitySense(float value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setParameter(MDA_EP_VELOCITY_SENSE, value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::setStereo(float value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setParameter(MDA_EP_STEREO, value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::setMaxPolyphony(uint8_t value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
max_polyphony = value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::setTune(float value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setParameter(MDA_EP_TUNE, value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::setDetune(float value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setParameter(MDA_EP_DETUNE, value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::setOverdrive(float value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setParameter(MDA_EP_OVERDRIVE, value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::setParameter(int32_t index, float value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
programs[ 0].param[index] = value; |
|
|
|
|
|
|
|
update(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32_t mdaEPiano::getActiveVoices(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return (activevoices); |
|
|
|
} |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::process(int16_t* outputs_r, int16_t* outputs_l) |
|
|
|
void mdaEPiano::process(int16_t* outputs_r, int16_t* outputs_l) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -269,13 +310,13 @@ void mdaEPiano::process(int16_t* outputs_r, int16_t* outputs_l) |
|
|
|
|
|
|
|
|
|
|
|
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[ 0].param; |
|
|
|
float l = 99.0f; |
|
|
|
float l = 99.0f; |
|
|
|
int32_t v, vl = 0, k, s; |
|
|
|
int32_t v, vl = 0, k, s; |
|
|
|
|
|
|
|
|
|
|
|
if (velocity > 0) |
|
|
|
if (velocity > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (activevoices < configuration.max_poly) //add a note
|
|
|
|
if (activevoices < max_polyphony) //add a note
|
|
|
|
{ |
|
|
|
{ |
|
|
|
vl = activevoices; |
|
|
|
vl = activevoices; |
|
|
|
activevoices++; |
|
|
|
activevoices++; |
|
|
@ -283,7 +324,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
} |
|
|
|
} |
|
|
|
else //steal a note
|
|
|
|
else //steal a note
|
|
|
|
{ |
|
|
|
{ |
|
|
|
for (v = 0; v < configuration.max_poly; v++) //find quietest voice
|
|
|
|
for (v = 0; v < max_polyphony; v++) //find quietest voice
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (voice[v].env < l) { |
|
|
|
if (voice[v].env < l) { |
|
|
|
l = voice[v].env; |
|
|
|
l = voice[v].env; |
|
|
@ -333,7 +374,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
} |
|
|
|
} |
|
|
|
else //note off
|
|
|
|
else //note off
|
|
|
|
{ |
|
|
|
{ |
|
|
|
for (v = 0; v < configuration.max_poly; v++) if (voice[v].note == note) //any voices playing that note?
|
|
|
|
for (v = 0; v < max_polyphony; v++) if (voice[v].note == note) //any voices playing that note?
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (sustain == 0) |
|
|
|
if (sustain == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -346,7 +387,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
|
|
|
|
|
|
|
|
bool mdaEPiano::processMidiController(uint8_t data1, uint8_t data2) |
|
|
|
bool mdaEPiano::processMidiController(uint8_t data1, uint8_t data2) |
|
|
|
{ |
|
|
|
{ |
|
|
|
float* param = programs[curProgram].param; |
|
|
|
float* param = programs[ 0].param; |
|
|
|
|
|
|
|
|
|
|
|
switch (data1) |
|
|
|
switch (data1) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -375,7 +416,7 @@ bool mdaEPiano::processMidiController(uint8_t data1, uint8_t data2) |
|
|
|
default: //all notes off
|
|
|
|
default: //all notes off
|
|
|
|
if (data1 > 0x7A) |
|
|
|
if (data1 > 0x7A) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (int32_t v = 0; v < configuration.max_poly; v++) voice[v].dec = 0.99f; |
|
|
|
for (int32_t v = 0; v < max_polyphony; v++) voice[v].dec = 0.99f; |
|
|
|
sustain = 0; |
|
|
|
sustain = 0; |
|
|
|
muff = 160.0f; |
|
|
|
muff = 160.0f; |
|
|
|
} |
|
|
|
} |
|
|
|