|
|
|
@ -54,8 +54,8 @@ AudioMixer4 mixer_r; |
|
|
|
|
AudioMixer4 mixer_l; |
|
|
|
|
AudioAmplifier volume_r; |
|
|
|
|
AudioAmplifier volume_l; |
|
|
|
|
AudioModulatedEffectChorus modchorus_r; |
|
|
|
|
AudioModulatedEffectChorus modchorus_l; |
|
|
|
|
AudioEffectModulatedDelay modchorus_r; |
|
|
|
|
AudioEffectModulatedDelay modchorus_l; |
|
|
|
|
AudioSynthWaveform modulator; |
|
|
|
|
AudioConnection patchCord0(queue_r, peak_r); |
|
|
|
|
AudioConnection patchCord1(queue_l, peak_l); |
|
|
|
@ -183,7 +183,7 @@ void setup() |
|
|
|
|
// create EPiano object
|
|
|
|
|
ep = new mdaEPiano(); |
|
|
|
|
|
|
|
|
|
//set_complete_configuration();
|
|
|
|
|
set_complete_configuration(); |
|
|
|
|
initial_values_from_eeprom(); |
|
|
|
|
|
|
|
|
|
setup_midi_devices(); |
|
|
|
@ -213,46 +213,44 @@ void setup() |
|
|
|
|
Serial.println(F("PT8211 enabled.")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// set master volume
|
|
|
|
|
set_master_volume(master_volume); |
|
|
|
|
|
|
|
|
|
// internal mixing of original signal(0), reverb(1) and chorus(2)
|
|
|
|
|
mixer_r.gain(0, 1.0); |
|
|
|
|
mixer_l.gain(0, 1.0); |
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
// Initialize processor and memory measurements
|
|
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
Serial.print(F("AUDIO_BLOCK_SAMPLES=")); |
|
|
|
|
Serial.print(AUDIO_BLOCK_SAMPLES); |
|
|
|
|
Serial.print(F(" (Time per block=")); |
|
|
|
|
Serial.print(audio_block_time_us); |
|
|
|
|
Serial.println(F("ms)")); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if (!modchorus_r.begin(r_delayline, CHORUS_DELAY_LENGTH)) { |
|
|
|
|
Serial.println(F("AudioModulatedEffectChorus - right channel begin failed")); |
|
|
|
|
Serial.println(F("AudioEffectModulatedDelay - right channel begin failed")); |
|
|
|
|
while (1); |
|
|
|
|
} |
|
|
|
|
if (!modchorus_l.begin(l_delayline, CHORUS_DELAY_LENGTH)) { |
|
|
|
|
Serial.println(F("AudioModulatedEffectChorus - left channel begin failed")); |
|
|
|
|
Serial.println(F("AudioEffectModulatedDelay - left channel begin failed")); |
|
|
|
|
while (1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// chorus modulation fixed
|
|
|
|
|
memset(r_delayline, 0, sizeof(short)*CHORUS_DELAY_LENGTH); |
|
|
|
|
memset(l_delayline, 0, sizeof(short)*CHORUS_DELAY_LENGTH); |
|
|
|
|
modulator.begin(CHORUS_WAVEFORM); |
|
|
|
|
modulator.amplitude(0.1); |
|
|
|
|
modulator.frequency(1.0); |
|
|
|
|
modulator.phase(0); |
|
|
|
|
// chorus level fixed
|
|
|
|
|
*/ |
|
|
|
|
// internal mixing of original signal(0), reverb(1) and chorus(2)
|
|
|
|
|
mixer_r.gain(0, 1.0); |
|
|
|
|
mixer_l.gain(0, 1.0); |
|
|
|
|
mixer_r.gain(2, 0.5); |
|
|
|
|
mixer_l.gain(2, 0.5); |
|
|
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
// set master volume
|
|
|
|
|
set_master_volume(master_volume); |
|
|
|
|
|
|
|
|
|
Serial.println(F("<setup end>")); |
|
|
|
|
|
|
|
|
@ -534,7 +532,11 @@ void config_from_eeprom(void) |
|
|
|
|
checksum = crc32((byte*)&tmp_conf + 4, sizeof(tmp_conf) - 4); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("EEPROM checksum: 0x")); |
|
|
|
|
Serial.print(F("Reading sound ")); |
|
|
|
|
Serial.print(sound, DEC); |
|
|
|
|
Serial.print(F(" from 0x")); |
|
|
|
|
Serial.print(EEPROM_CONFIGURATIONS + sizeof(config_t) * (sound - 1), HEX); |
|
|
|
|
Serial.print(F(" EEPROM checksum: 0x")); |
|
|
|
|
Serial.print(tmp_conf.checksum, HEX); |
|
|
|
|
Serial.print(F(" / 0x")); |
|
|
|
|
Serial.print(checksum, HEX); |
|
|
|
@ -543,8 +545,7 @@ void config_from_eeprom(void) |
|
|
|
|
if (checksum == tmp_conf.checksum) |
|
|
|
|
{ |
|
|
|
|
EEPROM_readAnything(EEPROM_CONFIGURATIONS + sizeof(config_t) * (sound - 1), configuration); |
|
|
|
|
Serial.print(F(" - OK -> loading sound.")); |
|
|
|
|
Serial.print(sound, DEC); |
|
|
|
|
Serial.print(F(" - OK")); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
@ -552,6 +553,7 @@ void config_from_eeprom(void) |
|
|
|
|
Serial.println(F(" - mismatch -> loading initial configuration.")); |
|
|
|
|
#endif |
|
|
|
|
set_complete_configuration(); |
|
|
|
|
EEPROM.update(EEPROM_SOUND, sound); |
|
|
|
|
} |
|
|
|
|
show_sound(); |
|
|
|
|
} |
|
|
|
@ -571,12 +573,15 @@ void eeprom_config_write(uint8_t value) |
|
|
|
|
void eeprom_config_update(void) |
|
|
|
|
{ |
|
|
|
|
configuration.checksum = crc32((byte*)&configuration + 4, sizeof(configuration) - 4); |
|
|
|
|
EEPROM_writeAnything(EEPROM_CONFIGURATIONS + sizeof(config_t) * (eeprom_config_update_flag - 1), configuration); |
|
|
|
|
Serial.print(F("Updating EEPROM configuration for sound ")); |
|
|
|
|
Serial.print(eeprom_config_update_flag, DEC); |
|
|
|
|
Serial.print(F(" with checksum 0x")); |
|
|
|
|
Serial.print(configuration.checksum, HEX); |
|
|
|
|
Serial.print(F(" at 0x")); |
|
|
|
|
Serial.println(EEPROM_CONFIGURATIONS + sizeof(config_t) * (eeprom_config_update_flag - 1), HEX); |
|
|
|
|
EEPROM_writeAnything(EEPROM_CONFIGURATIONS + sizeof(config_t) * (eeprom_config_update_flag - 1), configuration); |
|
|
|
|
eeprom_config_update_flag = 0; |
|
|
|
|
EEPROM.update(EEPROM_SOUND, sound); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void eeprom_master_volume_write(void) |
|
|
|
|