From bab51190e15d4a985cd993ef14fabe6ea574b6b0 Mon Sep 17 00:00:00 2001 From: Johan Berglund Date: Sun, 25 Aug 2019 12:38:02 +0200 Subject: [PATCH] Fix for bite vibrato sensitivity. Added increased range of sensitivity settings. Added possibility to use both bite and lever for vibrato at the same time. Separate timing interval for breath (trying to get speed up again). Moved Teensy touch sense calls for pinky key and special key to function less often called (every standard CC interval). Changed menu name VEL BIAS to VEL BOOST which is a more accurate description. --- NuEVI/NuEVI.ino | 59 +++++++++++++++++++++++++++------------------- NuEVI/config.h | 5 ++-- NuEVI/menu.cpp | 10 ++++---- NuEVI/settings.cpp | 4 ++-- NuEVI/settings.h | 2 +- 5 files changed, 47 insertions(+), 33 deletions(-) diff --git a/NuEVI/NuEVI.ino b/NuEVI/NuEVI.ino index 720452e..5e86363 100644 --- a/NuEVI/NuEVI.ino +++ b/NuEVI/NuEVI.ino @@ -114,6 +114,7 @@ static const unsigned long pixelUpdateInterval = 80; unsigned long lastDeglitchTime = 0; // The last time the fingering was changed unsigned long ccSendTime = 0L; // The last time we sent CC values +unsigned long ccBreathSendTime = 0L; // The last time we sent breath CC values unsigned long breath_on_time = 0L; // Time when breath sensor value went over the ON threshold int lastFingering = 0; // Keep the last fingering value for debouncing @@ -173,6 +174,7 @@ byte vibLedOff = 0; byte oldpkey = 0; static const float vibDepth[10] = {0,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.40,0.45}; // max pitch bend values (+/-) for the vibrato settings +static const short vibMaxBiteList[17] = {1600,1400,1200,1000,900,800,700,600,500,400,300,250,200,150,100,50,25}; static const short vibMaxList[12] = {300,275,250,225,200,175,150,125,100,75,50,25}; static const unsigned short curveM4[] = {0,4300,7000,8700,9900,10950,11900,12600,13300,13900,14500,15000,15450,15700,16000,16250,16383}; @@ -467,9 +469,7 @@ void loop() { } if (analogRead(breathSensorPin) > (breathCalZero - 800)) programonce = false; - - if (specialKeyEnable) { - specialKey = (touchRead(specialKeyPin) > touch_Thr); //S2 on pcb + if (specialKeyEnable) { if (lastSpecialKey != specialKey) { if (specialKey) { // special key just pressed, check other keys @@ -700,21 +700,20 @@ void loop() { if (pressureSensor > breathThrVal) cursorBlinkTime = millis(); // keep display from updating with cursor blinking if breath is over thr } // Is it time to send more CC data? + if (millis() - ccBreathSendTime > (CC_BREATH_INTERVAL*(slowMidi+1))){ + breath(); + ccBreathSendTime = millis(); + } if (millis() - ccSendTime > CC_INTERVAL) { - // deal with Breath, Pitch Bend, Modulation, etc. - if (!slowMidi) breath(); - halfTime = !halfTime; - if (halfTime) { - pitch_bend(); - portamento_(); - } else { - if (slowMidi) breath(); - extraController(); - if (((pinkySetting == LVL) || (pinkySetting == LVLP)) && pinkyKey){ - // show LVL indication - } else updateSensorLEDs(); - doorKnobCheck(); - } + // deal with Pitch Bend, Modulation, etc. + pitch_bend(); + portamento_(); + extraController(); + readTeensySwitches(); + if (((pinkySetting == LVL) || (pinkySetting == LVLP)) && pinkyKey){ + // show LVL indication + } else updateSensorLEDs(); + doorKnobCheck(); ccSendTime = millis(); } if (millis() - pixelUpdateTime > pixelUpdateInterval) { @@ -860,7 +859,7 @@ void pitch_bend() { vibMax = vibMaxList[vibSens - 1]; - vibMaxBite = vibMax*4; + vibMaxBite = vibMaxBiteList[vibSensBite - 1]; if (vibControl){ //bite vibrato if (biteJumper){ //PBITE (if pulled low with jumper, use pressure sensor instead of capacitive bite sensor) @@ -883,7 +882,8 @@ void pitch_bend() { } else { vibSignal = vibSignal * 0.5; } - } else { //lever vibrato + } + if (vibControl != 1) { //lever vibrato vibRead = touchRead(vibratoPin); // SENSOR PIN 15 - built in var cap if (vibRead < vibThr) { if (UPWD == vibDirection) { @@ -1102,12 +1102,12 @@ void extraController() { void portamento_() { - if (biteJumper){ //PBITE (if pulled low with jumper, use pressure sensor instead of capacitive bite sensor) + if (biteJumper) { //PBITE (if pulled low with jumper, use pressure sensor instead of capacitive bite sensor) biteSensor=analogRead(bitePressurePin); // alternative kind bite sensor (air pressure tube and sensor) PBITE } else { biteSensor = touchRead(bitePin); // get sensor data, do some smoothing - SENSOR PIN 17 - PCB PINS LABELED "BITE" (GND left, sensor pin right) } - if (!vibControl){ + if (0 == vibControl) { // Portamento is controlled with the bite sensor (variable capacitor) in the mouthpiece if (portamento && (biteSensor >= portamThrVal)) { // if we are enabled and over the threshold, send portamento if (!portIsOn) { @@ -1117,7 +1117,8 @@ void portamento_() { } else if (portIsOn) { // we have just gone below threshold, so send zero value portOff(); } - } else { + } else if (1 == vibControl) { + // Portamento is switched to lever control leverPortRead = touchRead(vibratoPin); if (portamento && (leverPortRead <= (leverPortZero-leverPortThr))) { // if we are enabled and over the threshold, send portamento if (!portIsOn) { @@ -1127,6 +1128,10 @@ void portamento_() { } else if (portIsOn) { // we have just gone below threshold, so send zero value portOff(); } + } else { + // no control for portamento + if (portIsOn) + portOff(); } } @@ -1143,7 +1148,7 @@ void portOn() { void port() { int portCC; - if (!vibControl) + if (1 != vibControl) portCC = map(constrain(biteSensor, portamThrVal, portamMaxVal), portamThrVal, portamMaxVal, 0, 127); else portCC = constrain((leverPortZero-leverPortThr-leverPortRead),0,127); @@ -1168,6 +1173,12 @@ void portOff() { //*********************************************************** + +void readTeensySwitches() { //these seem to slow things down, so do it less often + pinkyKey = (touchRead(halfPitchBendKeyPin) > touch_Thr); // SENSOR PIN 1 - PCB PIN "S1" + specialKey = (touchRead(specialKeyPin) > touch_Thr); //S2 on pcb +} + void readSwitches() { // Read touch pads (MPR121), compare against threshold value @@ -1196,7 +1207,7 @@ void readSwitches() { K6 = touchKeys[K6Pin]; K7 = touchKeys[K7Pin]; - pinkyKey = (touchRead(halfPitchBendKeyPin) > touch_Thr); // SENSOR PIN 1 - PCB PIN "S1" + int qTransp = (pinkyKey && (pinkySetting < 25)) ? pinkySetting-12 : 0; diff --git a/NuEVI/config.h b/NuEVI/config.h index 84520ea..059dd93 100644 --- a/NuEVI/config.h +++ b/NuEVI/config.h @@ -11,9 +11,10 @@ #define CCN_Port 5 // Controller number for portamento level #define CCN_PortOnOff 65// Controller number for portamento on/off -// Send breath CC data no more than every CC_INTERVAL (other CC is sent with double interval) +// Send breath CC data no more than every CC_BREATH_INTERVAL // milliseconds (due to timing errors, the value should be about half the actual wanted value) -#define CC_INTERVAL 2 +#define CC_BREATH_INTERVAL 1 +#define CC_INTERVAL 10 #define breathLoLimit 0 diff --git a/NuEVI/menu.cpp b/NuEVI/menu.cpp index 3f65e41..d285352 100644 --- a/NuEVI/menu.cpp +++ b/NuEVI/menu.cpp @@ -777,7 +777,7 @@ const MenuEntrySub velSmpDlMenu = { }; const MenuEntrySub velBiasMenu = { - MenuType::ESub, "VEL BIAS", "VEL BIAS", &velBias, 0, 9, MenuEntryFlags::EMenuEntryWrap, + MenuType::ESub, "VEL BOOST", "VEL BOOST", &velBias, 0, 9, MenuEntryFlags::EMenuEntryWrap, [](SubMenuRef __unused, char* out, const char** __unused unit) { if (velBias) numToString(velBias, out); else strncpy(out, "OFF", 4); @@ -964,7 +964,7 @@ const MenuEntrySub vibSquelchMenu = { }; const MenuEntrySub vibSenseBiteMenu = { - MenuType::ESub, "SENSE BTE", "LEVEL", &vibSensBite, 1, 12, MenuEntryFlags::ENone, + MenuType::ESub, "SENSE BTE", "LEVEL", &vibSensBite, 1, 17, MenuEntryFlags::ENone, [](SubMenuRef __unused,char* textBuffer, const char** __unused unit) { numToString(vibSensBite, textBuffer); }, @@ -982,9 +982,11 @@ const MenuEntrySub vibSquelchBiteMenu = { }; const MenuEntrySub vibControlMenu = { - MenuType::ESub, "CONTROL", "CONTROL", &vibControl , 0, 1, MenuEntryFlags::EMenuEntryWrap, + MenuType::ESub, "CONTROL", "CONTROL", &vibControl , 0, 2, MenuEntryFlags::EMenuEntryWrap, [](SubMenuRef __unused, char* out, const char** __unused unit) { - if (vibControl) + if (2 == vibControl) + strncpy(out, "BTH", 4); + else if (1 == vibControl) strncpy(out, "BIT", 4); else strncpy(out, "LVR", 4); diff --git a/NuEVI/settings.cpp b/NuEVI/settings.cpp index d8b3195..e83eeac 100644 --- a/NuEVI/settings.cpp +++ b/NuEVI/settings.cpp @@ -151,9 +151,9 @@ void readEEPROM() { vibDirection = readSettingBounded(VIB_DIRECTION_ADDR, 0, 1, VIB_DIRECTION_FACTORY); breathCC2 = readSettingBounded(BREATH_CC2_ADDR, 0, 127, BREATH_CC2_FACTORY); breathCC2Rise = readSettingBounded(BREATH_CC2_RISE_ADDR, 1, 10, BREATH_CC2_RISE_FACTORY); - vibSensBite = readSettingBounded(VIB_SENS_BITE_ADDR, 1, 12, VIB_SENS_BITE_FACTORY); + vibSensBite = readSettingBounded(VIB_SENS_BITE_ADDR, 1, 17, VIB_SENS_BITE_FACTORY); vibSquelchBite = readSettingBounded(VIB_SQUELCH_BITE_ADDR, 1, 30, VIB_SQUELCH_BITE_FACTORY); - vibControl = readSettingBounded(VIB_CONTROL_ADDR, 0, 1, VIB_CONTROL_FACTORY); + vibControl = readSettingBounded(VIB_CONTROL_ADDR, 0, 2, VIB_CONTROL_FACTORY); dacMode = readSettingBounded(DAC_MODE_ADDR, DAC_MODE_BREATH, DAC_MODE_PITCH, DAC_MODE_FACTORY); trill3_interval = readSettingBounded(TRILL3_INTERVAL_ADDR, 3, 4, TRILL3_INTERVAL_FACTORY); extraCT2 = readSettingBounded(EXTRA2_ADDR, 0, 127, EXTRA2_FACTORY); diff --git a/NuEVI/settings.h b/NuEVI/settings.h index 36f0141..2aed720 100644 --- a/NuEVI/settings.h +++ b/NuEVI/settings.h @@ -120,7 +120,7 @@ #define VIB_SQUELCH_BITE_FACTORY 10 #define VIB_CONTROL_FACTORY 0 #define TRILL3_INTERVAL_FACTORY 4 -#define DAC_MODE_FACTORY DAC_MODE_BREATH +#define DAC_MODE_FACTORY DAC_MODE_PITCH #define EXTRA2_FACTORY 0 #define LEVEL_CC_FACTORY 11 #define LEVEL_VAL_FACTORY 127