diff --git a/NuEVI/src/xEVI.cpp b/NuEVI/src/xEVI.cpp index 8a31b17..ab0ceaf 100644 --- a/NuEVI/src/xEVI.cpp +++ b/NuEVI/src/xEVI.cpp @@ -777,8 +777,6 @@ void noteOn(int fingeredNote, int pressureSensor, int initial_breath_value) { } else { velocitySend = state.currentPreset->fixedVelocity; } - Serial.print(">velocity:"); - Serial.println(velocitySend); midiSendNoteOn(fingeredNote, velocitySend); // send Note Off message } @@ -892,7 +890,6 @@ void readBreath() { int16_t breathAltSignal = constrain(readAltPressure(), BREATH_LO_LIMIT, BREATH_HI_LIMIT) + instrument.breathAltZeroOffset; int16_t spikeSignal = constrain(readSpikePressure(), -SPIKE_HI_LIMIT, SPIKE_HI_LIMIT); int16_t diffSignal = breathAltSignal - breathSignal; - int16_t halfOffset = state.calibration->breathThrValOffset / 2; if (state.currentPreset->breathMode == BREATH_ACC || state.currentPreset->breathMode == BREATH_ACC_AT) { int delta = breathSignal - instrument.breathZero; if (abs(delta) > state.calibration->breathThrValOffset) { @@ -903,12 +900,20 @@ void readBreath() { } instrument.breathAltSignal = breathAltSignal; + + int16_t movingThrAdj = instrument.breathBaseline + (instrument.breathSignal - instrument.breathBaseline) * .75; + if (state.mainState != NOTE_ON) { + // Don't allow the threshold to increase if we're not playing a note to make slow attacks consistent + movingThrAdj = min(instrument.breathMovingThrVal, movingThrAdj); + } + instrument.breathMovingThrVal = constrain( - breathBaselineFilter.input(instrument.breathBaseline + (instrument.breathSignal - instrument.breathBaseline) * .75), - instrument.breathZero + halfOffset, - instrument.breathMaxVal - halfOffset + breathBaselineFilter.input(movingThrAdj), + instrument.breathBaseline, + instrument.breathMaxVal - state.calibration->breathThrValOffset ); + int16_t halfOffset = state.calibration->breathThrValOffset >> 1; instrument.breathThrVal = instrument.breathMovingThrVal + halfOffset; instrument.breathThrOffVal = instrument.breathMovingThrVal - halfOffset; @@ -931,6 +936,8 @@ void readBreath() { Serial.println(instrument.breathThrVal); Serial.print(">off:"); Serial.println(instrument.breathThrOffVal); + Serial.print(">offset:"); + Serial.println(state.calibration->breathThrValOffset); } }