#ifndef __GLOBALS_H #define __GLOBALS_H #include "wiring.h" #include // The three states of our main state machine // No note is sounding #define NOTE_OFF 1 // We've observed a transition from below to above the // threshold value. We wait a while to see how fast the // breath velocity is increasing #define RISE_WAIT 2 // A note is sounding #define NOTE_ON 3 enum PinkyMode : uint8_t { PBD = 12, GLD = 25, MOD = 26, QTN = 27, }; enum FingeringMode : uint8_t { EVI = 0, EVR = 1, TPT = 2, HRN = 3, }; enum RollerMode : uint8_t { HIGHEST = 1, HIGHEST_EXTEND = 2, HIGHEST_PAIR = 3, HIGHEST_PAIR_EXTEND = 4, // Releasing the roller from the highest/lowest moves PARTIAL = 5, PARTIAL_EXTEND = 6, }; enum VibratoMode : uint8_t { VSTART_DOWN = 0, VSTART_UP = 1, }; enum BreathMode : uint8_t { BREATH_STD = 0, BREATH_LSB = 1, BREATH_AT = 2, BREATH_LSB_AT = 3, }; enum ExtraControl : uint8_t { OFF = 0, VIBRATO = 1, GLIDE = 2, CC = 3, }; enum PolySelect : uint8_t { EHarmonizerOff = 0, EDuo = 1, EChord = 2, }; enum PortamentoMode : uint8_t { POFF = 0, PON = 1, PSWITCH_ONLY = 2, PGLIDE_ONLY = 3, }; struct instrument_state_t { uint8_t patch; // 1-128 byte activeMIDIchannel = 1; // MIDI channel byte activeNote = 0; // note playing byte activePatch = 0; byte doPatchUpdate = 0; int8_t transpose = 0; int8_t octave = 0; PolySelect polyMode = PolySelect::EHarmonizerOff; // Raw sensor signals int16_t breathSignal = 0; // breath level (smoothed) not mapped to CC value int16_t breathAltSignal = 0; int16_t biteSignal = 0; // capacitance data from bite sensor, for midi cc and threshold checks int16_t leverSignal = 0; int16_t pbUpSignal = 0; int16_t pbDnSignal = 0; int16_t extraSignal = 0; int16_t vibSignal = 0; int16_t avgCTouchSignal = 0; // MIDI values int breathCCVal = 0; byte biteVal = 0; // keep track and make sure we send CC with 0 value when off threshold byte portamentoVal = 0; // keep track and make sure we send CC with 0 value when off threshold byte extraVal = 0; // keep track and make sure we send CC with 0 value when off threshold byte leverVal = 0; // keep track and make sure we send CC with 0 value when off threshold int pitchBend = 8192; int pbSend = 8192; // Pitch bend actually sent, modified by vibrato, etc // Key states byte quarterToneTrigger; byte pinkyKey = 0; // CV values int cvPitch; int targetPitch; // Calibration int16_t breathZero; // this gets auto calibrated in setup int16_t breathThrVal; // this gets auto calibrated in setup int16_t breathMaxVal; // this gets auto calibrated in setup int16_t breathAltZero; // this gets auto calibrated in setup int16_t breathAltThrVal; // this gets auto calibrated in setup int16_t breathAltMaxVal; // this gets auto calibrated in setup int16_t vibThr; // this gets auto calibrated in setup int16_t vibThrLo; int16_t vibZero; int16_t vibZeroBite; int16_t vibThrBite; int16_t vibThrBiteLo; }; extern const std::array curves; extern const unsigned short curveIn[]; extern unsigned int multiMap(unsigned short val, const unsigned short * _in, const unsigned short * _out, uint8_t size); #define mapConstrain(val, in_lo, in_hi, out_lo, out_hi) map(constrain(val, in_lo, in_hi), in_lo, in_hi, out_lo, out_hi) #endif