Added midi controllers for some paramters.

Fixes.
dev
Holger Wirtz 6 years ago
parent d0bd6010f3
commit 5947d6f4ea
  1. 28
      MicroMDAEPiano.ino
  2. 2
      UI.hpp
  3. 4
      config.h
  4. 49
      mdaEPiano.cpp
  5. 5
      mdaEPiano.h

@ -318,7 +318,27 @@ void handleControlChange(byte inChannel, byte inData1, byte inData2)
{ {
if (checkMidiChannel(inChannel)) if (checkMidiChannel(inChannel))
{ {
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); ep->processMidiController(inData1, inData2);
break;
}
} }
} }
@ -334,7 +354,13 @@ void handlePitchBend(byte inChannel, int inPitch)
void handleProgramChange(byte inChannel, byte inProgram) 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)

@ -1977,7 +1977,7 @@ void set_reverb_level(uint8_t value)
Serial.print(F("Set REVERB_LEVEL ")); Serial.print(F("Set REVERB_LEVEL "));
Serial.println(value); Serial.println(value);
#endif #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_r.gain(0, 1.0 - tmp);
//mixer_l.gain(0, 1.0 - tmp); //mixer_l.gain(0, 1.0 - tmp);
mixer_r.gain(0, 1.0); mixer_r.gain(0, 1.0);

@ -97,7 +97,7 @@
30: 1.22 Volts p-p 30: 1.22 Volts p-p
31: 1.16 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_CS_PIN 10
//#define SDCARD_MOSI_PIN 7 //#define SDCARD_MOSI_PIN 7
//#define SDCARD_SCK_PIN 14 //#define SDCARD_SCK_PIN 14
@ -135,7 +135,7 @@
//* DO NO CHANGE ANYTHING BEYOND IF YOU DON'T KNOW WHAT YOU ARE DOING !!! //* 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))) #define MAX_SOUNDS min(99,int((4096-EEPROM_CONFIGURATIONS)/sizeof(config_t)))

@ -30,6 +30,8 @@
#include <math.h> #include <math.h>
extern float _loudness; extern float _loudness;
extern uint8_t master_volume;
extern config_t configuration;
mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, NPROGS, NPARAMS) 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 void mdaEPiano::reset_voices(void) // reset all voices
{ {
//initialise...
for (int32_t v = 0; v < NVOICES; v++) for (int32_t v = 0; v < NVOICES; v++)
{ {
voice[v].env = 0.0f; voice[v].env = 0.0f;
voice[v].dec = 0.99f; //all notes off 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; muff = 160.0f;
sustain = activevoices = 0; sustain = activevoices = 0;
tl = tr = lfo0 = dlfo = 0.0f; tl = tr = lfo0 = dlfo = 0.0f;
lfo1 = 1.0f; lfo1 = 1.0f;
vol = VOLUME;
update(); 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 void mdaEPiano::update() //parameter change
{ {
@ -401,7 +419,7 @@ bool mdaEPiano::processMidiController(uint8_t data1, uint8_t data2)
break; break;
case 0x07: //volume case 0x07: //volume
volume = 0.00002f * (float)(data2 * data2); master_volume = map(data2, 0, 127, ENC_MASTER_VOLUME_MIN, ENC_MASTER_VOLUME_MAX);
break; break;
case 0x40: //sustain pedal case 0x40: //sustain pedal
@ -413,13 +431,20 @@ bool mdaEPiano::processMidiController(uint8_t data1, uint8_t data2)
} }
break; break;
default: //all notes off case 0x78: // All Sound Off: mutes all sounding notes. It does so regardless of release time or sustain. (See MIDI CC 123)
if (data1 > 0x7A) reset_voices();
{ break;
for (int32_t v = 0; v < max_polyphony; v++) voice[v].dec = 0.99f; case 0x79: // Reset All Controllers: it will reset all controllers to their default.
sustain = 0; reset_controllers();
muff = 160.0f; 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; break;
} }
return (true); return (true);

@ -98,6 +98,8 @@ class mdaEPiano
//virtual float getParameter(int32_t index); //virtual float getParameter(int32_t index);
virtual void resume(); virtual void resume();
void reset_voices(void); void reset_voices(void);
void reset_controllers(void);
void stop_voices(void);
void setDecay(float value); void setDecay(float value);
void setRelease(float value); void setRelease(float value);
void setHardness(float value); void setHardness(float value);
@ -132,7 +134,8 @@ class mdaEPiano
float lfo0, lfo1, dlfo, lmod, rmod; float lfo0, lfo1, dlfo, lmod, rmod;
float treb, tfrq, tl, tr; float treb, tfrq, tl, tr;
float tune, fine, random, stretch, overdrive; 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; float vol;
//uint8_t curProgram; //uint8_t curProgram;
}; };

Loading…
Cancel
Save