From 6a8290c317a486d92e4810d0642c024c01fc401f Mon Sep 17 00:00:00 2001 From: positionhigh Date: Mon, 23 Aug 2021 17:38:10 +0200 Subject: [PATCH] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MicroDexed.ino | 77 ++------------------------------------------------ 1 file changed, 3 insertions(+), 74 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 6487917..a5d48c9 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -23,7 +23,6 @@ #include "TeensyTimerTool.h" using namespace TeensyTimerTool; - #include #include "config.h" #include @@ -54,10 +53,8 @@ using namespace TeensyTimerTool; #ifdef SGTL5000_AUDIO_ENHANCE #include "control_sgtl5000plus.h" #endif - // Audio engines AudioSynthDexed* MicroDexed[NUM_DEXED]; - #if defined(USE_FX) AudioSynthWaveform* chorus_modulator[NUM_DEXED]; #if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT @@ -70,7 +67,6 @@ AudioEffectDelay* delay_fx[NUM_DEXED]; AudioMixer4* delay_mixer[NUM_DEXED]; #endif AudioEffectMonoStereo* mono2stereo[NUM_DEXED]; - AudioMixer4 microdexed_peak_mixer; AudioAnalyzePeak microdexed_peak; #if defined(USE_FX) @@ -93,7 +89,6 @@ AudioAnalyzePeak master_peak_l; AudioMixer4 audio_thru_mixer_r; AudioMixer4 audio_thru_mixer_l; #endif - // Drumset #if NUM_DRUMS > 0 AudioPlayMemory* Drum[NUM_DRUMS]; @@ -114,7 +109,6 @@ AudioMixer8 drum_reverb_send_mixer_l; #endif #endif #endif - // Outputs #if defined(TEENSY_AUDIO_BOARD) AudioOutputI2S i2s1; @@ -139,7 +133,6 @@ AudioOutputAnalogStereo dacOut; #ifdef AUDIO_DEVICE_USB AudioOutputUSB usb1; #endif - #if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU) AudioInputI2S i2s1in; #endif @@ -168,7 +161,6 @@ AudioConnection patchCord[] = { {volume_l, 0, stereo2mono, 1}, {stereo2mono, 0, master_peak_r, 0}, {stereo2mono, 0, master_peak_l, 0}, - // Outputs #if defined(TEENSY_AUDIO_BOARD) #ifndef SGTL5000_AUDIO_THRU @@ -196,7 +188,6 @@ AudioConnection patchCord[] = { {stereo2mono, 0, usb1, 0}, {stereo2mono, 1, usb1, 1}, #endif - #if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU) {stereo2mono, 0, audio_thru_mixer_r, 0}, {stereo2mono, 1, audio_thru_mixer_l, 0}, @@ -205,7 +196,6 @@ AudioConnection patchCord[] = { {audio_thru_mixer_r, 0, i2s1, 0}, {audio_thru_mixer_l, 0, i2s1, 1}, #endif - #if NUM_DRUMS > 0 #ifdef USE_FX {drum_reverb_send_mixer_r, 0, reverb_mixer_r, 2}, @@ -245,7 +235,6 @@ void create_audio_dexed_chain(uint8_t instance_id) delay_fx[instance_id] = new AudioEffectDelay(); delay_mixer[instance_id] = new AudioMixer4(); #endif - dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, microdexed_peak_mixer, instance_id); #if defined(USE_FX) dynamicConnections[nDynamic++] = new AudioConnection(*MicroDexed[instance_id], 0, *chorus_mixer[instance_id], 0); @@ -270,13 +259,11 @@ void create_audio_dexed_chain(uint8_t instance_id) #endif dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, master_mixer_r, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, master_mixer_l, instance_id); - #ifdef DEBUG Serial.print(F("Dexed-Instance: ")); Serial.println(instance_id); #endif } - // // Dynamic patching of Drum objects // @@ -284,14 +271,12 @@ void create_audio_dexed_chain(uint8_t instance_id) void create_audio_drum_chain(uint8_t instance_id) { Drum[instance_id] = new AudioPlayMemory(); - dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, drum_mixer_r, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, drum_mixer_l, instance_id); #ifdef USE_FX dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, drum_reverb_send_mixer_r, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, drum_reverb_send_mixer_l, instance_id); #endif - #ifdef DEBUG Serial.print(F("Drum-Instance: ")); Serial.println(instance_id); @@ -300,7 +285,6 @@ void create_audio_drum_chain(uint8_t instance_id) #endif } #endif - uint8_t sd_card = 0; Sd2Card card; SdVolume volume; @@ -340,7 +324,6 @@ int8_t midi_decay[NUM_DEXED] = { -1}; #endif elapsedMillis midi_decay_timer; #endif - #if NUM_DEXED>1 int perform_attack_mod[NUM_DEXED] = { 0, 0}; int perform_release_mod[NUM_DEXED] = { 0, 0}; @@ -352,18 +335,15 @@ int perform_release_mod[NUM_DEXED] = { 0 }; // Allocate the delay lines for chorus int16_t delayline[NUM_DEXED][MOD_DELAY_SAMPLE_BUFFER]; #endif - #if NUM_DRUMS > 0 extern drum_config_t drum_config[NUM_DRUMSET_CONFIG]; uint8_t drum_counter; uint8_t drum_type[NUM_DRUMS]; extern void sequencer(void); #endif - #ifdef ENABLE_LCD_UI extern LCDMenuLib2 LCDML; #endif - extern void getNoteName(char* noteName, uint8_t noteNumber); PeriodicTimer timer1; extern char seq_chord_names[7][4]; @@ -373,15 +353,11 @@ extern char seq_chord_names[7][4]; ***********************************************************************/ void setup() { -#ifdef DEBUG Serial.begin(SERIAL_SPEED); -#endif - #ifdef DISPLAY_LCD_SPI pinMode(SDCARD_CS_PIN, OUTPUT); pinMode(U8X8_CS_PIN, OUTPUT); #endif - #ifdef ENABLE_LCD_UI setup_ui(); #endif @@ -390,14 +366,10 @@ void setup() Serial.println(F("NO LCD DISPLAY ENABLED!")); #endif #endif - #ifdef DEBUG Serial.println(CrashReport); - setup_debug_message(); - generate_version_string(version_string, sizeof(version_string)); - Serial.println(F("MicroDexed based on https://github.com/asb2m10/dexed")); Serial.println(F("(c)2018-2021 H. Wirtz ")); Serial.println(F("https://codeberg.org/dcoredump/MicroDexed")); @@ -409,12 +381,9 @@ void setup() Serial.println(F("")); Serial.flush(); #endif - setup_midi_devices(); - // Start audio system AudioMemory(AUDIO_MEM); - #if defined(TEENSY_AUDIO_BOARD) sgtl5000.enable(); sgtl5000.lineOutLevel(SGTL5000_LINEOUT_LEVEL); @@ -472,7 +441,6 @@ void setup() Serial.println(F("Internal DAC enabled.")); #endif #endif - // create dynamic Dexed instances for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { @@ -482,7 +450,6 @@ void setup() #endif create_audio_dexed_chain(instance_id); } - #ifdef DEBUG for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { @@ -493,7 +460,6 @@ void setup() Serial.println(F(" voices")); } #endif - #if NUM_DRUMS > 0 // create dynamic Drum instances for (uint8_t instance_id = 0; instance_id < NUM_DRUMS; instance_id++) @@ -503,7 +469,6 @@ void setup() Serial.println(instance_id, DEC); #endif create_audio_drum_chain(instance_id); - drum_mixer_r.gain(instance_id, 1.0); drum_mixer_l.gain(instance_id, 1.0); #ifdef USE_FX @@ -533,9 +498,7 @@ void setup() Serial.println(F(" samples")); #endif #endif - initial_values_from_eeprom(false); - // start SD card #ifdef DISPLAY_LCD_SPI change_disp_sd(false); @@ -551,7 +514,6 @@ void setup() else { check_and_create_directories(); - for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { // load default SYSEX data @@ -561,15 +523,12 @@ void setup() memset(receive_bank_filename, 0, FILENAME_LEN); } } - #ifdef DISPLAY_LCD_SPI change_disp_sd(true); #endif - // Initialize processor and memory measurements AudioProcessorUsageMaxReset(); AudioMemoryUsageMaxReset(); - #ifdef DEBUG for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { @@ -584,18 +543,15 @@ void setup() Serial.print(F("Polyphony: ")); Serial.println(configuration.dexed[instance_id].polyphony, DEC); } - Serial.print(F("AUDIO_BLOCK_SAMPLES=")); Serial.print(AUDIO_BLOCK_SAMPLES); 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(); #endif - // init master_mixer #if NUM_DEXED > 1 for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) @@ -613,14 +569,12 @@ void setup() master_mixer_r.gain(2, VOL_MAX_FLOAT); master_mixer_l.gain(2, VOL_MAX_FLOAT); drums_volume = VOL_MAX_FLOAT; - #else master_mixer_r.gain(2, 0.0); master_mixer_l.gain(2, 0.0); #endif master_mixer_r.gain(3, VOL_MAX_FLOAT); master_mixer_l.gain(3, VOL_MAX_FLOAT); - #if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU) audio_thru_mixer_r.gain(0, VOL_MAX_FLOAT); // MD signal sum audio_thru_mixer_l.gain(0, VOL_MAX_FLOAT); // MD signal sum @@ -636,11 +590,9 @@ void setup() audio_thru_mixer_r.gain(3, 0.0); audio_thru_mixer_l.gain(3, 0.0); #endif - #ifdef DEBUG Serial.println(F("")); #endif - LCDML.OTHER_jumpToFunc(UI_func_voice_select); timer1.begin(sequencer, 90000, false); } @@ -649,24 +601,21 @@ void loop() { // MIDI input handling check_midi_devices(); - // check encoder ENCODER[ENC_L].update(); ENCODER[ENC_R].update(); - #ifdef ENABLE_LCD_UI LCDML.loop(); #endif - if (seq_running) { if (seq_step != seq_UI_last_step) { seq_UI_last_step = seq_step; - if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sequencer)) //is in UI of Sequencer + if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_seq_pattern_editor)) //is in UI of Sequencer { - lcd.setCursor(seq_step, 1); - lcd.print("X"); + lcd.setCursor(seq_step, 1); + lcd.write(124); if (seq_step == 0) { lcd.setCursor(15, 1); @@ -677,7 +626,6 @@ void loop() lcd.setCursor(seq_step - 1, 1); lcd.print(seq_find_shortname(seq_step - 1)[0]); } - } else if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_arpeggio)) //is in UI of Arpeggiator { @@ -693,7 +641,6 @@ void loop() if (control_rate > CONTROL_RATE_MS) { control_rate = 0; - // check for value changes, unused voices and CPU overload for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { @@ -701,7 +648,6 @@ void loop() if (active_voices[instance_id] == 0) midi_voices[instance_id] = 0; } - if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_voice_select)) { for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) @@ -746,7 +692,6 @@ void loop() } else yield(); - #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) if (cpu_mem_millis >= SHOW_CPU_LOAD_MSEC) { @@ -785,7 +730,6 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) { if (configuration.dexed[instance_id].polyphony > 0) MicroDexed[instance_id]->keydown(inNumber, uint8_t(float(configuration.dexed[instance_id].velocity_level / 127.0)*inVelocity + 0.5)); - midi_voices[instance_id]++; #ifdef TEENSY4 if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_voice_select)) @@ -809,14 +753,12 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) } } } - #if NUM_DRUMS > 0 // Check for Drum if (inChannel == drum_midi_channel) { if (drum_counter >= NUM_DRUMS) drum_counter = 0; - #ifdef DEBUG char note_name[4]; getNoteName(note_name, inNumber); @@ -1200,12 +1142,10 @@ void handleSystemExclusive(byte * sysex, uint len) #endif return; } - #ifdef DEBUG Serial.print(F("SysEx data length: [")); Serial.print(len); Serial.println(F("]")); - Serial.println(F("SysEx data:")); for (uint16_t i = 0; i < len; i++) { @@ -1226,7 +1166,6 @@ void handleSystemExclusive(byte * sysex, uint len) } Serial.println(); #endif - // Check for SYSEX end byte if (sysex[len - 1] != 0xf7) { @@ -1235,7 +1174,6 @@ void handleSystemExclusive(byte * sysex, uint len) #endif return; } - if (sysex[1] != 0x43) // check for Yamaha sysex { #ifdef DEBUG @@ -1243,13 +1181,11 @@ void handleSystemExclusive(byte * sysex, uint len) #endif return; } - #ifdef DEBUG Serial.print(F("Substatus: [")); Serial.print((sysex[2] & 0x70) >> 4); Serial.println(F("]")); #endif - // parse parameter change if (len == 7) { @@ -1260,10 +1196,8 @@ void handleSystemExclusive(byte * sysex, uint len) #endif return; } - sysex[4] &= 0x7f; sysex[5] &= 0x7f; - if ((sysex[3] & 0x7c) >> 2 == 0) { #ifdef DEBUG @@ -1420,12 +1354,10 @@ void handleSystemExclusive(byte * sysex, uint len) { int32_t bulk_checksum_calc = 0; int8_t bulk_checksum = sysex[161]; - // 1 Voice bulk upload #ifdef DEBUG Serial.println(F("One Voice bulk upload")); #endif - if ((sysex[3] & 0x7f) != 0) { #ifdef DEBUG @@ -1433,7 +1365,6 @@ void handleSystemExclusive(byte * sysex, uint len) #endif return; } - if (((sysex[4] << 7) | sysex[5]) != 0x9b) { #ifdef DEBUG @@ -1441,14 +1372,12 @@ void handleSystemExclusive(byte * sysex, uint len) #endif return; } - // checksum calculation for (uint8_t i = 0; i < 155 ; i++) { bulk_checksum_calc -= sysex[i + 6]; } bulk_checksum_calc &= 0x7f; - if (bulk_checksum_calc != bulk_checksum) { #ifdef DEBUG