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