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
|
andrewm@0
|
40 public:
|
andrewm@0
|
41 // ***** Constructor *****
|
andrewm@0
|
42
|
andrewm@0
|
43 // Default constructor, containing a reference to the PianoKeyboard class.
|
andrewm@0
|
44 TouchkeyPitchBendMappingFactory(PianoKeyboard &keyboard, MidiKeyboardSegment& segment);
|
andrewm@0
|
45
|
andrewm@0
|
46 // ***** Destructor *****
|
andrewm@0
|
47
|
andrewm@0
|
48 ~TouchkeyPitchBendMappingFactory();
|
andrewm@0
|
49
|
andrewm@0
|
50 // ***** Accessors / Modifiers *****
|
andrewm@0
|
51
|
andrewm@0
|
52 virtual const std::string factoryTypeName() { return "Pitch\nBend"; }
|
andrewm@0
|
53
|
andrewm@0
|
54 void setName(const string& name);
|
andrewm@0
|
55
|
andrewm@0
|
56 // ***** Bend-Specific Methods *****
|
andrewm@0
|
57
|
andrewm@0
|
58 float getBendRange() { return bendRangeSemitones_; }
|
andrewm@0
|
59 float getBendThresholdSemitones() { return bendThresholdSemitones_; }
|
andrewm@0
|
60 float getBendThresholdKeyLength() { return bendThresholdKeyLength_; }
|
andrewm@0
|
61 int getBendMode() { return bendMode_; }
|
andrewm@0
|
62
|
andrewm@0
|
63 void setBendRange(float rangeSemitones, bool updateCurrent = false);
|
andrewm@0
|
64 void setBendThresholdSemitones(float thresholdSemitones);
|
andrewm@0
|
65 void setBendThresholdKeyLength(float thresholdKeyLength);
|
andrewm@0
|
66 void setBendThresholds(float thresholdSemitones, float thresholdKeyLength, bool updateCurrent = false);
|
andrewm@0
|
67 void setBendFixedEndpoints(float minimumDistanceToEnable, float bufferAtEnd);
|
andrewm@0
|
68 void setBendVariableEndpoints();
|
andrewm@0
|
69 void setBendIgnoresMultipleFingers(bool ignoresTwo, bool ignoresThree);
|
andrewm@0
|
70
|
andrewm@49
|
71 #ifndef TOUCHKEYS_NO_GUI
|
andrewm@0
|
72 // ***** GUI Support *****
|
andrewm@0
|
73 bool hasBasicEditor() { return true; }
|
andrewm@0
|
74 MappingEditorComponent* createBasicEditor();
|
andrewm@0
|
75 bool hasExtendedEditor() { return false; }
|
andrewm@0
|
76 MappingEditorComponent* createExtendedEditor() { return nullptr; }
|
andrewm@49
|
77 #endif
|
andrewm@49
|
78
|
andrewm@49
|
79 // ****** OSC Control Support ******
|
andrewm@49
|
80 OscMessage* oscControlMethod(const char *path, const char *types,
|
andrewm@49
|
81 int numValues, lo_arg **values, void *data);
|
andrewm@0
|
82
|
andrewm@36
|
83 // ****** Preset Save/Load ******
|
andrewm@36
|
84 XmlElement* getPreset();
|
andrewm@36
|
85 bool loadPreset(XmlElement const* preset);
|
andrewm@36
|
86
|
andrewm@0
|
87 private:
|
andrewm@0
|
88 // ***** Private Methods *****
|
andrewm@0
|
89 void initializeMappingParameters(int noteNumber, TouchkeyPitchBendMapping *mapping);
|
andrewm@0
|
90 void setBendParameters();
|
andrewm@0
|
91
|
andrewm@0
|
92 float bendRangeSemitones_; // Range of the pitch bend component
|
andrewm@0
|
93 float bendThresholdSemitones_; // Threshold for engaging pitch bend
|
andrewm@0
|
94 float bendThresholdKeyLength_; // Threshold in key length for engaging pitch bend
|
andrewm@0
|
95 int bendMode_; // What mode the bend works in (fixed, variable, etc.)
|
andrewm@0
|
96 float fixedModeMinEnableDistance_; // Minimum distance to engage in fixed mode
|
andrewm@0
|
97 float fixedModeBufferDistance_; // Extra distance at end beyond which no bend happens
|
andrewm@0
|
98 bool bendIgnoresTwoFingers_; // Whether the pitch bends ignore two
|
andrewm@0
|
99 bool bendIgnoresThreeFingers_; // or three fingers on the key at once
|
andrewm@0
|
100 };
|
andrewm@0
|
101
|
andrewm@0
|
102 #endif /* defined(__TouchKeys__TouchkeyPitchBendMappingFactory__) */
|