Save the current state.

Added default configuration an some additions for changing values via menus.
master
Holger Wirtz 6 years ago
parent 27b2e96664
commit 60bbe39472
  1. BIN
      .swp
  2. 99
      MicroMDAEPiano.ino
  3. 473
      UI.hpp
  4. 189
      config.h
  5. 4
      mdaEPiano.cpp

BIN
.swp

Binary file not shown.

@ -89,46 +89,6 @@ mdaEPiano* ep;
extern void init_menus(void); extern void init_menus(void);
extern int32_t encoder_value[NUM_ENCODER]; extern int32_t encoder_value[NUM_ENCODER];
// vars fot menus
uint8_t sound = 1;
//
uint8_t decay = 0;
uint8_t release = 0;
uint8_t hardness = 0;
uint8_t treble = 0;
int8_t stereo = 0;
int8_t transpose = 0;
int8_t tune = 0;
uint8_t detune = 0;
uint8_t velocity_sense = 0;
//
uint8_t pan_trem_frequency = 0; // LFO
uint8_t pan_trem_level = 0;
uint8_t overdrive = 0;
uint8_t comp_gain = 0;
uint8_t comp_response = 0;
uint8_t comp_limit = 0;
uint8_t comp_threshold = 0;
uint8_t comp_attack = 0;
uint8_t comp_decay = 0;
uint8_t reverb_roomsize = 0;
uint8_t reverb_damping = 0;
uint8_t reverb_level = 0;
uint8_t chorus_frequency = 0; // LFO
uint8_t chorus_delay = 0;
uint8_t chorus_level = 0;
uint8_t bass_lr_level = 0;
uint8_t bass_mono_level = 0;
uint8_t eq_bass = 0;
uint8_t eq_treble = 0;
//
uint8_t loudness = 80;
uint8_t midi_channel = DEFAULT_MIDI_CHANNEL;
uint8_t midi_soft_thru = 1;
uint8_t max_poly = 32;
//
uint8_t master_volume = 99;
// more variables // more variables
uint32_t xrun = 0; uint32_t xrun = 0;
uint32_t overload = 0; uint32_t overload = 0;
@ -138,13 +98,48 @@ elapsedMicros fill_audio_buffer;
elapsedMillis control_rate; elapsedMillis control_rate;
elapsedMillis autostore; elapsedMillis autostore;
const uint16_t audio_block_time_us = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES); const uint16_t audio_block_time_us = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES);
config_t configuration = {0xffff, 0, VOLUME, 0.5f, DEFAULT_MIDI_CHANNEL}; config_t configuration = {
0xffff, // checksum
1, // sound
ENC_DECAY_DEFAULT, // decay
ENC_RELEASE_DEFAULT, //release
ENC_HARDNESS_DEFAULT, // hardness
ENC_TREBLE_DEFAULT, // treble
ENC_STEREO_DEFAULT, // stereo
ENC_TRANSPOSE_DEFAULT,// transpose
ENC_TUNE_DEFAULT, // tune
ENC_DETUNE_DEFAULT, // detune
ENC_VELOCITY_SENSE_DEFAULT, // velocity_sense
ENC_PAN_TREM_FREQUENCY_DEFAULT,// pan_trem_frequency
ENC_PAN_TREM_LEVEL_DEFAULT, // pan_trem_level
ENC_OVERDRIVE_DEFAULT, // overdrive
ENC_COMP_GAIN_DEFAULT, // comp_gain
ENC_COMP_RESPONSE_DEFAULT, // comp_response
ENC_COMP_LIMIT_DEFAULT, // comp_limit
ENC_COMP_THRESHOLD_DEFAULT, // comp_threshold
ENC_COMP_ATTACK_DEFAULT, // comp_attack
ENC_COMP_DECAY_DEFAULT, // comp_decay
ENC_REVERB_ROOMSIZE_DEFAULT,// reverb_roomsize
ENC_REVERB_DAMPING_DEFAULT, // reverb_damping
ENC_REVERB_LEVEL_DEFAULT, // reverb_level
ENC_CHORUS_FREQUENCY_DEFAULT,// chorus_frequency
ENC_CHORUS_DELAY_DEFAULT, // chorus_delay
ENC_CHORUS_LEVEL_DEFAULT, // chorus_level
ENC_BASS_LR_LEVEL_DEFAULT, // bass_lr_level
ENC_BASS_MONO_LEVEL_DEFAULT,// bass_mono_level
ENC_EQ_BASS_DEFAULT, // eq_bass
ENC_EQ_TREBLE_DEFAULT, // eq_treble
ENC_LOUDNESS_DEFAULT, // loudness
ENC_MIDI_CHANNEL_DEFAULT, // midi_channel
ENC_MIDI_CHANNEL_DEFAULT, // midi_soft_thru
ENC_MAX_POLY_DEFAULT // max_poly
};
bool eeprom_update_flag = false; bool eeprom_update_flag = false;
#ifdef SHOW_CPU_LOAD_MSEC #ifdef SHOW_CPU_LOAD_MSEC
elapsedMillis cpu_mem_millis; elapsedMillis cpu_mem_millis;
#endif #endif
enum MDA_EP_PARAM { MDA_EP_DECAY, MDA_EP_RELEASE, MDA_EP_HARDNESS, MDA_EP_TREBLE, MDA_EP_PAN_TREM, MDA_EP_LFO_RATE, MDA_EP_VELOCITY_SENSE, MDA_EP_STEREO, MDA_EP_MAX_POLY, MDA_EP_TUNE, MDA_EP_DETUNE, MDA_EP_OVERDRIVE };
//************************************************************************************************* //*************************************************************************************************
//* SETUP FUNCTION //* SETUP FUNCTION
@ -152,8 +147,6 @@ enum MDA_EP_PARAM { MDA_EP_DECAY, MDA_EP_RELEASE, MDA_EP_HARDNESS, MDA_EP_TREBLE
void setup() void setup()
{ {
//while (!Serial) ; // wait for Arduino Serial Monitor
pinMode(BUT_L_PIN, INPUT_PULLUP); pinMode(BUT_L_PIN, INPUT_PULLUP);
pinMode(BUT_R_PIN, INPUT_PULLUP); pinMode(BUT_R_PIN, INPUT_PULLUP);
@ -337,7 +330,7 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
{ {
if (checkMidiChannel(inChannel)) if (checkMidiChannel(inChannel))
{ {
ep->noteOn(inNumber, inVelocity); ep->noteOn(inNumber + configuration.transpose, inVelocity);
} }
} }
@ -345,7 +338,7 @@ void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity)
{ {
if (checkMidiChannel(inChannel)) if (checkMidiChannel(inChannel))
{ {
ep->noteOn(inNumber, 0); ep->noteOn(inNumber + configuration.transpose, 0);
} }
} }
@ -440,17 +433,17 @@ void handleRealTimeSystem(void)
bool checkMidiChannel(byte inChannel) bool checkMidiChannel(byte inChannel)
{ {
// check for MIDI channel // check for MIDI channel
if (midi_channel == MIDI_CHANNEL_OMNI) if (configuration.midi_channel == MIDI_CHANNEL_OMNI)
{ {
return (true); return (true);
} }
else if (inChannel != midi_channel) else if (inChannel != configuration.midi_channel)
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Ignoring MIDI data on channel ")); Serial.print(F("Ignoring MIDI data on channel "));
Serial.print(inChannel); Serial.print(inChannel);
Serial.print(F("(listening on ")); Serial.print(F("(listening on "));
Serial.print(midi_channel); Serial.print(configuration.midi_channel);
Serial.println(F(")")); Serial.println(F(")"));
#endif #endif
return (false); return (false);
@ -460,21 +453,21 @@ bool checkMidiChannel(byte inChannel)
void set_volume(float v, float p) void set_volume(float v, float p)
{ {
configuration.vol = v; configuration.loudness = v;
configuration.pan = p; configuration.pan = p;
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Setting volume: VOL=")); Serial.print(F("Setting volume: VOL="));
Serial.print(v, DEC); Serial.print(v, DEC);
Serial.print(F("[")); Serial.print(F("["));
Serial.print(configuration.vol, DEC); Serial.print(configuration.loudness, DEC);
Serial.print(F("] PAN=")); Serial.print(F("] PAN="));
Serial.print(F("[")); Serial.print(F("["));
Serial.print(configuration.pan, DEC); Serial.print(configuration.pan, DEC);
Serial.print(F("] ")); Serial.print(F("] "));
Serial.print(pow(configuration.vol * sinf(configuration.pan * PI / 2), VOLUME_CURVE), 3); Serial.print(pow(configuration.loudness * sinf(configuration.pan * PI / 2), VOLUME_CURVE), 3);
Serial.print(F("/")); Serial.print(F("/"));
Serial.println(pow(configuration.vol * cosf( configuration.pan * PI / 2), VOLUME_CURVE), 3); Serial.println(pow(configuration.loudness * cosf( configuration.pan * PI / 2), VOLUME_CURVE), 3);
#endif #endif
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html // http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html

473
UI.hpp

File diff suppressed because it is too large Load Diff

@ -112,7 +112,158 @@
//************************************************************************************************* //*************************************************************************************************
#define CONTROL_RATE_MS 100 #define CONTROL_RATE_MS 100
#define BACK_TO_MAIN_MS 500 #define BACK_TO_MAIN_MS 800
// Encoder min/max values
#define ENC_DECAY_MIN 0
#define ENC_DECAY_MAX 99
#define ENC_DECAY_DEFAULT 49
//
#define ENC_RELEASE_MIN 0
#define ENC_RELEASE_MAX 99
#define ENC_RELEASE_DEFAULT 49
//
#define ENC_HARDNESS_MIN 0
#define ENC_HARDNESS_MAX 99
#define ENC_HARDNESS_DEFAULT 49
//
#define ENC_TREBLE_MIN 0
#define ENC_TREBLE_MAX 99
#define ENC_TREBLE_DEFAULT 49
//
#define ENC_STEREO_MIN 0
#define ENC_STEREO_MAX 99
#define ENC_STEREO_DEFAULT 64
//
#define ENC_TRANSPOSE_MIN -24
#define ENC_TRANSPOSE_MAX 24
#define ENC_TRANSPOSE_DEFAULT 0
//
#define ENC_TUNE_MIN 0
#define ENC_TUNE_MAX 99
#define ENC_TUNE_DEFAULT 49
//
#define ENC_DETUNE_MIN 0
#define ENC_DETUNE_MAX 99
#define ENC_DETUNE_DEFAULT 14
//
#define ENC_VELOCITY_SENSE_MIN 0
#define ENC_VELOCITY_SENSE_MAX 99
#define ENC_VELOCITY_SENSE_DEFAULT 24
//
#define ENC_PAN_TREM_FREQUENCY_MIN 0
#define ENC_PAN_TREM_FREQUENCY_MAX 99
#define ENC_PAN_TREM_FREQUENCY_DEFAULT 50
//
#define ENC_PAN_TREM_LEVEL_MIN 0
#define ENC_PAN_TREM_LEVEL_MAX 99
#define ENC_PAN_TREM_LEVEL_DEFAULT 50
//
#define ENC_OVERDRIVE_MIN 0
#define ENC_OVERDRIVE_MAX 99
#define ENC_OVERDRIVE_DEFAULT 50
//
#define ENC_COMP_GAIN_MIN 0
#define ENC_COMP_GAIN_MAX 99
#define ENC_COMP_GAIN_DEFAULT 50
//
#define ENC_COMP_RESPONSE_MIN 0
#define ENC_COMP_RESPONSE_MAX 99
#define ENC_COMP_RESPONSE_DEFAULT 50
//
#define ENC_COMP_LIMIT_MIN 0
#define ENC_COMP_LIMIT_MAX 99
#define ENC_COMP_LIMIT_DEFAULT 50
//
#define ENC_COMP_THRESHOLD_MIN 0
#define ENC_COMP_THRESHOLD_MAX 99
#define ENC_COMP_THRESHOLD_DEFAULT 50
//
#define ENC_COMP_ATTACK_MIN 0
#define ENC_COMP_ATTACK_MAX 99
#define ENC_COMP_ATTACK_DEFAULT 50
//
#define ENC_COMP_DECAY_MIN 0
#define ENC_COMP_DECAY_MAX 99
#define ENC_COMP_DECAY_DEFAULT 50
//
#define ENC_REVERB_ROOMSIZE_MIN 0
#define ENC_REVERB_ROOMSIZE_MAX 99
#define ENC_REVERB_ROOMSIZE_DEFAULT 50
//
#define ENC_REVERB_DAMPING_MIN 0
#define ENC_REVERB_DAMPING_MAX 99
#define ENC_REVERB_DAMPING_DEFAULT 50
//
#define ENC_REVERB_LEVEL_MIN 0
#define ENC_REVERB_LEVEL_MAX 99
#define ENC_REVERB_LEVEL_DEFAULT 50
//
#define ENC_CHORUS_FREQUENCY_MIN 0
#define ENC_CHORUS_FREQUENCY_MAX 20
#define ENC_CHORUS_FREQUENCY_DEFAULT 3
//
#define ENC_CHORUS_DELAY_MIN 0
#define ENC_CHORUS_DELAY_MAX 20
#define ENC_CHORUS_DELAY_DEFAULT 15
//
#define ENC_CHORUS_LEVEL_MIN 0
#define ENC_CHORUS_LEVEL_MAX 99
#define ENC_CHORUS_LEVEL_DEFAULT 50
//
#define ENC_BASS_LR_LEVEL_MIN 0
#define ENC_BASS_LR_LEVEL_MAX 99
#define ENC_BASS_LR_LEVEL_DEFAULT 50
//
#define ENC_BASS_MONO_LEVEL_MIN 0
#define ENC_BASS_MONO_LEVEL_MAX 99
#define ENC_BASS_MONO_LEVEL_DEFAULT 50
//
#define ENC_EQ_BASS_MIN 0
#define ENC_EQ_BASS_MAX 99
#define ENC_EQ_BASS_DEFAULT 50
//
#define ENC_EQ_TREBLE_MIN 0
#define ENC_EQ_TREBLE_MAX 99
#define ENC_EQ_TREBLE_DEFAULT 50
//
#define ENC_LOUDNESS_MIN 0
#define ENC_LOUDNESS_MAX 99
#define ENC_LOUDNESS_DEFAULT 80
//
#define ENC_MIDI_CHANNEL_MIN 0
#define ENC_MIDI_CHANNEL_MAX 16
#define ENC_MIDI_CHANNEL_DEFAULT DEFAULT_MIDI_CHANNEL
//
#define ENC_MIDI_SOFT_THRU_MIN 0
#define ENC_MIDI_SOFT_THRU_MAX 1
#define ENC_MIDI_SOFT_THRU_DEFAULT 1
//
#define ENC_MAX_POLY_MIN 1
#define ENC_MAX_POLY_MAX 32
#define ENC_MAX_POLY_DEFAULT 32
//
#define ENC_MASTER_VOLUME_MIN 0
#define ENC_MASTER_VOLUME_MAX 99
#define ENC_MASTER_VOLUME_DEFAULT 80
//
#define ENC_MASTER_PAN_MIN -20
#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 // MIDI
#ifdef MIDI_DEVICE_USB #ifdef MIDI_DEVICE_USB
@ -136,10 +287,40 @@
// struct for holding the current configuration // struct for holding the current configuration
struct config_t { struct config_t {
uint32_t checksum; uint32_t checksum;
uint8_t voice; uint8_t sound;
float vol; uint8_t decay;
float pan; uint8_t release;
uint8_t hardness;
uint8_t treble;
int8_t stereo;
int8_t transpose;
int8_t tune;
uint8_t detune;
uint8_t velocity_sense;
uint8_t pan_trem_frequency;
uint8_t pan_trem_level;
uint8_t overdrive;
uint8_t comp_gain;
uint8_t comp_response;
uint8_t comp_limit;
uint8_t comp_threshold;
uint8_t comp_attack;
uint8_t comp_decay;
uint8_t reverb_roomsize;
uint8_t reverb_damping;
uint8_t reverb_level;
uint8_t chorus_frequency;
uint8_t chorus_delay;
uint8_t chorus_level;
uint8_t bass_lr_level;
uint8_t bass_mono_level;
uint8_t eq_bass;
uint8_t eq_treble;
uint8_t loudness;
uint8_t midi_channel; uint8_t midi_channel;
uint8_t midi_soft_thru;
uint8_t max_poly;
int8_t pan;
}; };
#endif #endif

@ -240,8 +240,8 @@ void mdaEPiano::process(int16_t* outputs_r, int16_t* outputs_l)
l = 1.0; l = 1.0;
else if (l < -1.0) else if (l < -1.0)
l = -1.0; l = -1.0;
outputs_l[frame] = static_cast<int16_t>(l * configuration.vol * 0x7fff) >> REDUCE_LOUDNESS; outputs_l[frame] = static_cast<int16_t>(l * configuration.loudness * 0x7fff) >> REDUCE_LOUDNESS;
outputs_r[frame] = static_cast<int16_t>(r * configuration.vol * 0x7fff) >> REDUCE_LOUDNESS; outputs_r[frame] = static_cast<int16_t>(r * configuration.loudness * 0x7fff) >> REDUCE_LOUDNESS;
} }
if (fabs(tl) < 1.0e-10) tl = 0.0f; //anti-denormal if (fabs(tl) < 1.0e-10) tl = 0.0f; //anti-denormal

Loading…
Cancel
Save