Additional br tweaking
This commit is contained in:
parent
7740c09375
commit
e757ebc885
9 changed files with 91 additions and 44 deletions
|
@ -231,7 +231,9 @@ int breath() {
|
|||
// send midi cc
|
||||
midiSendControlChange(state.currentPreset->breathCC, breathCCval);
|
||||
}
|
||||
if (state.currentPreset->breathMode == BreathMode::BREATH_AT || state.currentPreset->breathMode == BreathMode::BREATH_LSB_AT) {
|
||||
if (state.currentPreset->breathMode == BreathMode::BREATH_AT
|
||||
|| state.currentPreset->breathMode == BreathMode::BREATH_LSB_AT
|
||||
|| state.currentPreset->breathMode == BreathMode::BREATH_ACC_AT) {
|
||||
// send aftertouch
|
||||
midiSendAfterTouch(breathCCval);
|
||||
}
|
||||
|
@ -245,6 +247,7 @@ int breath() {
|
|||
|
||||
oldbreathhires = breathCCvalHires;
|
||||
|
||||
state.instrument->breathCCVal = breathCCval;
|
||||
return breathCCval;
|
||||
}
|
||||
|
||||
|
@ -790,16 +793,6 @@ void sendCCs() {
|
|||
void runStateMachine() {
|
||||
static unsigned long breath_on_time = 0L; // Time when breath sensor value went over the ON threshold
|
||||
static int initial_breath_value = 0; // The breath value at the time we observed the transition
|
||||
|
||||
Serial.print(">breath:");
|
||||
Serial.println(instrument.breathSignal);
|
||||
Serial.print(">breathThr:");
|
||||
Serial.println(instrument.breathThrVal);
|
||||
Serial.print(">spike:");
|
||||
Serial.println(instrument.spikeSignal);
|
||||
Serial.print(">note:");
|
||||
Serial.println(state.mainState);
|
||||
|
||||
int fingeredNote = noteValueCheck(readSwitches() + readOctave());
|
||||
if (state.mainState == NOTE_OFF) {
|
||||
handleOffStateActions();
|
||||
|
@ -823,10 +816,7 @@ void runStateMachine() {
|
|||
state.mainState = NOTE_OFF;
|
||||
}
|
||||
} else if (state.mainState == NOTE_ON) {
|
||||
if (state.currentPreset->spikeFilterFreq && instrument.spikeSignal < -calibration.spikeThrVal) {
|
||||
midiSendNoteOff(instrument.activeNote); // send Note Off message
|
||||
state.mainState = SPIKE_HOLD;
|
||||
} else if (instrument.breathSignal < instrument.breathThrVal) {
|
||||
if (instrument.breathSignal < instrument.breathThrVal) {
|
||||
// Value has fallen below threshold - turn the note off
|
||||
midiSendNoteOff(instrument.activeNote); // send Note Off message
|
||||
instrument.breathSignal = 0;
|
||||
|
@ -842,14 +832,6 @@ void runStateMachine() {
|
|||
instrument.activeNote = fingeredNote;
|
||||
}
|
||||
}
|
||||
} else if (state.mainState == SPIKE_HOLD) {
|
||||
if (state.currentPreset->spikeFilterFreq && instrument.spikeSignal > calibration.spikeThrVal) {
|
||||
noteOn(fingeredNote, instrument.breathSignal, initial_breath_value);
|
||||
state.mainState = NOTE_ON;
|
||||
instrument.activeNote = fingeredNote;
|
||||
} else if ((instrument.breathSignal < instrument.breathThrVal)) {
|
||||
state.mainState = NOTE_OFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -908,8 +890,12 @@ void setup() {
|
|||
//_______________________________________________________________________________________________ MAIN LOOP
|
||||
|
||||
void loop() {
|
||||
static unsigned long lastUpdate = millis();
|
||||
static unsigned long pixelUpdateTime = 0;
|
||||
static const unsigned long pixelUpdateInterval = 80;
|
||||
unsigned long time = millis();
|
||||
unsigned long deltaTime = time - lastUpdate;
|
||||
lastUpdate = time;
|
||||
|
||||
// If in config mgmt loop, do that and nothing else
|
||||
if (configManagementMode) {
|
||||
|
@ -922,9 +908,32 @@ void loop() {
|
|||
return;
|
||||
}
|
||||
|
||||
instrument.breathSignal = constrain(readPressure(), BREATH_LO_LIMIT, BREATH_HI_LIMIT); // Get the filtered pressure sensor reading from analog pin A0, input from sensor MP3V5004GP
|
||||
int16_t breathSignal = constrain(readPressure(), BREATH_LO_LIMIT, BREATH_HI_LIMIT); // Get the filtered pressure sensor reading from analog pin A0, input from sensor MP3V5004GP
|
||||
int16_t spikeSignal = constrain(readSpikePressure(), -SPIKE_HI_LIMIT, SPIKE_HI_LIMIT);
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
instrument.breathSignal = breathSignal + (spikeSignal > 0 ? spikeSignal * state.currentPreset->spikeOnFactor : spikeSignal * state.currentPreset->spikeOffFactor);
|
||||
}
|
||||
instrument.breathAltSignal = constrain(readAltPressure(), BREATH_LO_LIMIT, BREATH_HI_LIMIT); // Get the filtered pressure sensor reading from analog pin A0, input from sensor MP3V5004GP
|
||||
instrument.spikeSignal = constrain(readSpikePressure(), -SPIKE_HI_LIMIT, SPIKE_HI_LIMIT);
|
||||
|
||||
/*
|
||||
Serial.print(">breathThr:");
|
||||
Serial.println(instrument.breathThrVal);
|
||||
Serial.print(">note:");
|
||||
Serial.println(state.mainState);
|
||||
Serial.print(">spike:");
|
||||
Serial.println(spikeSignal);
|
||||
Serial.print(">breath:");
|
||||
Serial.println(breathSignal);
|
||||
Serial.print(">combo:");
|
||||
Serial.println(instrument.breathSignal);
|
||||
*/
|
||||
|
||||
runStateMachine();
|
||||
sendCCs();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue