Improved moving threshold behavior
This commit is contained in:
parent
90077f7a4e
commit
e8aeb26399
1 changed files with 13 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue