summaryrefslogtreecommitdiff
path: root/src/mdaPiano.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mdaPiano.cpp')
-rw-r--r--src/mdaPiano.cpp105
1 files changed, 100 insertions, 5 deletions
diff --git a/src/mdaPiano.cpp b/src/mdaPiano.cpp
index a358988..419939a 100644
--- a/src/mdaPiano.cpp
+++ b/src/mdaPiano.cpp
@@ -1,14 +1,13 @@
-/* ==================================================
- * LV2 port of the famous mda Piano VSTi
- * ==================================================
+/* ======================================================
+ * LV2 port of the popular mda Piano and mda EPiano VSTi
+ * ======================================================
*
* Port
* Author: Ricardo Wurmus (rekado)
* Based on: mda-vst-src-2010-02-14.zip
*
- * mda Piano v1.0
+ * mda Piano / mda EPiano
* Copyright(c)1999-2000 Paul Kellett (maxim digital audio)
- * Based on VST2 SDK (c)1996-1999 Steinberg Soft und Hardware GmbH, All Rights Reserved
*
* ==================================================
*/
@@ -24,6 +23,7 @@ mdaPiano::mdaPiano(double rate)
sustain = 0;
+#ifdef PIANO
static const char* sample_names[] =
{ "0c.raw", "0e.raw", "0g.raw"
, "1c.raw", "1e.raw", "1g.raw"
@@ -31,12 +31,30 @@ mdaPiano::mdaPiano(double rate)
, "3c.raw", "3e.raw", "3g.raw"
, "4c.raw", "4e.raw", "4a.raw"
};
+#elif defined EPIANO
+ static const char* sample_names[] =
+ { "0c-0.raw", "0c-1.raw", "0c-2.raw"
+ , "0g-0.raw", "0g-1.raw", "0g-2.raw"
+ , "1c-0.raw", "1c-1.raw", "1c-2.raw"
+ , "1g-0.raw", "1g-1.raw", "1g-2.raw"
+ , "2c-0.raw", "2c-1.raw", "2c-2.raw"
+ , "2g-0.raw", "2g-1.raw", "2g-2.raw"
+ , "3c-0.raw", "3c-1.raw", "3c-2.raw"
+ , "3g-0.raw", "3g-1.raw", "3g-2.raw"
+ , "4c-0.raw", "4c-1.raw", "4c-2.raw"
+ , "4g-0.raw", "4g-1.raw", "4g-2.raw"
+ , "5c-0.raw", "5c-1.raw", "5c-2.raw"
+ };
+#endif
for (unsigned char i=0; i<NSAMPLES; ++i) {
load_sample(&samples[i], sample_names[i]);
}
load_kgrp(kgrp);
+#ifdef EPIANO
+ tweak_samples();
+#endif
for(uint32_t i=0; i<NVOICES; ++i) {
voices[i] = new mdaPianoVoice(rate, samples, kgrp);
@@ -117,6 +135,7 @@ void mdaPiano::handle_midi(uint32_t size, unsigned char* data) {
case 0xB0:
switch(data[1])
{
+#ifdef PIANO
case 0x01: //mod wheel
case 0x43: //soft pedal
{
@@ -126,6 +145,12 @@ void mdaPiano::handle_midi(uint32_t size, unsigned char* data) {
}
break;
}
+#elif defined EPIANO
+ case 0x01: //mod wheel
+ //scale the mod value to cover the range [0..1]
+ *p(p_modulation) = scale_midi_to_f(data[2]);
+ break;
+#endif
case 0x07: //volume
setVolume(0.00002f * (float)(data[2] * data[2]));
@@ -206,6 +231,7 @@ void mdaPiano::load_sample(Sample *s, const char* name) {
// TODO: load keymapping from a file
void mdaPiano::load_kgrp(KGRP *kgrp) {
+#ifdef PIANO
kgrp[ 0].root = 36; kgrp[ 0].high = 37; kgrp[ 0].loop = 14774;
kgrp[ 1].root = 40; kgrp[ 1].high = 41; kgrp[ 1].loop = 16268;
kgrp[ 2].root = 43; kgrp[ 2].high = 45; kgrp[ 2].loop = 33541;
@@ -221,7 +247,76 @@ void mdaPiano::load_kgrp(KGRP *kgrp) {
kgrp[12].root = 84; kgrp[12].high = 85; kgrp[12].loop = 6011;
kgrp[13].root = 88; kgrp[13].high = 89; kgrp[13].loop = 3414;
kgrp[14].root = 93; kgrp[14].high = 999; kgrp[14].loop = 2399;
+#elif defined EPIANO
+ kgrp[ 0].root = 36; kgrp[ 0].high = 39; //C1
+ kgrp[ 3].root = 43; kgrp[ 3].high = 45; //G1
+ kgrp[ 6].root = 48; kgrp[ 6].high = 51; //C2
+ kgrp[ 9].root = 55; kgrp[ 9].high = 57; //G2
+ kgrp[12].root = 60; kgrp[12].high = 63; //C3
+ kgrp[15].root = 67; kgrp[15].high = 69; //G3
+ kgrp[18].root = 72; kgrp[18].high = 75; //C4
+ kgrp[21].root = 79; kgrp[21].high = 81; //G4
+ kgrp[24].root = 84; kgrp[24].high = 87; //C5
+ kgrp[27].root = 91; kgrp[27].high = 93; //G5
+ kgrp[30].root = 96; kgrp[30].high =999; //C6
+
+ kgrp[0].loop = 4400;
+ kgrp[1].loop = 4903;
+ kgrp[2].loop = 6398;
+ kgrp[3].loop = 3938;
+ kgrp[4].loop = 1633; //was 1636
+ kgrp[5].loop = 5245;
+ kgrp[6].loop = 2937;
+ kgrp[7].loop = 2203; //was 2204
+ kgrp[8].loop = 6368;
+ kgrp[9].loop = 10452;
+ kgrp[10].loop = 5217; //was 5220
+ kgrp[11].loop = 3099;
+ kgrp[12].loop = 4284;
+ kgrp[13].loop = 3916;
+ kgrp[14].loop = 2937;
+ kgrp[15].loop = 4732;
+ kgrp[16].loop = 4733;
+ kgrp[17].loop = 2285;
+ kgrp[18].loop = 4098;
+ kgrp[19].loop = 4099;
+ kgrp[20].loop = 3609;
+ kgrp[21].loop = 2446;
+ kgrp[22].loop = 6278;
+ kgrp[23].loop = 2283;
+ kgrp[24].loop = 2689;
+ kgrp[25].loop = 4370;
+ kgrp[26].loop = 5225;
+ kgrp[27].loop = 2811;
+ kgrp[28].loop = 2811; //ghost
+ kgrp[29].loop = 4522;
+ kgrp[30].loop = 2306;
+ kgrp[31].loop = 2306; //ghost
+ kgrp[32].loop = 2169;
+#endif
}
+#ifdef EPIANO
+void mdaPiano::tweak_samples() {
+ //extra xfade looping...
+ for(uint32_t k=0; k<28; k++)
+ {
+ long p0 = samples[k].size;
+ long p1 = samples[k].size - kgrp[k].loop;
+
+ float xf = 1.0f;
+ float dxf = -0.02f;
+
+ while(xf > 0.0f)
+ {
+ samples[k].buffer[p0] = (short)((1.0f - xf) * (float)samples[k].buffer[p0] + xf * (float)samples[k].buffer[p1]);
+ p0--;
+ p1--;
+ xf += dxf;
+ }
+ }
+}
+#endif
+
static int _ = mdaPiano::register_class(p_uri);