From 3d8fc6949f9a0c205e5e29a584aea456b59beec3 Mon Sep 17 00:00:00 2001 From: Meng Qi Date: Sun, 20 Mar 2022 21:40:51 +0800 Subject: [PATCH] MIDI fix / Minimize startup decay --- Wingie2/MIDI.ino | 4 ++-- Wingie2/control.ino | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Wingie2/MIDI.ino b/Wingie2/MIDI.ino index 4cfde46..83270bd 100644 --- a/Wingie2/MIDI.ino +++ b/Wingie2/MIDI.ino @@ -95,8 +95,8 @@ void MIDISetParam(int kb, byte number, byte value) { float v = (midiVal14Bit / 16383.) * 9.9 + 0.1; v = fscale(0.1, 10., 0.1, 10., v, -3.25); - if (!kb) dsp.setParamValue("/Wingie/left/decay", v); - if (kb) dsp.setParamValue("/Wingie/right/decay", v); + if (!kb && !startup) dsp.setParamValue("/Wingie/left/decay", v); + if (kb && !startup) dsp.setParamValue("/Wingie/right/decay", v); } if (number == VOL_CC or number == VOL_CC + 32) { diff --git a/Wingie2/control.ino b/Wingie2/control.ino index 9e7b811..0955c3e 100644 --- a/Wingie2/control.ino +++ b/Wingie2/control.ino @@ -117,6 +117,9 @@ void control( void * pvParameters ) { dsp.setParamValue("/Wingie/right/poly_note_1", 4 + BASE_NOTE + POLY_MODE_NOTE_ADD_R); dsp.setParamValue("/Wingie/right/poly_note_2", 7 + BASE_NOTE + POLY_MODE_NOTE_ADD_R); + dsp.setParamValue("/Wingie/left/decay", 0.1); // 最小 Startup Decay 避免开机声音过大 + dsp.setParamValue("/Wingie/right/decay", 0.1); + for (;;) { interrupts(); @@ -155,7 +158,8 @@ void control( void * pvParameters ) { // for (int i = 0; i < 3; i++) { potValRealtime[i] = analogRead(potPin[i]); - if (midiValValid[i]) if (potValRealtime[i] - potValSampled[i] > slider_movement_detect) midiValValid[i] = false; + int difference = abs(potValRealtime[i] - potValSampled[i]); + if (midiValValid[i]) if (difference > slider_movement_detect) midiValValid[i] = false; } float Mix = potValRealtime[0] / 4095.; @@ -166,7 +170,7 @@ void control( void * pvParameters ) { float Decay = (potValRealtime[1] / 4095.) * 9.9 + 0.1; Decay = fscale(0.1, 10., 0.1, 10., Decay, -3.25); - if (!midiValValid[DECAY]) { + if (!midiValValid[DECAY] && !startup) { dsp.setParamValue("/Wingie/left/decay", Decay); dsp.setParamValue("/Wingie/right/decay", Decay); }