andrewm@0: /*
andrewm@0: TouchKeys: multi-touch musical keyboard control software
andrewm@0: Copyright (c) 2013 Andrew McPherson
andrewm@0:
andrewm@0: This program is free software: you can redistribute it and/or modify
andrewm@0: it under the terms of the GNU General Public License as published by
andrewm@0: the Free Software Foundation, either version 3 of the License, or
andrewm@0: (at your option) any later version.
andrewm@0:
andrewm@0: This program is distributed in the hope that it will be useful,
andrewm@0: but WITHOUT ANY WARRANTY; without even the implied warranty of
andrewm@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
andrewm@0: GNU General Public License for more details.
andrewm@0:
andrewm@0: You should have received a copy of the GNU General Public License
andrewm@0: along with this program. If not, see .
andrewm@0:
andrewm@0: =====================================================================
andrewm@0:
andrewm@0: TouchkeyPitchBendMappingFactory.h: factory for the pitch-bend mapping,
andrewm@0: which handles changing pitch based on relative finger motion.
andrewm@0: */
andrewm@0:
andrewm@0:
andrewm@0: #ifndef __TouchKeys__TouchkeyPitchBendMappingFactory__
andrewm@0: #define __TouchKeys__TouchkeyPitchBendMappingFactory__
andrewm@0:
andrewm@0:
andrewm@0: #include
andrewm@0:
andrewm@0: #include "../TouchkeyBaseMappingFactory.h"
andrewm@0: #include "TouchkeyPitchBendMapping.h"
andrewm@0:
andrewm@0: // Factory class to produce Touchkey pitch bend messages
andrewm@0: // This class keeps track of all the active mappings and responds
andrewm@0: // whenever touches or notes begin or end
andrewm@0:
andrewm@0: class TouchkeyPitchBendMappingFactory : public TouchkeyBaseMappingFactory {
andrewm@0:
andrewm@0: public:
andrewm@0: // ***** Constructor *****
andrewm@0:
andrewm@0: // Default constructor, containing a reference to the PianoKeyboard class.
andrewm@0: TouchkeyPitchBendMappingFactory(PianoKeyboard &keyboard, MidiKeyboardSegment& segment);
andrewm@0:
andrewm@0: // ***** Destructor *****
andrewm@0:
andrewm@0: ~TouchkeyPitchBendMappingFactory();
andrewm@0:
andrewm@0: // ***** Accessors / Modifiers *****
andrewm@0:
andrewm@0: virtual const std::string factoryTypeName() { return "Pitch\nBend"; }
andrewm@0:
andrewm@0: void setName(const string& name);
andrewm@0:
andrewm@0: // ***** Bend-Specific Methods *****
andrewm@0:
andrewm@0: float getBendRange() { return bendRangeSemitones_; }
andrewm@0: float getBendThresholdSemitones() { return bendThresholdSemitones_; }
andrewm@0: float getBendThresholdKeyLength() { return bendThresholdKeyLength_; }
andrewm@0: int getBendMode() { return bendMode_; }
andrewm@0:
andrewm@0: void setBendRange(float rangeSemitones, bool updateCurrent = false);
andrewm@0: void setBendThresholdSemitones(float thresholdSemitones);
andrewm@0: void setBendThresholdKeyLength(float thresholdKeyLength);
andrewm@0: void setBendThresholds(float thresholdSemitones, float thresholdKeyLength, bool updateCurrent = false);
andrewm@0: void setBendFixedEndpoints(float minimumDistanceToEnable, float bufferAtEnd);
andrewm@0: void setBendVariableEndpoints();
andrewm@0: void setBendIgnoresMultipleFingers(bool ignoresTwo, bool ignoresThree);
andrewm@0:
andrewm@49: #ifndef TOUCHKEYS_NO_GUI
andrewm@0: // ***** GUI Support *****
andrewm@0: bool hasBasicEditor() { return true; }
andrewm@0: MappingEditorComponent* createBasicEditor();
andrewm@0: bool hasExtendedEditor() { return false; }
andrewm@0: MappingEditorComponent* createExtendedEditor() { return nullptr; }
andrewm@49: #endif
andrewm@49:
andrewm@49: // ****** OSC Control Support ******
andrewm@49: OscMessage* oscControlMethod(const char *path, const char *types,
andrewm@49: int numValues, lo_arg **values, void *data);
andrewm@0:
andrewm@36: // ****** Preset Save/Load ******
andrewm@36: XmlElement* getPreset();
andrewm@36: bool loadPreset(XmlElement const* preset);
andrewm@36:
andrewm@0: private:
andrewm@0: // ***** Private Methods *****
andrewm@0: void initializeMappingParameters(int noteNumber, TouchkeyPitchBendMapping *mapping);
andrewm@0: void setBendParameters();
andrewm@0:
andrewm@0: float bendRangeSemitones_; // Range of the pitch bend component
andrewm@0: float bendThresholdSemitones_; // Threshold for engaging pitch bend
andrewm@0: float bendThresholdKeyLength_; // Threshold in key length for engaging pitch bend
andrewm@0: int bendMode_; // What mode the bend works in (fixed, variable, etc.)
andrewm@0: float fixedModeMinEnableDistance_; // Minimum distance to engage in fixed mode
andrewm@0: float fixedModeBufferDistance_; // Extra distance at end beyond which no bend happens
andrewm@0: bool bendIgnoresTwoFingers_; // Whether the pitch bends ignore two
andrewm@0: bool bendIgnoresThreeFingers_; // or three fingers on the key at once
andrewm@0: };
andrewm@0:
andrewm@0: #endif /* defined(__TouchKeys__TouchkeyPitchBendMappingFactory__) */