diff --git a/MicroMDAEPiano.ino b/MicroMDAEPiano.ino index 9019b7e..0eddd10 100644 --- a/MicroMDAEPiano.ino +++ b/MicroMDAEPiano.ino @@ -61,21 +61,21 @@ AudioAnalyzePeak peak_l; //xy=695,491 #ifdef USE_DYNAMICS AudioEffectDynamics dyna_r; AudioEffectDynamics dyna_l; -AudioConnection patchCord2(queue_r, dyna_r); -AudioConnection patchCord3(queue_l, dyna_l); +AudioConnection patchCord0(queue_r, dyna_r); +AudioConnection patchCord1(queue_l, dyna_l); #endif #ifdef TEENSY_AUDIO_BOARD AudioOutputI2S i2s1; //xy=1072,364 #ifdef USE_DYNAMICS -AudioConnection patchCord4(dyna_r, peak_r); -AudioConnection patchCord5(dyna_l, peak_l); -AudioConnection patchCord6(dyna_r, 0, i2s1, 0); -AudioConnection patchCord7(dyna_l, 0, i2s1, 1); +AudioConnection patchCord2(dyna_r, peak_r); +AudioConnection patchCord3(dyna_l, peak_l); +AudioConnection patchCord4(dyna_r, 0, i2s1, 0); +AudioConnection patchCord5(dyna_l, 0, i2s1, 1); #else -AudioConnection patchCord4(queue_r, peak_r); -AudioConnection patchCord5(queue_l, peak_l); -AudioConnection patchCord6(queue_r, 0, i2s1, 0); -AudioConnection patchCord7(queue_l, 0, i2s1, 1); +AudioConnection patchCord2(queue_r, peak_r); +AudioConnection patchCord3(queue_l, peak_l); +AudioConnection patchCord4(queue_r, 0, i2s1, 0); +AudioConnection patchCord5(queue_l, 0, i2s1, 1); #endif AudioControlSGTL5000 sgtl5000_1; //xy=700,536 #else @@ -222,16 +222,13 @@ void setup() ep->setParameter(DETUNE, 0.1); ep->setParameter(VELOCITY_SENSE, 1.0); ep->setParameter(STEREO, 0.7); - ep->setParameter(MAX_POLY, 1.0); ep->setParameter(OVERDRIVE, 0.3); - // DECAY,RELEASE,HARDNESS,TREBLE,PAN_TREM,LFO_RATE,VELOCIT - #ifdef USE_DYNAMICS - //dyna_r.limit(); - //dyna_l.limit(); - dyna_r.compression(-10.0, MIN_T, MIN_T, 20.0, 2.0); - dyna_l.compression(-10.0, MIN_T, MIN_T, 20.0, 2.0); + dyna_r.limit(-0.1f, 0.2, 0.2); + dyna_l.limit(-0.1f, 0.2, 0.2); + //dyna_r.compression(-10.0, MIN_T, MIN_T, 20.0, 2.0); + //dyna_l.compression(-10.0, MIN_T, MIN_T, 20.0, 2.0); #endif Serial.println(F("")); diff --git a/config.h b/config.h index 8364c0b..bbbfe9c 100644 --- a/config.h +++ b/config.h @@ -32,18 +32,18 @@ #define VOLUME 0.8 #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI #define AUDIO_MEM 16 -#define AUDIO_MEM_F32 16 #define SAMPLE_RATE 44100 -#define REDUCE_LOUDNESS 0 +#define REDUCE_LOUDNESS 1 #define USE_XFADE_DATA 1 #if !defined(__MK66FX1M0__) // check for Teensy-3.6 #undef USE_ONBOARD_USB_HOST -#define NVOICES 32 +#define NVOICES 64 #else #define NVOICES 32 #endif #define USBCON 1 // enabling onboard MIDI via programing connector #define MIDI_MERGE_THRU 1 +//#define USE_DYNAMICS 1 // Debug output #define SERIAL_SPEED 38400 diff --git a/mdaEPiano.cpp b/mdaEPiano.cpp index c2ebe56..2510ff1 100644 --- a/mdaEPiano.cpp +++ b/mdaEPiano.cpp @@ -39,14 +39,14 @@ mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) { //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, 0.50f, 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, 0.50f, 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, 0.50f, 0.500f, 0.246f, 0.000f); - fillpatch(i++, "Autopan", 0.500f, 0.500f, 0.500f, 0.500f, 0.250f, 0.650f, 0.250f, 0.500f, 0.50f, 0.500f, 0.246f, 0.000f); - fillpatch(i++, "Tremolo", 0.500f, 0.500f, 0.500f, 0.500f, 0.750f, 0.650f, 0.250f, 0.500f, 0.50f, 0.500f, 0.246f, 0.000f); - fillpatch(i++, "(default)", 0.500f, 0.500f, 0.500f, 0.500f, 0.500f, 0.650f, 0.250f, 0.500f, 0.50f, 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, 0.50f, 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, 0.50f, 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++, "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++, "Autopan", 0.500f, 0.500f, 0.500f, 0.500f, 0.250f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.246f, 0.000f); + fillpatch(i++, "Tremolo", 0.500f, 0.500f, 0.500f, 0.500f, 0.750f, 0.650f, 0.250f, 0.500f, 1.0f, 0.500f, 0.246f, 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); } @@ -135,7 +135,6 @@ void mdaEPiano::update() //parameter change if (param[6] < 0.25f) velsens -= 0.75f - 3.0f * param[6]; width = 0.03f * param[7]; - poly = 1 + (int32_t)(31.9f * param[8]); fine = param[9] - 0.5f; random = 0.077f * param[10] * param[10]; stretch = 0.0f; //0.000434f * (param[11] - 0.5f); parameter re-used for overdrive! @@ -261,7 +260,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity) if (velocity > 0) { - if (activevoices < poly) //add a note + if (activevoices < NVOICES) //add a note { vl = activevoices; activevoices++; @@ -269,7 +268,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity) } else //steal a note { - for (v = 0; v < poly; v++) //find quietest voice + for (v = 0; v < NVOICES; v++) //find quietest voice { if (voice[v].env < l) { l = voice[v].env; @@ -390,84 +389,3 @@ bool mdaEPiano::processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2) return (true); } - -/* - int32_t mdaEPiano::processEvents() - { - float * param = programs[curProgram].param; - int32_t npos=0; - - for (int32_t i=0; inumEvents; i++) - { - if((ev->events[i])->type != kVstMidiType) continue; - VstMidiEvent* event = (VstMidiEvent*)ev->events[i]; - char* midiData = event->midiData; - - switch(midiData[0] & 0xf0) //status byte (all channels) - { - case 0x80: //note off - notes[npos++] = event->deltaFrames; //delta - notes[npos++] = midiData[1] & 0x7F; //note - notes[npos++] = 0; //vel - break; - - case 0x90: //note on - notes[npos++] = event->deltaFrames; //delta - notes[npos++] = midiData[1] & 0x7F; //note - notes[npos++] = midiData[2] & 0x7F; //vel - break; - - case 0xB0: //controller - switch(midiData[1]) - { - case 0x01: //mod wheel - modwhl = 0.0078f * (float)(midiData[2]); - 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)(midiData[2] * midiData[2]); - break; - - case 0x40: //sustain pedal - case 0x42: //sustenuto pedal - sustain = midiData[2] & 0x40; - if(sustain==0) - { - notes[npos++] = event->deltaFrames; - notes[npos++] = SUSTAIN; //end all sustained notes - notes[npos++] = 0; - } - break; - - default: //all notes off - if(midiData[1]>0x7A) - { - for(int32_t v=0; vEVENTBUFFER) npos -= 3; //discard events if buffer full!! - event++; //? - } - notes[npos] = EVENTS_DONE; - - return 1; - } -*/ diff --git a/mdaEPiano.h b/mdaEPiano.h index e308833..26d3ef6 100644 --- a/mdaEPiano.h +++ b/mdaEPiano.h @@ -30,7 +30,6 @@ #define NPARAMS 12 //number of parameters #define NPROGS 8 //number of programs #define NOUTS 2 //number of outputs -//#define NVOICES 32 //max polyphony #define SUSTAIN 128 #define SILENCE 0.0001f //voice choking #define WAVELEN 422414 //wave data bytes @@ -105,7 +104,7 @@ class mdaEPiano //: public AudioEffectX ///global internal variables KGRP kgrp[34]; VOICE voice[NVOICES]; - int32_t activevoices, poly; + int32_t activevoices; short *waves; float width; int32_t size, sustain;