andrewm@0
|
1 /*
|
andrewm@0
|
2 TouchKeys: multi-touch musical keyboard control software
|
andrewm@0
|
3 Copyright (c) 2013 Andrew McPherson
|
andrewm@0
|
4
|
andrewm@0
|
5 This program is free software: you can redistribute it and/or modify
|
andrewm@0
|
6 it under the terms of the GNU General Public License as published by
|
andrewm@0
|
7 the Free Software Foundation, either version 3 of the License, or
|
andrewm@0
|
8 (at your option) any later version.
|
andrewm@0
|
9
|
andrewm@0
|
10 This program is distributed in the hope that it will be useful,
|
andrewm@0
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
andrewm@0
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
andrewm@0
|
13 GNU General Public License for more details.
|
andrewm@0
|
14
|
andrewm@0
|
15 You should have received a copy of the GNU General Public License
|
andrewm@0
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
andrewm@0
|
17
|
andrewm@0
|
18 =====================================================================
|
andrewm@0
|
19
|
andrewm@0
|
20 TouchkeyPitchBendMappingFactory.h: factory for the pitch-bend mapping,
|
andrewm@0
|
21 which handles changing pitch based on relative finger motion.
|
andrewm@0
|
22 */
|
andrewm@0
|
23
|
andrewm@0
|
24
|
andrewm@0
|
25 #ifndef __TouchKeys__TouchkeyPitchBendMappingFactory__
|
andrewm@0
|
26 #define __TouchKeys__TouchkeyPitchBendMappingFactory__
|
andrewm@0
|
27
|
andrewm@0
|
28
|
andrewm@0
|
29 #include <iostream>
|
andrewm@0
|
30
|
andrewm@0
|
31 #include "../TouchkeyBaseMappingFactory.h"
|
andrewm@0
|
32 #include "TouchkeyPitchBendMapping.h"
|
andrewm@0
|
33
|
andrewm@0
|
34 // Factory class to produce Touchkey pitch bend messages
|
andrewm@0
|
35 // This class keeps track of all the active mappings and responds
|
andrewm@0
|
36 // whenever touches or notes begin or end
|
andrewm@0
|
37
|
andrewm@0
|
38 class TouchkeyPitchBendMappingFactory : public TouchkeyBaseMappingFactory<TouchkeyPitchBendMapping> {
|
andrewm@0
|
39 private:
|
andrewm@0
|
40 //typedef std::pair<TouchkeyVibratoMapping*, TouchkeyPitchBendMapping*> mapping_pair;
|
andrewm@0
|
41 //const float kDefaultPitchWheelRangeSemitones = 12.0;
|
andrewm@0
|
42 static const float kDefaultPitchWheelRangeSemitones;
|
andrewm@0
|
43
|
andrewm@0
|
44 public:
|
andrewm@0
|
45 // ***** Constructor *****
|
andrewm@0
|
46
|
andrewm@0
|
47 // Default constructor, containing a reference to the PianoKeyboard class.
|
andrewm@0
|
48 TouchkeyPitchBendMappingFactory(PianoKeyboard &keyboard, MidiKeyboardSegment& segment);
|
andrewm@0
|
49
|
andrewm@0
|
50 // ***** Destructor *****
|
andrewm@0
|
51
|
andrewm@0
|
52 ~TouchkeyPitchBendMappingFactory();
|
andrewm@0
|
53
|
andrewm@0
|
54 // ***** Accessors / Modifiers *****
|
andrewm@0
|
55
|
andrewm@0
|
56 virtual const std::string factoryTypeName() { return "Pitch\nBend"; }
|
andrewm@0
|
57
|
andrewm@0
|
58 void setMIDIPitchWheelRange(float maxBendSemitones); // Set the range for the MIDI pitch wheel
|
andrewm@0
|
59 void setName(const string& name);
|
andrewm@0
|
60
|
andrewm@0
|
61 // ***** Bend-Specific Methods *****
|
andrewm@0
|
62
|
andrewm@0
|
63 float getBendRange() { return bendRangeSemitones_; }
|
andrewm@0
|
64 float getBendThresholdSemitones() { return bendThresholdSemitones_; }
|
andrewm@0
|
65 float getBendThresholdKeyLength() { return bendThresholdKeyLength_; }
|
andrewm@0
|
66 int getBendMode() { return bendMode_; }
|
andrewm@0
|
67
|
andrewm@0
|
68 void setBendRange(float rangeSemitones, bool updateCurrent = false);
|
andrewm@0
|
69 void setBendThresholdSemitones(float thresholdSemitones);
|
andrewm@0
|
70 void setBendThresholdKeyLength(float thresholdKeyLength);
|
andrewm@0
|
71 void setBendThresholds(float thresholdSemitones, float thresholdKeyLength, bool updateCurrent = false);
|
andrewm@0
|
72 void setBendFixedEndpoints(float minimumDistanceToEnable, float bufferAtEnd);
|
andrewm@0
|
73 void setBendVariableEndpoints();
|
andrewm@0
|
74 void setBendIgnoresMultipleFingers(bool ignoresTwo, bool ignoresThree);
|
andrewm@0
|
75
|
andrewm@0
|
76 // ***** GUI Support *****
|
andrewm@0
|
77 bool hasBasicEditor() { return true; }
|
andrewm@0
|
78 MappingEditorComponent* createBasicEditor();
|
andrewm@0
|
79 bool hasExtendedEditor() { return false; }
|
andrewm@0
|
80 MappingEditorComponent* createExtendedEditor() { return nullptr; }
|
andrewm@0
|
81
|
andrewm@0
|
82 private:
|
andrewm@0
|
83 // ***** Private Methods *****
|
andrewm@0
|
84 void initializeMappingParameters(int noteNumber, TouchkeyPitchBendMapping *mapping);
|
andrewm@0
|
85 void setBendParameters();
|
andrewm@0
|
86
|
andrewm@0
|
87 float pitchWheelRangeSemitones_; // Range of the MIDI pitch wheel (different than vibrato range)
|
andrewm@0
|
88
|
andrewm@0
|
89 float bendRangeSemitones_; // Range of the pitch bend component
|
andrewm@0
|
90 float bendThresholdSemitones_; // Threshold for engaging pitch bend
|
andrewm@0
|
91 float bendThresholdKeyLength_; // Threshold in key length for engaging pitch bend
|
andrewm@0
|
92 int bendMode_; // What mode the bend works in (fixed, variable, etc.)
|
andrewm@0
|
93 float fixedModeMinEnableDistance_; // Minimum distance to engage in fixed mode
|
andrewm@0
|
94 float fixedModeBufferDistance_; // Extra distance at end beyond which no bend happens
|
andrewm@0
|
95 bool bendIgnoresTwoFingers_; // Whether the pitch bends ignore two
|
andrewm@0
|
96 bool bendIgnoresThreeFingers_; // or three fingers on the key at once
|
andrewm@0
|
97 };
|
andrewm@0
|
98
|
andrewm@0
|
99 #endif /* defined(__TouchKeys__TouchkeyPitchBendMappingFactory__) */
|