|
|
@ -29,6 +29,8 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdio.h> |
|
|
|
#include <math.h> |
|
|
|
#include <math.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern float _loudness; |
|
|
|
|
|
|
|
|
|
|
|
mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, NPROGS, NPARAMS)
|
|
|
|
mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, NPROGS, NPARAMS)
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Fs = SAMPLE_RATE; iFs = 1.0f / Fs; //just in case...
|
|
|
|
Fs = SAMPLE_RATE; iFs = 1.0f / Fs; //just in case...
|
|
|
@ -98,6 +100,12 @@ mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) |
|
|
|
kgrp[31].pos = 406046; kgrp[31].end = 414486; kgrp[31].loop = 2306; //ghost
|
|
|
|
kgrp[31].pos = 406046; kgrp[31].end = 414486; kgrp[31].loop = 2306; //ghost
|
|
|
|
kgrp[32].pos = 414487; kgrp[32].end = 422408; kgrp[32].loop = 2169; |
|
|
|
kgrp[32].pos = 414487; kgrp[32].end = 422408; kgrp[32].loop = 2169; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//initialise...
|
|
|
|
|
|
|
|
reset_voices(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::reset_voices(void) // reset all voices
|
|
|
|
|
|
|
|
{ |
|
|
|
//initialise...
|
|
|
|
//initialise...
|
|
|
|
for (int32_t v = 0; v < NVOICES; v++) |
|
|
|
for (int32_t v = 0; v < NVOICES; v++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -116,7 +124,6 @@ mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) |
|
|
|
update(); |
|
|
|
update(); |
|
|
|
// suspend();
|
|
|
|
// suspend();
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void mdaEPiano::update() //parameter change
|
|
|
|
void mdaEPiano::update() //parameter change
|
|
|
|
{ |
|
|
|
{ |
|
|
|
float * param = programs[curProgram].param; |
|
|
|
float * param = programs[curProgram].param; |
|
|
@ -240,8 +247,8 @@ void mdaEPiano::process(int16_t* outputs_r, int16_t* outputs_l) |
|
|
|
l = 1.0; |
|
|
|
l = 1.0; |
|
|
|
else if (l < -1.0) |
|
|
|
else if (l < -1.0) |
|
|
|
l = -1.0; |
|
|
|
l = -1.0; |
|
|
|
outputs_l[frame] = static_cast<int16_t>(l * configuration._loudness * 0x7fff) >> REDUCE_LOUDNESS; |
|
|
|
outputs_l[frame] = static_cast<int16_t>(l * _loudness * 0x7fff) >> REDUCE_LOUDNESS; |
|
|
|
outputs_r[frame] = static_cast<int16_t>(r * configuration._loudness * 0x7fff) >> REDUCE_LOUDNESS; |
|
|
|
outputs_r[frame] = static_cast<int16_t>(r * _loudness * 0x7fff) >> REDUCE_LOUDNESS; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (fabs(tl) < 1.0e-10) tl = 0.0f; //anti-denormal
|
|
|
|
if (fabs(tl) < 1.0e-10) tl = 0.0f; //anti-denormal
|
|
|
@ -260,7 +267,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
|
|
|
|
|
|
|
|
if (velocity > 0) |
|
|
|
if (velocity > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (activevoices < NVOICES) //add a note
|
|
|
|
if (activevoices < configuration.max_poly) //add a note
|
|
|
|
{ |
|
|
|
{ |
|
|
|
vl = activevoices; |
|
|
|
vl = activevoices; |
|
|
|
activevoices++; |
|
|
|
activevoices++; |
|
|
@ -268,7 +275,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
} |
|
|
|
} |
|
|
|
else //steal a note
|
|
|
|
else //steal a note
|
|
|
|
{ |
|
|
|
{ |
|
|
|
for (v = 0; v < NVOICES; v++) //find quietest voice
|
|
|
|
for (v = 0; v < configuration.max_poly; v++) //find quietest voice
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (voice[v].env < l) { |
|
|
|
if (voice[v].env < l) { |
|
|
|
l = voice[v].env; |
|
|
|
l = voice[v].env; |
|
|
@ -318,7 +325,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity) |
|
|
|
} |
|
|
|
} |
|
|
|
else //note off
|
|
|
|
else //note off
|
|
|
|
{ |
|
|
|
{ |
|
|
|
for (v = 0; v < NVOICES; v++) if (voice[v].note == note) //any voices playing that note?
|
|
|
|
for (v = 0; v < configuration.max_poly; v++) if (voice[v].note == note) //any voices playing that note?
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (sustain == 0) |
|
|
|
if (sustain == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -360,7 +367,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 < NVOICES; v++) voice[v].dec = 0.99f; |
|
|
|
for (int32_t v = 0; v < configuration.max_poly; v++) voice[v].dec = 0.99f; |
|
|
|
sustain = 0; |
|
|
|
sustain = 0; |
|
|
|
muff = 160.0f; |
|
|
|
muff = 160.0f; |
|
|
|
} |
|
|
|
} |
|
|
|