diff --git a/MicroDexed.ino b/MicroDexed.ino index 8854872..7fb159a 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -364,7 +364,10 @@ extern LCDMenuLib2 LCDML; #endif extern void getNoteName(char* noteName, uint8_t noteNumber); -PeriodicTimer timer1; + +#ifdef USE_SEQUENCER +PeriodicTimer sequencer_timer; +#endif /*********************************************************************** SETUP @@ -565,8 +568,10 @@ void setup() } } +#ifdef USE_SEQUENCER // Start timer (to avoid a crash when loading the performance data) - timer1.begin(sequencer, seq.seq_tempo_ms / 2, false); + sequencer_timer.begin(sequencer, seq.seq_tempo_ms / 2, false); +#endif // Load initial Performance or the last used one initial_values(false); @@ -1766,7 +1771,9 @@ void handleStart(void) seq.seq_step = 0; seq.seq_chain_active_step = 0; seq.seq_running = true; - timer1.start(); +#ifdef USE_SEQUENCER + sequencer_timer.start(); +#endif } @@ -1777,7 +1784,9 @@ void handleContinue(void) void handleStop(void) { - timer1.stop(); +#ifdef USE_SEQUENCER + sequencer_timer.stop(); +#endif seq.seq_running = false; seq.seq_recording = false; seq.seq_note_in = 0; diff --git a/UI.hpp b/UI.hpp index f8ec0c7..2aabcdf 100644 --- a/UI.hpp +++ b/UI.hpp @@ -53,7 +53,9 @@ #endif #define _LCDML_DISP_cfg_scrollbar 1 // enable a scrollbar -extern PeriodicTimer timer1; +#ifdef USE_SEQUENCER +extern PeriodicTimer sequencer_timer; +#endif extern void sequencer(void); extern bool check_sd_performance_exists(uint8_t number); @@ -4404,8 +4406,10 @@ void UI_func_seq_tempo(uint8_t param) } } #endif - //timer1.stop(); - timer1.begin(sequencer, seq.seq_tempo_ms / 2); + //sequencer_timer.stop(); +#ifdef USE_SEQUENCER + sequencer_timer.begin(sequencer, seq.seq_tempo_ms / 2); +#endif } if (LCDML.FUNC_close()) // ****** STABLE END ********* { diff --git a/UI_FX.h b/UI_FX.h index 3f1466c..6a02b4d 100644 --- a/UI_FX.h +++ b/UI_FX.h @@ -103,7 +103,7 @@ LCDML_add(69, LCDML_0_1, 8, "Save Voice", UI_func_save_voice); LCDML_add(70, LCDML_0, 3, "Load/Save", NULL); LCDML_add(71, LCDML_0_3, 1, "Load Perf.", UI_func_load_performance); LCDML_add(72, LCDML_0_3, 2, "Save Perf.", UI_func_save_performance); -LCDML_add(73, LCDML_0_3, 3, "Name Perf.", UI_func_set_performance_name); +LCDML_add(73, LCDML_0_3, 3, "Name Perf.", UI_func_set_performance_name); LCDML_add(74, LCDML_0_3, 4, "MIDI", NULL); LCDML_add(75, LCDML_0_3_4, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank); LCDML_add(76, LCDML_0_3_4, 2, "MIDI Snd Bank", UI_func_sysex_send_bank); @@ -114,26 +114,12 @@ LCDML_add(80, LCDML_0_4, 2, "Drum Volumes", UI_func_drum_volume); LCDML_add(81, LCDML_0_4, 3, "Drum Pan", UI_func_drum_pan); LCDML_add(82, LCDML_0_4, 4, "Drum Rev.Send", UI_func_drum_reverb_send); LCDML_add(83, LCDML_0_4, 5, "MIDI Channel", UI_func_drum_midi_channel); -LCDML_add(84, LCDML_0, 5, "Sequencer", NULL); -LCDML_add(85, LCDML_0_5, 1, "Pattern Editor", UI_func_seq_pattern_editor); -LCDML_add(86, LCDML_0_5, 2, "Vel./Chrd Edit", UI_func_seq_vel_editor); -LCDML_add(87, LCDML_0_5, 3, "Pattern Chain", UI_func_seq_pat_chain); -LCDML_add(88, LCDML_0_5, 4, "Arpeggio", UI_func_arpeggio); -LCDML_add(89, LCDML_0_5, 5, "Seq. Settings", NULL); -LCDML_add(90, LCDML_0_5_5, 1, "Tempo", UI_func_seq_tempo); -LCDML_add(91, LCDML_0_5_5, 2, "Seq. Length", UI_func_seq_lenght); -LCDML_add(92, LCDML_0_5_5, 3, "Track Setup", UI_func_seq_track_setup); -LCDML_add(93, LCDML_0_5_5, 4, "Seq.Disp.Style", UI_func_seq_display_style); -LCDML_add(94, LCDML_0_5_5, 5, "Dexed Assign", UI_func_dexed_assign); -LCDML_add(95, LCDML_0_5_5, 6, "Shift&Transp.", UI_func_arp_shift); -LCDML_add(96, LCDML_0_5_5, 7, "ChordTrack Keys", UI_func_seq_chord_keys_ammount); -LCDML_add(97, LCDML_0_5_5, 8, "L.Transp.Key", UI_func_seq_live_transpose_oct); -LCDML_add(98, LCDML_0, 6, "System", NULL); -LCDML_add(99, LCDML_0_6, 1, "Stereo/Mono", UI_func_stereo_mono); -LCDML_add(100, LCDML_0_6, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); -LCDML_add(101, LCDML_0_6, 3, "Favorites", UI_func_favorites); -LCDML_add(102, LCDML_0_6, 4, "Startup", UI_func_startup); -LCDML_add(103, LCDML_0, 7, "Info", UI_func_information); -LCDML_addAdvanced(104, LCDML_0, 8, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); -#define _LCDML_DISP_cnt 104 +LCDML_add(84, LCDML_0, 5, "System", NULL); +LCDML_add(85, LCDML_0_5, 1, "Stereo/Mono", UI_func_stereo_mono); +LCDML_add(86, LCDML_0_5, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); +LCDML_add(87, LCDML_0_5, 3, "Favorites", UI_func_favorites); +LCDML_add(88, LCDML_0_5, 4, "Startup", UI_func_startup); +LCDML_add(89, LCDML_0, 6, "Info", UI_func_information); +LCDML_addAdvanced(90, LCDML_0, 7, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); +#define _LCDML_DISP_cnt 90 #endif diff --git a/UI_NO_FX.h b/UI_NO_FX.h index 25f9adc..206ad19 100644 --- a/UI_NO_FX.h +++ b/UI_NO_FX.h @@ -87,27 +87,12 @@ LCDML_add(53, LCDML_0_3, 1, "Drums Main Vol", UI_func_drums_main_volume); LCDML_add(54, LCDML_0_3, 2, "Drum Volumes", UI_func_drum_volume); LCDML_add(55, LCDML_0_3, 3, "Drum Pan", UI_func_drum_pan); LCDML_add(56, LCDML_0_3, 4, "MIDI Channel", UI_func_drum_midi_channel); -LCDML_add(57, LCDML_0, 4, "Sequencer", NULL); -LCDML_add(58, LCDML_0_4, 1, "Pattern Editor", UI_func_seq_pattern_editor); -LCDML_add(59, LCDML_0_4, 2, "Vel./Chrd Edit", UI_func_seq_vel_editor); -LCDML_add(60, LCDML_0_4, 3, "Pattern Chain", UI_func_seq_pat_chain); -LCDML_add(61, LCDML_0_4, 4, "Arpeggio", UI_func_arpeggio); -LCDML_add(62, LCDML_0_4, 5, "Mute Matrix", UI_func_seq_mute_matrix); -LCDML_add(63, LCDML_0_4, 6, "Seq. Settings", NULL); -LCDML_add(64, LCDML_0_4_6, 1, "Tempo", UI_func_seq_tempo); -LCDML_add(65, LCDML_0_4_6, 2, "Seq. Length", UI_func_seq_lenght); -LCDML_add(66, LCDML_0_4_6, 3, "Track Setup", UI_func_seq_track_setup); -LCDML_add(67, LCDML_0_4_6, 4, "Seq.Disp.Style", UI_func_seq_display_style); -LCDML_add(68, LCDML_0_4_6, 5, "Dexed Assign", UI_func_dexed_assign); -LCDML_add(69, LCDML_0_4_6, 6, "Shift&Transp.", UI_func_arp_shift); -LCDML_add(70, LCDML_0_4_6, 7, "L.Transp.Key", UI_func_seq_live_transpose_oct); -LCDML_add(71, LCDML_0_4_6, 8, "ChordTrack Keys", UI_func_seq_chord_keys_ammount); -LCDML_add(72, LCDML_0, 5, "System", NULL); -LCDML_add(73, LCDML_0_5, 1, "Stereo/Mono", UI_func_stereo_mono); -LCDML_add(74, LCDML_0_5, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); -LCDML_add(75, LCDML_0_5, 3, "Favorites", UI_func_favorites); -LCDML_add(76, LCDML_0_5, 4, "Startup", UI_func_startup); -LCDML_add(77, LCDML_0, 6, "Info", UI_func_information); -LCDML_addAdvanced(78, LCDML_0, 8, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); -#define _LCDML_DISP_cnt 78 +LCDML_add(57, LCDML_0, 4, "System", NULL); +LCDML_add(58, LCDML_0_4, 1, "Stereo/Mono", UI_func_stereo_mono); +LCDML_add(59, LCDML_0_4, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); +LCDML_add(60, LCDML_0_4, 3, "Favorites", UI_func_favorites); +LCDML_add(61, LCDML_0_4, 4, "Startup", UI_func_startup); +LCDML_add(62, LCDML_0, 5, "Info", UI_func_information); +LCDML_addAdvanced(63, LCDML_0, 6, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); +#define _LCDML_DISP_cnt 63 #endif diff --git a/config.h b/config.h index 6d31102..ffe78eb 100644 --- a/config.h +++ b/config.h @@ -96,7 +96,7 @@ #define SHOW_CPU_LOAD_MSEC 5000 //************************************************************************************************* -//* DEXED AND EFFECTS SETTINGS +//* DEXED SEQEUNCER AND EFFECTS SETTINGS //************************************************************************************************* // Number of Dexed instances #if defined(TEENSY3_6) @@ -128,13 +128,10 @@ #endif // SEQUENCER - -#ifdef TEENSY4 #define NUM_SEQ_PATTERN 24 #define NUM_SEQ_TRACKS 6 -#else -#define NUM_SEQ_PATTERN 10 -#define NUM_SEQ_TRACKS 2 +#ifdef TEENSY4 +#define USE_SEQUENCER #endif // CHORUS parameters @@ -351,6 +348,7 @@ // Teensy-3.6 settings #if defined(TEENSY3_6) +#undef USE_SEQUENCER # if defined(USE_FX) # warning >>> With enabled FX a maximum of 12 voices is possible (due to RAM and CPU limitations) # define MAX_NOTES 12 diff --git a/dexed_sd.cpp b/dexed_sd.cpp index 75ebd72..7341692 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -45,7 +45,9 @@ extern void check_configuration_performance(void); extern void check_configuration_fx(void); extern void sequencer(); extern sequencer_t seq; -extern PeriodicTimer timer1; +#ifdef USE_SEQUENCER +extern PeriodicTimer sequencer_timer; +#endif extern float midi_volume_transform(uint8_t midi_amp); extern void set_sample_note(uint8_t sample, uint8_t note); extern void set_sample_pitch(uint8_t sample, float playbackspeed); @@ -1514,6 +1516,7 @@ bool load_sd_seq_sub_patterns_json(uint8_t seq_number) bool load_sd_performance_json(uint8_t seq_number) { +#ifdef USE_SEQUENCER bool seq_was_running = false; if (seq.seq_running) @@ -1521,6 +1524,8 @@ bool load_sd_performance_json(uint8_t seq_number) seq_was_running = true; seq.seq_running = false; } +#endif + dac_mute(); handleStop(); seq_number = constrain(seq_number, 0, 99); @@ -1622,13 +1627,17 @@ bool load_sd_performance_json(uint8_t seq_number) dac_unmute(); seq.seq_step = 0; seq.seq_chain_active_step = 0; +#ifdef USE_SEQUENCER if (seq_was_running) { - timer1.begin(sequencer, seq.seq_tempo_ms / 2); + sequencer_timer.begin(sequencer, seq.seq_tempo_ms / 2); seq.seq_running = true; } else - timer1.begin(sequencer, seq.seq_tempo_ms / 2, false); + sequencer_timer.begin(sequencer, seq.seq_tempo_ms / 2, false); +#else + seq.seq_running = false; +#endif return (true); } #ifdef DEBUG diff --git a/effect_freeverb_simd.cpp b/effect_freeverb_simd.cpp index a0ecafa..e42d70c 100644 --- a/effect_freeverb_simd.cpp +++ b/effect_freeverb_simd.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. */ +#ifdef USE_FREEVERB_SIMD // A fixed point implementation of Freeverb by Jezar at Dreampoint // http://blog.bjornroche.com/2012/06/freeverb-original-public-domain-code-by.html // https://music.columbia.edu/pipermail/music-dsp/2001-October/045433.html @@ -843,3 +844,4 @@ void AudioEffectFreeverbSIMDStereo::update() if (block) release(block); #endif } +#endif diff --git a/effect_freeverb_simd.h b/effect_freeverb_simd.h index 863f06d..f89317d 100644 --- a/effect_freeverb_simd.h +++ b/effect_freeverb_simd.h @@ -24,6 +24,7 @@ THE SOFTWARE. */ +#ifdef USE_FREEVERB_SIMD #ifndef effect_freeverb_simd_h_ #define effect_freeverb_simd_h_ #include @@ -180,5 +181,5 @@ class AudioEffectFreeverbSIMDStereo : public AudioStream uint16_t allpass4indexR; }; - +#endif #endif diff --git a/sequencer.cpp b/sequencer.cpp index df17679..e4bf2bc 100644 --- a/sequencer.cpp +++ b/sequencer.cpp @@ -7,7 +7,7 @@ (c)2018-2021 M. Koslowski H. Wirtz - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by (at your option) any later version. diff --git a/sequencer.h b/sequencer.h index 93aa7ac..26f34d1 100644 --- a/sequencer.h +++ b/sequencer.h @@ -25,17 +25,13 @@ #ifndef _SEQUENCER_H #define _SEQUENCER_H -typedef struct sequencer_s { +typedef struct sequencer_s +{ float drums_volume; uint8_t seq_active_track = 0; uint8_t seq_menu; -#ifdef TEENSY4 bool seq_noteoffsent[NUM_SEQ_TRACKS] = {false, false, false, false, false, false}; uint8_t seq_inst_dexed[NUM_SEQ_TRACKS] = { 0, 0, 1, 1 , 1, 1 }; -#else - bool seq_noteoffsent[NUM_SEQ_TRACKS] = {false, false}; - uint8_t seq_inst_dexed[NUM_SEQ_TRACKS] = { 0, 0 }; -#endif uint8_t seq_step = 0; bool seq_running = false; bool seq_recording = false; @@ -54,7 +50,7 @@ typedef struct sequencer_s { int seq_oct_shift = 0; uint8_t arp_style = 0; // up, down, up&down, random - uint8_t seq_arps[6][23] = { + const uint8_t seq_arps[6][23] = { { 0, 4, 7, 12, 16, 19, 24, 28, 31, 36, 40, 43, 48, 52, 55, 60, 64, 67, 72, 76, 79, 84, 0}, //major { 0, 3, 7, 12, 15, 19, 24, 27, 31, 36, 39, 43, 48, 51, 55, 60, 63, 67, 72, 75, 79, 84, 0}, //minor { 0, 4, 7, 10, 12, 16, 19, 22, 24, 28, 31, 34, 36, 40, 43, 46, 48, 52, 55, 58, 60, 64, 0}, //seventh @@ -63,7 +59,7 @@ typedef struct sequencer_s { { 0, 4, 7, 11, 12, 16, 19, 23, 24, 28, 31, 35, 36, 40, 43, 47, 48, 52, 55, 59, 60, 64, 0} //maj7 }; - char seq_chord_names[7][4] = { + const char seq_chord_names[7][4] = { {'M', 'a', 'j', ' '}, //major {'M', 'i', 'n', ' '}, {'s', 'e', 'v', ' '}, @@ -73,7 +69,7 @@ typedef struct sequencer_s { { 'N', 'o', 'C', 'd'} }; - char arp_style_names[4][3] = { + const char arp_style_names[4][3] = { { 'u', 'p', ' '}, {'d', 'w', 'n'}, {'u', '&', 'd'}, @@ -123,8 +119,7 @@ typedef struct sequencer_s { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; - uint8_t seq_content_type[NUM_SEQ_PATTERN] = { 0, 0, 0, 0 , 0, 0, 0 , 0 , 0 , 0 }; // 0 = track is Drumtrack, 1= Instrumenttrack, 2= Chord or Arpeggio -#ifdef TEENSY4 + uint8_t seq_content_type[NUM_SEQ_PATTERN] = { 0, 0, 0, 0 , 0, 0, 0 , 0 , 0 , 0 }; // 0 = track is Drumtrack, 1 = Instrumenttrack, 2 = Chord or Arpeggio uint8_t seq_patternchain[4][NUM_SEQ_TRACKS] = { { 0 , 2 , 6 , 9 , 99, 99 }, { 1 , 2 , 5 , 8 , 99, 99 }, @@ -132,15 +127,6 @@ typedef struct sequencer_s { { 1 , 2 , 5 , 7 , 99, 99 } }; uint8_t seq_track_type[NUM_SEQ_TRACKS] = { 0, 0, 1, 1, 1, 1 }; // 0 = track is Drumtrack, 1 = Instrumenttrack, 2 = Chord, 3 = Arp -#else - uint8_t seq_patternchain[4][NUM_SEQ_TRACKS] = { - { 0 , 2 }, - { 1 , 2 }, - { 0 , 2 }, - { 1 , 2 }, - }; - uint8_t seq_track_type[NUM_SEQ_TRACKS] = { 0, 0 }; // 0 = track is Drumtrack, 1 = Instrumenttrack, 2 = Chord, 3 = Arp -#endif } sequencer_t; #endif