Every "Seria.print*" is now capsuled inside a "#ifdef DEBUG".

pull/32/head
Holger Wirtz 5 years ago
parent 4219e09854
commit 8b25e15925
  1. 53
      MicroDexed.ino
  2. 6
      midi_devices.hpp
  3. 2
      source_microdexed.h

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

@ -1591,7 +1591,9 @@ void setup_midi_devices(void)
midi_serial.setHandleActiveSensing(handleActiveSensing_MIDI_DEVICE_DIN); midi_serial.setHandleActiveSensing(handleActiveSensing_MIDI_DEVICE_DIN);
midi_serial.setHandleSystemReset(handleSystemReset_MIDI_DEVICE_DIN); midi_serial.setHandleSystemReset(handleSystemReset_MIDI_DEVICE_DIN);
//midi_serial.setHandleRealTimeSystem(handleRealTimeSystem_MIDI_DEVICE_DIN); //midi_serial.setHandleRealTimeSystem(handleRealTimeSystem_MIDI_DEVICE_DIN);
#ifdef DEBUG
Serial.println(F("MIDI_DEVICE_DIN enabled")); Serial.println(F("MIDI_DEVICE_DIN enabled"));
#endif
#endif #endif
// start up USB host // start up USB host
@ -1616,7 +1618,9 @@ void setup_midi_devices(void)
midi_usb.setHandleActiveSensing(handleActiveSensing_MIDI_DEVICE_USB_HOST); midi_usb.setHandleActiveSensing(handleActiveSensing_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleSystemReset(handleSystemReset_MIDI_DEVICE_USB_HOST); midi_usb.setHandleSystemReset(handleSystemReset_MIDI_DEVICE_USB_HOST);
//midi_usb.setHandleRealTimeSystem(handleRealTimeSystem_MIDI_DEVICE_USB_HOST); //midi_usb.setHandleRealTimeSystem(handleRealTimeSystem_MIDI_DEVICE_USB_HOST);
#ifdef DEBUG
Serial.println(F("MIDI_DEVICE_USB_HOST enabled.")); Serial.println(F("MIDI_DEVICE_USB_HOST enabled."));
#endif
#endif #endif
// check for onboard USB-MIDI // check for onboard USB-MIDI
@ -1641,8 +1645,10 @@ void setup_midi_devices(void)
usbMIDI.setHandleActiveSensing(handleActiveSensing_MIDI_DEVICE_USB); usbMIDI.setHandleActiveSensing(handleActiveSensing_MIDI_DEVICE_USB);
usbMIDI.setHandleSystemReset(handleSystemReset_MIDI_DEVICE_USB); usbMIDI.setHandleSystemReset(handleSystemReset_MIDI_DEVICE_USB);
//usbMIDI.setHandleRealTimeSystem(handleRealTimeSystem_MIDI_DEVICE_USB); //usbMIDI.setHandleRealTimeSystem(handleRealTimeSystem_MIDI_DEVICE_USB);
#ifdef DEBUG
Serial.println(F("MIDI_DEVICE_USB enabled.")); Serial.println(F("MIDI_DEVICE_USB enabled."));
#endif #endif
#endif
} }
void check_midi_devices(void) void check_midi_devices(void)

@ -28,7 +28,9 @@ class AudioSourceMicroDexed : public AudioStream, public Dexed {
if (render_time > audio_block_time_us) // everything greater 2.9ms is a buffer underrun! if (render_time > audio_block_time_us) // everything greater 2.9ms is a buffer underrun!
xrun++; xrun++;
/* if (render_time > audio_block_time_us - (audio_block_time_us / 10)) { /* if (render_time > audio_block_time_us - (audio_block_time_us / 10)) {
#ifdef DEBUG
Serial.println("At CPU Limit"); Serial.println("At CPU Limit");
#endif
uint8_t nnotes = getNumNotesPlaying(); uint8_t nnotes = getNumNotesPlaying();
//setMaxNotes(nnotes); //setMaxNotes(nnotes);
max_notes = nnotes; max_notes = nnotes;

Loading…
Cancel
Save