New slider signals

This commit is contained in:
Brian Hrebec 2024-04-01 16:39:27 -05:00
parent 4211a85562
commit 9f4634735b
6 changed files with 104 additions and 53 deletions

View file

@ -336,12 +336,12 @@ void pitch_bend() {
instrument.vibThrBiteLo = instrument.vibZeroBite - state.currentPreset->vibSquelch;
// PB calculation
int pbPos = mapConstrain(instrument.pbUpSignal, calibration.pbUpThrVal, calibration.pbUpMaxVal, calculatedPBdepth, 0);
int pbNeg = mapConstrain(instrument.pbDnSignal, calibration.pbDnThrVal, calibration.pbDnMaxVal, calculatedPBdepth, 0);
int pbPos = mapConstrain(instrument.pbSignal, calibration.pbCenterVal, calibration.pbMaxVal, calculatedPBdepth, 0);
int pbNeg = mapConstrain(instrument.pbSignal, calibration.pbCenterVal, calibration.pbMinVal, calculatedPBdepth, 0);
int pbSum = 8193 + pbPos - pbNeg;
int pbDif = abs(pbPos - pbNeg);
if ((instrument.pbUpSignal > calibration.pbUpThrVal || instrument.pbDnSignal > calibration.pbDnThrVal) && state.currentPreset->PBdepth) {
if ((pbPos > calibration.pbDeadzone || pbNeg < calibration.pbDeadzone) && state.currentPreset->PBdepth) {
if (pbDif < 10) {
instrument.pitchBend = 8192;
} else {
@ -390,8 +390,9 @@ void portamento_() {
if (ExtraControl::GLIDE == state.currentPreset->leverControl) {
// Portamento is controlled with thumb lever
if (((3000 - instrument.leverSignal) >= calibration.leverThrVal)) { // if we are enabled and over the threshold, send portamento
portSumCC += mapConstrain((3000 - instrument.leverSignal), calibration.leverThrVal, calibration.leverMaxVal, 0, state.currentPreset->portamentoLimit);
// FIXME: Fix this for new lever signal
if (((3000 - instrument.leverSignal) >= calibration.leverMinVal)) { // if we are enabled and over the threshold, send portamento
portSumCC += mapConstrain((3000 - instrument.leverSignal), calibration.leverMinVal, calibration.leverMaxVal, 0, state.currentPreset->portamentoLimit);
}
}
@ -415,8 +416,9 @@ void sendCC() {
int extraVal = 0;
if (ExtraControl::CC == state.currentPreset->extraControl) {
if (instrument.extraSignal >= calibration.extraThrVal) { // we are over the threshold, calculate CC value
extraVal = mapConstrain(instrument.extraSignal, calibration.extraThrVal, calibration.extraMaxVal, 0, 127);
// FIXME: Fix this for new extra signal
if (instrument.extraSignal >= calibration.extraMinVal) { // we are over the threshold, calculate CC value
extraVal = mapConstrain(instrument.extraSignal, calibration.extraMinVal, calibration.extraMaxVal, 0, 127);
}
if (extraVal != instrument.extraVal) {
@ -472,8 +474,7 @@ void autoCal() {
for (int i = 1; i <= CALIBRATE_SAMPLE_COUNT; ++i) {
bZero += readPressure();
bAltZero += readAltPressure();
instrument.vibZero += readTouchUtil(leverPin);
instrument.vibZeroBite += readTouchUtil(bitePin);
instrument.vibZeroBite += readTouchRoller(bitePin);
}
instrument.breathZero = bZero / CALIBRATE_SAMPLE_COUNT;
@ -494,30 +495,31 @@ void fullAutoCal() {
calibration.breathMaxValOffset = 1500;
autoCal();
// Bite sensor
calRead = readTouchRoller(bitePin);
calibration.biteThrVal = constrain(calRead + 100, BITE_LO_LIMIT, BITE_HI_LIMIT);
calibration.biteMaxVal = constrain(calRead + 300, BITE_LO_LIMIT, BITE_HI_LIMIT);
/*
// Lever
calRead = readTouchUtil(leverPin);
calRead = readTouchRoller(leverPin);
calibration.leverThrVal = constrain(calRead + 100, LEVER_LO_LIMIT, LEVER_HI_LIMIT);
calibration.leverMaxVal = constrain(calRead + 300, LEVER_LO_LIMIT, LEVER_HI_LIMIT);
// Extra
calRead = readTouchUtil(extraPin);
calRead = readTouchRoller(extraPin);
calibration.extraThrVal = constrain(calRead + 100, EXTRA_LO_LIMIT, EXTRA_HI_LIMIT);
calibration.extraMaxVal = constrain(calRead + 300, EXTRA_LO_LIMIT, EXTRA_HI_LIMIT);
// Bite sensor
calRead = readTouchUtil(bitePin);
calibration.biteThrVal = constrain(calRead + 100, BITE_LO_LIMIT, BITE_HI_LIMIT);
calibration.biteMaxVal = constrain(calRead + 300, BITE_LO_LIMIT, BITE_HI_LIMIT);
// PB
calRead = readTouchUtil(pbDnPin);
calRead = readTouchRoller(pbDnPin);
calibration.pbDnThrVal = constrain(calRead + 100, BITE_LO_LIMIT, BITE_HI_LIMIT);
calibration.pbDnMaxVal = constrain(calRead + 300, BITE_LO_LIMIT, BITE_HI_LIMIT);
calRead = readTouchUtil(pbUpPin);
calRead = readTouchRoller(pbUpPin);
calibration.pbUpThrVal = constrain(calRead + 100, BITE_LO_LIMIT, BITE_HI_LIMIT);
calibration.pbUpMaxVal = constrain(calRead + 300, BITE_LO_LIMIT, BITE_HI_LIMIT);
*/
// Touch sensors
calRead = CTOUCH_HI_LIMIT;
for (byte i = 0; i < 12; i++) {
@ -552,12 +554,12 @@ int readOctave() {
bool rollers[6];
uint16_t ctouchThrVal = calibration.ctouchThrVal;
rollers[0] = readTouchUtil(R1Pin) > ctouchThrVal;
rollers[1] = readTouchUtil(R2Pin) > ctouchThrVal;
rollers[2] = readTouchUtil(R3Pin) > ctouchThrVal;
rollers[3] = readTouchUtil(R4Pin) > ctouchThrVal;
rollers[4] = readTouchUtil(R5Pin) > ctouchThrVal;
rollers[5] = readTouchUtil(R6Pin) > ctouchThrVal;
rollers[0] = readTouchRoller(R1Pin) > ctouchThrVal;
rollers[1] = readTouchRoller(R2Pin) > ctouchThrVal;
rollers[2] = readTouchRoller(R3Pin) > ctouchThrVal;
rollers[3] = readTouchRoller(R4Pin) > ctouchThrVal;
rollers[4] = readTouchRoller(R5Pin) > ctouchThrVal;
rollers[5] = readTouchRoller(R6Pin) > ctouchThrVal;
int offset = 0;
int octaveR = 0;
@ -796,7 +798,7 @@ void changeNote(int fingeredNote, int activeNote, int fingeredNote2, int activeN
noteOn(fingeredNote, instrument.breathSignal, 0);
}
if (fingeredNote2 != activeNote && fingeredNote2 != activeNote2) {
if (fingeredNote2 != fingeredNote && fingeredNote2 != activeNote && fingeredNote2 != activeNote2) {
noteOn(fingeredNote2, instrument.breathSignal, 0);
}
@ -807,7 +809,7 @@ void changeNote(int fingeredNote, int activeNote, int fingeredNote2, int activeN
midiSendNoteOff(activeNote);
}
if (activeNote2 != fingeredNote && activeNote2 != fingeredNote2) {
if (activeNote != activeNote2 && activeNote2 != fingeredNote && activeNote2 != fingeredNote2) {
midiSendNoteOff(activeNote2);
}
}
@ -841,11 +843,10 @@ void initState() {
* Read all utility sensors
*/
void readUtil() {
instrument.biteSignal = readTouchUtil(bitePin);
instrument.leverSignal = readTouchUtil(leverPin);
instrument.pbUpSignal = readTouchUtil(pbUpPin); // PCB PIN "Pu"
instrument.pbDnSignal = readTouchUtil(pbDnPin); // PCB PIN "Pd"
instrument.extraSignal = readTouchUtil(extraPin);
instrument.biteSignal = readTouchRoller(bitePin);
instrument.pbSignal = readSlider(SLIDER_PITCH_BEND);
instrument.leverSignal = readSlider(SLIDER_LEVER);
instrument.extraSignal = readSlider(SLIDER_EXTRA);
}
/**
@ -900,7 +901,7 @@ void readBreath() {
if (state.currentPreset->breathMode == BREATH_ACC || state.currentPreset->breathMode == BREATH_ACC_AT) {
int delta = breathSignal - instrument.breathZero;
if (abs(delta) > state.calibration->breathAltThrValOffset) {
instrument.breathSignal = constrain(instrument.breathSignal + delta / 10, instrument.breathZero, instrument.breathMaxVal);
instrument.breathSignal = constrain(instrument.breathSignal + delta / 15, instrument.breathZero, instrument.breathMaxVal);
}
} else {
instrument.breathSignal = breathSignal + (spikeSignal > 0 ? spikeSignal * state.currentPreset->spikeOnFactor : spikeSignal * state.currentPreset->spikeOffFactor);
@ -1040,6 +1041,7 @@ void loop() {
readSwitches();
runStateMachine();
handleCCs();
readSlider(1);
// cvUpdate();
midiDiscardInput();