|
|
@ -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
|
|
|
|