|
|
|
@ -263,9 +263,12 @@ void setup() |
|
|
|
|
#ifdef ENABLE_LCD_UI |
|
|
|
|
setup_ui(); |
|
|
|
|
#else |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("NO LCD DISPLAY ENABLED!")); |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("MicroDexed based on https://github.com/asb2m10/dexed")); |
|
|
|
|
Serial.println(F("(c)2018-2020 H. Wirtz <wirtz@parasitstudio.de>")); |
|
|
|
|
Serial.println(F("https://codeberg.org/dcoredump/MicroDexed")); |
|
|
|
@ -276,6 +279,7 @@ void setup() |
|
|
|
|
Serial.println(F(" MHz")); |
|
|
|
|
Serial.println(F("<setup start>")); |
|
|
|
|
Serial.flush(); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
setup_midi_devices(); |
|
|
|
|
|
|
|
|
@ -283,8 +287,10 @@ void setup() |
|
|
|
|
{ |
|
|
|
|
if (instance_id < MAX_DEXED) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Creating MicroDexed instance ")); |
|
|
|
|
Serial.println(instance_id, DEC); |
|
|
|
|
#endif |
|
|
|
|
MicroDexed[instance_id] = new AudioSourceMicroDexed(SAMPLE_RATE); |
|
|
|
|
dexed_level[instance_id] = new AudioAmplifier(); |
|
|
|
|
mono2stereo[instance_id] = new AudioEffectMonoStereo(); |
|
|
|
@ -292,11 +298,13 @@ void setup() |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Ignoring instance ")); |
|
|
|
|
Serial.print(instance_id, DEC); |
|
|
|
|
Serial.print(F(" (maximum allowed: ")); |
|
|
|
|
Serial.print(MAX_DEXED, DEC); |
|
|
|
|
Serial.println(F(")")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -304,7 +312,9 @@ void setup() |
|
|
|
|
// Init EEPROM if both buttons are pressed at startup
|
|
|
|
|
if (digitalRead(BUT_R_PIN) == HIGH && digitalRead(BUT_L_PIN) == HIGH) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Init EEPROM")); |
|
|
|
|
#endif |
|
|
|
|
lcd.clear(); |
|
|
|
|
lcd.setCursor(0, 0); |
|
|
|
|
lcd.print(F("INIT")); |
|
|
|
@ -350,20 +360,32 @@ void setup() |
|
|
|
|
6 225Hz |
|
|
|
|
*/ |
|
|
|
|
//sgtl5000_1.eqBands(bass, mid_bass, midrange, mid_treble, treble);
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Teensy-Audio-Board enabled.")); |
|
|
|
|
#endif |
|
|
|
|
#elif defined(TGA_AUDIO_BOARD) |
|
|
|
|
wm8731_1.enable(); |
|
|
|
|
wm8731_1.volume(1.0); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("TGA board enabled.")); |
|
|
|
|
#endif |
|
|
|
|
#elif defined(I2S_AUDIO_ONLY) |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("I2S enabled.")); |
|
|
|
|
#endif |
|
|
|
|
#elif defined(PT8211_AUDIO) |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("PT8211 enabled.")); |
|
|
|
|
#endif |
|
|
|
|
#elif defined(TEENSY_DAC_SYMMETRIC) |
|
|
|
|
invMixer.gain(0, -1.f); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Internal DAC using symmetric outputs enabled.")); |
|
|
|
|
#endif |
|
|
|
|
#else |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Internal DAC enabled.")); |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// start SD card
|
|
|
|
@ -376,7 +398,9 @@ void setup() |
|
|
|
|
#endif |
|
|
|
|
if (!SD.begin(SDCARD_CS_PIN)) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("SD card not accessable.")); |
|
|
|
|
#endif |
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
|
{ |
|
|
|
|
strcpy(bank_name[instance_id], "Default"); |
|
|
|
@ -385,7 +409,9 @@ void setup() |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("SD card found.")); |
|
|
|
|
#endif |
|
|
|
|
sd_card_available = true; |
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
|
{ |
|
|
|
@ -426,12 +452,16 @@ void setup() |
|
|
|
|
// Init effects
|
|
|
|
|
memset(delayline_r, 0, sizeof(delayline_r)); |
|
|
|
|
if (!modchorus_r.begin(delayline_r, MOD_DELAY_SAMPLE_BUFFER)) { |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("AudioEffectModulatedDelay - begin failed (R)")); |
|
|
|
|
#endif |
|
|
|
|
while (1); |
|
|
|
|
} |
|
|
|
|
memset(delayline_l, 0, sizeof(delayline_l)); |
|
|
|
|
if (!modchorus_l.begin(delayline_l, MOD_DELAY_SAMPLE_BUFFER)) { |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("AudioEffectModulatedDelay - begin failed (L)")); |
|
|
|
|
#endif |
|
|
|
|
while (1); |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
@ -549,6 +579,7 @@ void setup() |
|
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
|
{ |
|
|
|
|
Serial.print(F("Dexed instance ")); |
|
|
|
@ -561,9 +592,7 @@ void setup() |
|
|
|
|
Serial.println(F("]")); |
|
|
|
|
Serial.print(F("Polyphony: ")); |
|
|
|
|
Serial.println(configuration.dexed[instance_id].polyphony, DEC); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
show_patch(instance_id); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Serial.print(F("AUDIO_BLOCK_SAMPLES=")); |
|
|
|
@ -571,6 +600,7 @@ void setup() |
|
|
|
|
Serial.print(F(" (Time per block=")); |
|
|
|
|
Serial.print(1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES)); |
|
|
|
|
Serial.println(F("ms)")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
show_cpu_and_mem_usage(); |
|
|
|
@ -578,7 +608,9 @@ void setup() |
|
|
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("<setup end>")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void loop() |
|
|
|
@ -620,11 +652,13 @@ void loop() |
|
|
|
|
cpu_overload_throttle_timer = 0; |
|
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
|
MicroDexed[instance_id]->keyup(-1); // kills the oldest note and decreases max_notes
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("!!!CPU overload!!! Automatic throttling polyphony down to ")); |
|
|
|
|
Serial.print(MicroDexed[instance_id]->getMaxNotes(), DEC); |
|
|
|
|
Serial.print(F(" for instance ")); |
|
|
|
|
Serial.print(instance_id, DEC); |
|
|
|
|
Serial.println(F(".")); |
|
|
|
|
#endif |
|
|
|
|
configuration.dexed[instance_id].polyphony = MicroDexed[instance_id]->getMaxNotes(); |
|
|
|
|
eeprom_update(); // useful to do this???
|
|
|
|
|
} |
|
|
|
@ -1278,19 +1312,25 @@ void initial_values_from_eeprom(bool init) |
|
|
|
|
init_configuration(); |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Loading inital data from EEPROM.")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
EEPROM.get(EEPROM_START_ADDRESS, tmp_conf); |
|
|
|
|
checksum = crc32((byte*)&tmp_conf + 4, sizeof(tmp_conf) - 4); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("EEPROM checksum: 0x")); |
|
|
|
|
Serial.print(tmp_conf.checksum, HEX); |
|
|
|
|
Serial.print(F(" / 0x")); |
|
|
|
|
Serial.println(checksum, HEX); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (checksum != tmp_conf.checksum) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Checksum mismatch -> initializing EEPROM!")); |
|
|
|
|
#endif |
|
|
|
|
init_configuration(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
@ -1328,7 +1368,9 @@ void initial_values_from_eeprom(bool init) |
|
|
|
|
dexed_level[instance_id]->gain(mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("OK, loaded!")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
master_mixer_r.gain(DEXED, 1.0); |
|
|
|
|
master_mixer_l.gain(DEXED, 1.0); |
|
|
|
@ -1500,8 +1542,8 @@ void eeprom_update(void) |
|
|
|
|
eeprom_update_flag = false; |
|
|
|
|
configuration.checksum = crc32((byte*)&configuration + 4, sizeof(configuration) - 4); |
|
|
|
|
EEPROM.put(EEPROM_START_ADDRESS, configuration); |
|
|
|
|
Serial.println(F("Updating EEPROM")); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Updating EEPROM")); |
|
|
|
|
show_configuration(); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
@ -1550,8 +1592,11 @@ void show_cpu_and_mem_usage(void) |
|
|
|
|
if (AudioProcessorUsageMax() > 99.9) |
|
|
|
|
{ |
|
|
|
|
cpumax++; |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("*")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
else |
|
|
|
|
Serial.print(F(" ")); |
|
|
|
|
Serial.print(F("CPU:")); |
|
|
|
@ -1590,7 +1635,7 @@ void show_cpu_and_mem_usage(void) |
|
|
|
|
Serial.print(F(",")); |
|
|
|
|
} |
|
|
|
|
Serial.println(); |
|
|
|
|
Serial.flush(); |
|
|
|
|
#endif |
|
|
|
|
AudioProcessorUsageMaxReset(); |
|
|
|
|
AudioMemoryUsageMaxReset(); |
|
|
|
|
} |
|
|
|
|