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