Added midi controllers for some paramters.

Fixes.
master
Holger Wirtz 6 years ago
parent cbf64fa039
commit 2dd128532a
  1. 34
      MicroMDAEPiano.ino
  2. 2
      UI.hpp
  3. 4
      config.h
  4. 49
      mdaEPiano.cpp
  5. 7
      mdaEPiano.h

@ -318,7 +318,27 @@ void handleControlChange(byte inChannel, byte inData1, byte inData2)
{
if (checkMidiChannel(inChannel))
{
ep->processMidiController(inData1, inData2);
switch (inData1)
{
case 10: // Panorama
configuration.pan = mapfloat(float(inData2), 0, 127, 0.0, 1.0);
break;
case 91: // Reverb level
set_reverb_level(map(inData2, 0, 127, ENC_REVERB_LEVEL_MIN, ENC_REVERB_LEVEL_MAX));
break;
case 92: // Tremolo level (same as modwheel)
inData1 = 1; // now it's modwheel and can be processd by ep->processMidiController :-)
break;
case 93: // Chorus level
set_chorus_level(map(inData2, 0, 127, ENC_CHORUS_LEVEL_MIN, ENC_CHORUS_LEVEL_MAX));
break;
case 94: // Detune level
ep->setDetune(mapfloat(float(inData2), 0, 127, 0.0, 1.0));
break;
default:
ep->processMidiController(inData1, inData2);
break;
}
}
}
@ -334,15 +354,21 @@ void handlePitchBend(byte inChannel, int inPitch)
void handleProgramChange(byte inChannel, byte inProgram)
{
;
if (checkMidiChannel(inChannel))
{
sound = inProgram;
load_sound();
if (menu_system.get_currentScreen() == &load_sound_screen)
menu_system.update();
}
}
void handleSystemExclusive(byte *data, uint len)
void handleSystemExclusive(byte * data, uint len)
{
;
}
void handleSystemExclusiveChunk(const byte *data, uint16_t len, bool last)
void handleSystemExclusiveChunk(const byte * data, uint16_t len, bool last)
{
;
}

@ -1977,7 +1977,7 @@ void set_reverb_level(uint8_t value)
Serial.print(F("Set REVERB_LEVEL "));
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_REVERB_DAMPING_MIN, ENC_REVERB_DAMPING_MAX, 0.0, 1.0);
float tmp = mapfloat(float(value), ENC_REVERB_LEVEL_MIN, ENC_REVERB_LEVEL_MAX, 0.0, 1.0);
//mixer_r.gain(0, 1.0 - tmp);
//mixer_l.gain(0, 1.0 - tmp);
mixer_r.gain(0, 1.0);

@ -97,7 +97,7 @@
30: 1.22 Volts p-p
31: 1.16 Volts p-p
*/
#define SGTL5000_LINEOUT_LEVEL 28
#define SGTL5000_LINEOUT_LEVEL 22
//#define SDCARD_CS_PIN 10
//#define SDCARD_MOSI_PIN 7
//#define SDCARD_SCK_PIN 14
@ -135,7 +135,7 @@
//* DO NO CHANGE ANYTHING BEYOND IF YOU DON'T KNOW WHAT YOU ARE DOING !!!
//*************************************************************************************************
#define MICRO_MDAEPIANO_VERSION "0.9.0"
#define MICRO_MDAEPIANO_VERSION "0.9.1"
#define MAX_SOUNDS min(99,int((4096-EEPROM_CONFIGURATIONS)/sizeof(config_t)))

@ -30,6 +30,8 @@
#include <math.h>
extern float _loudness;
extern uint8_t master_volume;
extern config_t configuration;
mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, NPROGS, NPARAMS)
{
@ -115,23 +117,39 @@ mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster)
void mdaEPiano::reset_voices(void) // reset all voices
{
//initialise...
for (int32_t v = 0; v < NVOICES; v++)
{
voice[v].env = 0.0f;
voice[v].dec = 0.99f; //all notes off
}
volume = 0.2f;
//volume = // 0.00002f * 127; // Fixing this level and using CC#7 as master_volume
muff = 160.0f;
sustain = activevoices = 0;
tl = tr = lfo0 = dlfo = 0.0f;
lfo1 = 1.0f;
vol = VOLUME;
update();
// suspend();
}
void mdaEPiano::reset_controllers(void) // reset controllers
{
tl = tr = lfo0 = dlfo = 0.0f;
lfo1 = 1.0f;
update();
}
void mdaEPiano::stop_voices(void) // all keys off, but no reset for sustain
{
for (int32_t v = 0; v < NVOICES; v++)
{
voice[v].env = 0.0f;
}
muff = 160.0f;
activevoices = 0;
update();
}
void mdaEPiano::update() //parameter change
{
@ -401,7 +419,7 @@ bool mdaEPiano::processMidiController(uint8_t data1, uint8_t data2)
break;
case 0x07: //volume
volume = 0.00002f * (float)(data2 * data2);
master_volume = map(data2, 0, 127, ENC_MASTER_VOLUME_MIN, ENC_MASTER_VOLUME_MAX);
break;
case 0x40: //sustain pedal
@ -413,13 +431,20 @@ bool mdaEPiano::processMidiController(uint8_t data1, uint8_t data2)
}
break;
default: //all notes off
if (data1 > 0x7A)
{
for (int32_t v = 0; v < max_polyphony; v++) voice[v].dec = 0.99f;
sustain = 0;
muff = 160.0f;
}
case 0x78: // All Sound Off: mutes all sounding notes. It does so regardless of release time or sustain. (See MIDI CC 123)
reset_voices();
break;
case 0x79: // Reset All Controllers: it will reset all controllers to their default.
reset_controllers();
break;
case 0x7b: // All Notes Off: mutes all sounding notes. Release time will still be maintained, and notes held by sustain will not turn off until sustain pedal is depressed.
stop_voices();
break;
case 0x7e: // Mono Mode: sets device mode to Monophonic.
setMaxPolyphony(1);
break;
case 0x7f: // Poly Mode: sets device mode to Polyphonic.
setMaxPolyphony(configuration.max_poly);
break;
}
return (true);

@ -98,6 +98,8 @@ class mdaEPiano
//virtual float getParameter(int32_t index);
virtual void resume();
void reset_voices(void);
void reset_controllers(void);
void stop_voices(void);
void setDecay(float value);
void setRelease(float value);
void setHardness(float value);
@ -111,7 +113,7 @@ class mdaEPiano
void setDetune(float value);
void setOverdrive(float value);
int32_t getActiveVoices(void);
private:
void update(); //my parameter update
void fillpatch(int32_t p, char *name, float p0, float p1, float p2, float p3, float p4,
@ -132,7 +134,8 @@ class mdaEPiano
float lfo0, lfo1, dlfo, lmod, rmod;
float treb, tfrq, tl, tr;
float tune, fine, random, stretch, overdrive;
float muff, muffvel, sizevel, velsens, volume, modwhl;
float muff, muffvel, sizevel, velsens, modwhl;
const float volume = 0.00002f * 127;
float vol;
//uint8_t curProgram;
};

Loading…
Cancel
Save