From ef104f6909f3d3250ea401f13e6362094efc1bf1 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 25 Oct 2019 13:03:31 +0200 Subject: [PATCH 1/2] Trying a faster way to mix stereo to mono. Garbage collection at config.h. --- config.h | 24 +++++++++--------------- effect_stereo_mono.cpp | 10 ++++++++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/config.h b/config.h index f973320..1051744 100644 --- a/config.h +++ b/config.h @@ -44,12 +44,16 @@ //* DEVICE SETTINGS //************************************************************************************************* -// MIDI +//************************************************************************************************* +//* MIDI HARDWARE SETTINGS +//************************************************************************************************* //#define MIDI_DEVICE_DIN Serial1 #define MIDI_DEVICE_USB 1 #define MIDI_DEVICE_USB_HOST 1 -// AUDIO +//************************************************************************************************* +//* AUDIO HARDWARE SETTINGS +//************************************************************************************************* // If nothing is defined Teensy internal DAC is used as audio output device! // Left and right channel audio signal is presented on pins A21 and A22. #define AUDIO_DEVICE_USB @@ -61,9 +65,8 @@ #define PT8211_AUDIO //************************************************************************************************* -//* MIDI SETTINGS +//* MIDI SOFTWARE SETTINGS //************************************************************************************************* - #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI #define MIDI_MERGE_THRU 1 #define SYSEXBANK_DEFAULT 0 @@ -82,7 +85,7 @@ //#define USE_REVERB 1 //************************************************************************************************* -//* AUDIO SETTINGS +//* AUDIO SOFTWARE SETTINGS //************************************************************************************************* // https://rechneronline.de/funktionsgraphen/ #ifndef TEENSY_AUDIO_BOARD @@ -141,7 +144,6 @@ #endif #define CONTROL_RATE_MS 50 - #define BACK_FROM_VOLUME_MS 1000 //************************************************************************************************* @@ -156,7 +158,6 @@ //************************************************************************************************* //* HARDWARE SETTINGS //************************************************************************************************* - #if defined(__IMXRT1062__) //Teensy-4.0 #define TEENSY4 #endif @@ -248,9 +249,8 @@ // Some optimizations #define USE_TEENSY_DSP 1 -#define SUM_UP_AS_INT 1 -/* HELPER MACROS */ +// HELPER MACROS #define TIME_MS2SAMPLES(x) floor(uint32_t(x) * AUDIO_SAMPLE_RATE / 1000) #define SAMPLES2TIME_MS(x) float(uint32_t(x) * 1000 / AUDIO_SAMPLE_RATE) // Modulated delay options @@ -367,12 +367,6 @@ struct config_t { uint8_t engine; }; -// struct for smoothing value changes -struct value_change_t { - float diff; - uint16_t steps; -}; - inline float mapfloat(float val, float in_min, float in_max, float out_min, float out_max) { return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; diff --git a/effect_stereo_mono.cpp b/effect_stereo_mono.cpp index 6ceae55..8eb9067 100644 --- a/effect_stereo_mono.cpp +++ b/effect_stereo_mono.cpp @@ -45,6 +45,7 @@ void AudioEffectStereoMono::update(void) { if (block[0] && block[1]) { +#ifdef USE_OLD_STEREO_TO_MONO int16_t *bp[2] = { block[0]->data, block[1]->data }; for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) @@ -54,6 +55,15 @@ void AudioEffectStereoMono::update(void) bp[0]++; bp[1]++; } +#else + // device every channel by 2 + arm_shift_q15(block[0]->data, -1, block[0]->data, AUDIO_BLOCK_SAMPLES); + arm_shift_q15(block[1]->data, -1, block[1]->data, AUDIO_BLOCK_SAMPLES); + // add channel 2 to channel 1 + arm_add_q15(block[0]->data, block[1]->data, block[0]->data, AUDIO_BLOCK_SAMPLES); + // copy channel 1 to channel 2 + arm_copy_q15(block[0]->data, block[1]->data, AUDIO_BLOCK_SAMPLES); +#endif } } From 9f7081b4876ad0fb235f7a52a149283c03b9f3ca Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 25 Oct 2019 13:27:59 +0200 Subject: [PATCH 2/2] Moving some more strings into PROGMEM. --- UI.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/UI.hpp b/UI.hpp index 66f983a..a56673c 100644 --- a/UI.hpp +++ b/UI.hpp @@ -232,9 +232,9 @@ void setup_ui(void) { lcd.setFont(u8x8_font_amstrad_cpc_extended_f); #endif lcd.setCursor(1, 0); - lcd.print("MicroDexed"); + lcd.print(F("MicroDexed")); lcd.setCursor(0, 1); - lcd.print("(c)parasiTstudio"); + lcd.print(F("(c)parasiTstudio")); #ifdef I2C_DISPLAY // set special chars for scrollbar @@ -703,7 +703,7 @@ void lcdml_menu_display(void) } else { lcd.setCursor((_LCDML_DISP_cols - 1), n); - lcd.print(' '); + lcd.print(F(" ")); } } } @@ -948,7 +948,7 @@ void UI_func_chorus_frequency(uint8_t param) lcd.setCursor(0, 1); lcd_display_float(configuration.chorus_frequency / 10.0, 2, 1, false, true, false); - lcd.print(" Hz"); + lcd.print(F(" Hz")); modulator.frequency(configuration.chorus_frequency / 10.0); } @@ -995,15 +995,15 @@ void UI_func_chorus_waveform(uint8_t param) { case 0: modulator.begin(WAVEFORM_TRIANGLE); - lcd.print("[TRIANGLE]"); + lcd.print(F("[TRIANGLE]")); break; case 1: modulator.begin(WAVEFORM_SINE); - lcd.print("[SINE ]"); + lcd.print(F("[SINE ]")); break; default: modulator.begin(WAVEFORM_TRIANGLE); - lcd.print("[TRIANGLE]"); + lcd.print(F("[TRIANGLE]")); break; } } @@ -1708,9 +1708,9 @@ void UI_func_volume(uint8_t param) for (uint8_t i = 0; i < LCD_cols; i++) { if (i < int((LCD_cols - 2) * configuration.vol / 100.0)) - lcd.print("*"); + lcd.print(F("*")); else - lcd.print(" "); + lcd.print(F(" ")); } lcd.show(1, 0, 1, "["); lcd.show(1, 15, 1, "]");