Fixing missing velocity_sense menu.

Removing not needed parts from MDAEPiano.
Adding parameter set/get functions for MDAEPiano.
master
Holger Wirtz 6 years ago
parent 6888d1c7f5
commit 46896ad213
  1. 4
      MicroMDAEPiano.ino
  2. 26
      UI.hpp
  3. 24
      config.h
  4. 129
      mdaEPiano.cpp
  5. 38
      mdaEPiano.h

@ -257,7 +257,7 @@ void loop()
}
elapsedMicros t1;
ep->process(audio_buffer_l, audio_buffer_r);
ep->process(audio_buffer_r, audio_buffer_l);
uint32_t t2 = t1;
if (t2 > audio_block_time_us) // everything greater 2.9ms is a buffer underrun!
xrun++;
@ -537,6 +537,8 @@ void show_cpu_and_mem_usage(void)
Serial.print(overload, DEC);
Serial.print(F(" PEAK: "));
Serial.print(peak, DEC);
Serial.print(F(" ACTIVE_VOICES: "));
Serial.print(ep->getActiveVoices(), DEC);
Serial.println();
AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset();

@ -103,6 +103,7 @@ extern AudioAmplifier volume_l;
extern void eeprom_write(void);
extern mdaEPiano* ep;
extern float _loudness;
extern config_t configuration;
/******************************************
TEXT GETTER FUCTIONS
@ -250,7 +251,7 @@ LiquidMenu load_sound_menu(lcd);
/******************************************
EDIT SOUND MENU
******************************************/
#define NUM_EDIT_SOUND_MENUS 8
#define NUM_EDIT_SOUND_MENUS 9
const char edit_sound_text1[] PROGMEM = "Decay";
const char edit_sound_text2[] PROGMEM = "Release";
const char edit_sound_text3[] PROGMEM = "Hardness";
@ -1681,7 +1682,7 @@ void set_decay(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_DECAY_MIN, ENC_DECAY_MAX, 0.0, 1.0);
ep->setParameter(MDA_EP_DECAY, tmp);
ep->setDecay(tmp);
configuration.decay = value;
}
@ -1692,7 +1693,7 @@ void set_release(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_RELEASE_MIN, ENC_RELEASE_MAX, 0.0, 1.0);
ep->setParameter(MDA_EP_RELEASE, tmp);
ep->setRelease(tmp);
configuration.release = value;
}
@ -1703,7 +1704,7 @@ void set_hardness(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_HARDNESS_MIN, ENC_HARDNESS_MAX, 0.0, 1.0);
ep->setParameter(MDA_EP_HARDNESS, tmp);
ep->setHardness(tmp);
configuration.hardness = value;
}
@ -1714,7 +1715,7 @@ void set_treble(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_TREBLE_MIN, ENC_TREBLE_MAX, 0.0, 1.0);
ep->setParameter(MDA_EP_TREBLE, tmp);
ep->setTreble(tmp);
configuration.treble = value;
}
@ -1725,7 +1726,7 @@ void set_stereo(int8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_STEREO_MIN, ENC_STEREO_MAX, 0.0, 1.0);
ep->setParameter(MDA_EP_STEREO, tmp);
ep->setStereo(tmp);
configuration.stereo = value;
}
@ -1746,7 +1747,7 @@ void set_tune(int8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_TUNE_MIN, ENC_TUNE_MAX, 0.0, 1.0);
ep->setParameter(MDA_EP_TUNE, tmp);
ep->setTune(tmp);
configuration.tune = value;
}
@ -1757,7 +1758,7 @@ void set_detune(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_DETUNE_MIN, ENC_DETUNE_MAX, 0.0, 1.0);
ep->setParameter(MDA_EP_DETUNE, tmp);
ep->setDetune(tmp);
configuration.detune = value;
}
@ -1768,7 +1769,7 @@ void set_velocity_sense(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_VELOCITY_SENSE_MIN, ENC_VELOCITY_SENSE_MAX, 0.0, 1.0);
ep->setParameter(MDA_EP_DETUNE, tmp);
ep->setVelocitySense(tmp);
configuration.velocity_sense = value;
}
@ -1779,7 +1780,7 @@ void set_pan_trem_frequency(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_PAN_TREM_FREQUENCY_MIN, ENC_PAN_TREM_FREQUENCY_MAX, 0.0, 1.0);
ep->setParameter(MDA_EP_LFO_RATE, tmp);
ep->setPanLFO(tmp);
configuration.pan_trem_frequency = value;
}
@ -1790,7 +1791,7 @@ void set_pan_trem_level(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_PAN_TREM_LEVEL_MIN, ENC_PAN_TREM_LEVEL_MAX, 0.0, 1.0);
ep->setParameter(MDA_EP_PAN_TREM, tmp);
ep->setPanTremolo(tmp);
configuration.pan_trem_level = value;
}
@ -1801,7 +1802,7 @@ void set_overdrive(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_OVERDRIVE_MIN, ENC_OVERDRIVE_MAX, 0.0, 1.0);
ep->setParameter(MDA_EP_OVERDRIVE, tmp);
ep->setOverdrive(tmp);
configuration.overdrive = value;
}
@ -2029,6 +2030,7 @@ void set_max_poly(uint8_t value)
Serial.print(F("Set MAX_POLY "));
Serial.println(value);
#endif
ep->setMaxPolyphony(value);
configuration.max_poly = value;
ep->reset_voices();
}

@ -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 29
//#define SDCARD_CS_PIN 10
//#define SDCARD_MOSI_PIN 7
//#define SDCARD_SCK_PIN 14
@ -182,7 +182,7 @@
//
#define ENC_OVERDRIVE_MIN 0
#define ENC_OVERDRIVE_MAX 99
#define ENC_OVERDRIVE_DEFAULT 50
#define ENC_OVERDRIVE_DEFAULT 15
//
#define ENC_COMP_GAIN_MIN 0
#define ENC_COMP_GAIN_MAX 2
@ -210,7 +210,7 @@
//
#define ENC_REVERB_ROOMSIZE_MIN 0
#define ENC_REVERB_ROOMSIZE_MAX 99
#define ENC_REVERB_ROOMSIZE_DEFAULT 50
#define ENC_REVERB_ROOMSIZE_DEFAULT 40
//
#define ENC_REVERB_DAMPING_MIN 0
#define ENC_REVERB_DAMPING_MAX 99
@ -218,7 +218,7 @@
//
#define ENC_REVERB_LEVEL_MIN 0
#define ENC_REVERB_LEVEL_MAX 99
#define ENC_REVERB_LEVEL_DEFAULT 50
#define ENC_REVERB_LEVEL_DEFAULT 15
//
#define ENC_CHORUS_FREQUENCY_MIN 0
#define ENC_CHORUS_FREQUENCY_MAX 20
@ -272,20 +272,6 @@
#define ENC_MASTER_PAN_MAX 20
#define ENC_MASTER_PAN_DEFAULT 0
// MDAEPiano parameter mapping
#define MDA_EP_DECAY 0
#define MDA_EP_RELEASE 1
#define MDA_EP_HARDNESS 2
#define MDA_EP_TREBLE 3
#define MDA_EP_PAN_TREM 4
#define MDA_EP_LFO_RATE 5
#define MDA_EP_VELOCITY_SENSE 6
#define MDA_EP_STEREO 7
#define MDA_EP_MAX_POLY 8
#define MDA_EP_TUNE 9
#define MDA_EP_DETUNE 10
#define MDA_EP_OVERDRIVE 11
// MIDI
#ifdef MIDI_DEVICE_USB
#define USBCON 1
@ -300,7 +286,7 @@
// Engine
#if defined(__MK66FX1M0__)
// Teensy-3.6 settings
#define NVOICES 64
#define NVOICES 48
#else
#define NVOICES 32
#endif

@ -35,13 +35,8 @@ mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster)
{
Fs = SAMPLE_RATE; iFs = 1.0f / Fs; //just in case...
programs = new mdaEPianoProgram[NPROGS];
/*
if (programs)
{
//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, 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);
@ -50,10 +45,20 @@ mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster)
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);
}
*/
fillpatch(0, "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);
setDecay(0.500f);
setRelease(0.500f);
setHardness(0.500f);
setTreble(0.500f);
setPanTremolo(0.500f);
setPanLFO(0.650f);
setVelocitySense(0.250f);
setStereo(0.500f);
setMaxPolyphony(1.0f);
setTune(0.500f);
setDetune(0.146f);
setOverdrive(0.000f);
waves = (short*)epianoDataXfade;
@ -106,8 +111,6 @@ mdaEPiano::mdaEPiano() // mdaEPiano::mdaEPiano(audioMasterCallback audioMaster)
//initialise...
reset_voices();
curProgram = 0;
}
void mdaEPiano::reset_voices(void) // reset all voices
@ -124,15 +127,15 @@ void mdaEPiano::reset_voices(void) // reset all voices
tl = tr = lfo0 = dlfo = 0.0f;
lfo1 = 1.0f;
//guiUpdate = 0;
vol = VOLUME;
update();
// suspend();
}
void mdaEPiano::update() //parameter change
{
float * param = programs[curProgram].param;
float * param = programs[ 0].param;
size = (int32_t)(12.0f * param[2] - 6.0f);
treb = 4.0f * param[3] * param[3] - 1.0f; //treble gain
@ -159,7 +162,7 @@ void mdaEPiano::resume()
{
Fs = SAMPLE_RATE;
iFs = 1.0f / Fs;
dlfo = 6.283f * iFs * (float)exp(6.22f * programs[curProgram].param[5] - 2.61f); //lfo rate
dlfo = 6.283f * iFs * (float)exp(6.22f * programs[ 0].param[5] - 2.61f); //lfo rate
}
@ -168,38 +171,76 @@ mdaEPiano::~mdaEPiano () //destroy any buffers...
if (programs) delete [] programs;
}
/*
void mdaEPiano::setProgram(int32_t program)
{
curProgram = program;
update();
}
*/
void mdaEPiano::setDecay(float value)
{
setParameter(MDA_EP_DECAY, value);
}
void mdaEPiano::setParameter(int32_t index, float value)
void mdaEPiano::setRelease(float value)
{
programs[curProgram].param[index] = value;
update();
setParameter(MDA_EP_RELEASE, value);
}
void mdaEPiano::setHardness(float value)
{
setParameter(MDA_EP_HARDNESS, value);
}
void mdaEPiano::fillpatch(int32_t p, char *name, float p0, float p1, float p2, float p3, float p4,
float p5, float p6, float p7, float p8, float p9, float p10, float p11)
void mdaEPiano::setTreble(float value)
{
strcpy(programs[p].name, name);
programs[p].param[0] = p0; programs[p].param[1] = p1;
programs[p].param[2] = p2; programs[p].param[3] = p3;
programs[p].param[4] = p4; programs[p].param[5] = p5;
programs[p].param[6] = p6; programs[p].param[7] = p7;
programs[p].param[8] = p8; programs[p].param[9] = p9;
programs[p].param[10] = p10; programs[p].param[11] = p11;
setParameter(MDA_EP_TREBLE, value);
}
/*
float mdaEPiano::getParameter(int32_t index) {
return programs[curProgram].param[index];
}
*/
void mdaEPiano::setPanTremolo(float value)
{
setParameter(MDA_EP_PAN_TREM, value);
}
void mdaEPiano::setPanLFO(float value)
{
setParameter(MDA_EP_LFO_RATE, value);
}
void mdaEPiano::setVelocitySense(float value)
{
setParameter(MDA_EP_VELOCITY_SENSE, value);
}
void mdaEPiano::setStereo(float value)
{
setParameter(MDA_EP_STEREO, value);
}
void mdaEPiano::setMaxPolyphony(uint8_t value)
{
max_polyphony = value;
}
void mdaEPiano::setTune(float value)
{
setParameter(MDA_EP_TUNE, value);
}
void mdaEPiano::setDetune(float value)
{
setParameter(MDA_EP_DETUNE, value);
}
void mdaEPiano::setOverdrive(float value)
{
setParameter(MDA_EP_OVERDRIVE, value);
}
void mdaEPiano::setParameter(int32_t index, float value)
{
programs[ 0].param[index] = value;
update();
}
int32_t mdaEPiano::getActiveVoices(void)
{
return (activevoices);
}
void mdaEPiano::process(int16_t* outputs_r, int16_t* outputs_l)
{
@ -269,13 +310,13 @@ void mdaEPiano::process(int16_t* outputs_r, int16_t* outputs_l)
void mdaEPiano::noteOn(int32_t note, int32_t velocity)
{
float * param = programs[curProgram].param;
float * param = programs[ 0].param;
float l = 99.0f;
int32_t v, vl = 0, k, s;
if (velocity > 0)
{
if (activevoices < configuration.max_poly) //add a note
if (activevoices < max_polyphony) //add a note
{
vl = activevoices;
activevoices++;
@ -283,7 +324,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity)
}
else //steal a note
{
for (v = 0; v < configuration.max_poly; v++) //find quietest voice
for (v = 0; v < max_polyphony; v++) //find quietest voice
{
if (voice[v].env < l) {
l = voice[v].env;
@ -333,7 +374,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity)
}
else //note off
{
for (v = 0; v < configuration.max_poly; v++) if (voice[v].note == note) //any voices playing that note?
for (v = 0; v < max_polyphony; v++) if (voice[v].note == note) //any voices playing that note?
{
if (sustain == 0)
{
@ -346,7 +387,7 @@ void mdaEPiano::noteOn(int32_t note, int32_t velocity)
bool mdaEPiano::processMidiController(uint8_t data1, uint8_t data2)
{
float* param = programs[curProgram].param;
float* param = programs[ 0].param;
switch (data1)
{
@ -375,7 +416,7 @@ bool mdaEPiano::processMidiController(uint8_t data1, uint8_t data2)
default: //all notes off
if (data1 > 0x7A)
{
for (int32_t v = 0; v < configuration.max_poly; v++) voice[v].dec = 0.99f;
for (int32_t v = 0; v < max_polyphony; v++) voice[v].dec = 0.99f;
sustain = 0;
muff = 160.0f;
}

@ -34,14 +34,25 @@
#define SILENCE 0.0001f //voice choking
#define WAVELEN 422414 //wave data bytes
extern config_t configuration;
// MDAEPiano parameter mapping
#define MDA_EP_DECAY 0
#define MDA_EP_RELEASE 1
#define MDA_EP_HARDNESS 2
#define MDA_EP_TREBLE 3
#define MDA_EP_PAN_TREM 4
#define MDA_EP_LFO_RATE 5
#define MDA_EP_VELOCITY_SENSE 6
#define MDA_EP_STEREO 7
#define MDA_EP_MAX_POLY 8
#define MDA_EP_TUNE 9
#define MDA_EP_DETUNE 10
#define MDA_EP_OVERDRIVE 11
class mdaEPianoProgram
{
friend class mdaEPiano;
private:
float param[NPARAMS];
char name[24];
};
struct VOICE //voice state
@ -84,23 +95,34 @@ class mdaEPiano
void noteOn(int32_t note, int32_t velocity);
virtual bool processMidiController(uint8_t data1, uint8_t data2);
//virtual void setProgram(int32_t program);
virtual void setParameter(int32_t index, float value);
//virtual float getParameter(int32_t index);
virtual void resume();
void reset_voices(void);
//int32_t guiUpdate;
//void guiGetDisplay(int32_t index, char *label);
void setDecay(float value);
void setRelease(float value);
void setHardness(float value);
void setTreble(float value);
void setPanTremolo(float value);
void setPanLFO(float value);
void setVelocitySense(float value);
void setStereo(float value);
void setMaxPolyphony(uint8_t value);
void setTune(float value);
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,
float p5, float p6, float p7, float p8, float p9, float p10, float p11);
void setParameter(int32_t index, float value);
mdaEPianoProgram* programs;
float Fs, iFs;
///global internal variables
uint8_t max_polyphony;
KGRP kgrp[34];
VOICE voice[NVOICES];
int32_t activevoices;
@ -112,7 +134,7 @@ class mdaEPiano
float tune, fine, random, stretch, overdrive;
float muff, muffvel, sizevel, velsens, volume, modwhl;
float vol;
uint8_t curProgram;
//uint8_t curProgram;
};
#endif

Loading…
Cancel
Save