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 TouchkeyVibratoMappingFactory.h: factory for the vibrato mapping class,
|
andrewm@0
|
21 which creates vibrato through side-to-side motion of the finger on the
|
andrewm@0
|
22 key surface.
|
andrewm@0
|
23 */
|
andrewm@0
|
24
|
andrewm@0
|
25 #ifndef __touchkeys__TouchkeyVibratoMappingFactory__
|
andrewm@0
|
26 #define __touchkeys__TouchkeyVibratoMappingFactory__
|
andrewm@0
|
27
|
andrewm@0
|
28 #include <iostream>
|
andrewm@0
|
29
|
andrewm@0
|
30 #include "../TouchkeyBaseMappingFactory.h"
|
andrewm@0
|
31 #include "TouchkeyVibratoMapping.h"
|
andrewm@0
|
32
|
andrewm@0
|
33 // Factory class to produce Touchkey vibrato (pitch-bend) mappings
|
andrewm@0
|
34 // This class keeps track of all the active mappings and responds
|
andrewm@0
|
35 // whenever touches or notes begin or end
|
andrewm@0
|
36
|
andrewm@0
|
37 class TouchkeyVibratoMappingFactory : public TouchkeyBaseMappingFactory<TouchkeyVibratoMapping> {
|
andrewm@0
|
38 private:
|
andrewm@0
|
39 static const int kDefaultVibratoControl;
|
andrewm@0
|
40
|
andrewm@0
|
41 public:
|
andrewm@0
|
42
|
andrewm@0
|
43 // ***** Constructor *****
|
andrewm@0
|
44
|
andrewm@0
|
45 // Default constructor, containing a reference to the PianoKeyboard class.
|
andrewm@0
|
46 TouchkeyVibratoMappingFactory(PianoKeyboard &keyboard, MidiKeyboardSegment& segment);
|
andrewm@0
|
47
|
andrewm@0
|
48 // ***** Destructor *****
|
andrewm@0
|
49
|
andrewm@0
|
50 ~TouchkeyVibratoMappingFactory();
|
andrewm@0
|
51
|
andrewm@0
|
52 // ***** Accessors / Modifiers *****
|
andrewm@0
|
53
|
andrewm@0
|
54 virtual const std::string factoryTypeName() { return "Vibrato"; }
|
andrewm@7
|
55
|
andrewm@0
|
56 void setName(const string& name);
|
andrewm@0
|
57
|
andrewm@0
|
58 // ***** Vibrato-Specific Methods *****
|
andrewm@0
|
59
|
andrewm@0
|
60 int getVibratoControl() { return vibratoControl_; }
|
andrewm@0
|
61 float getVibratoRange() { return vibratoRange_; }
|
andrewm@0
|
62 float getVibratoPrescaler() { return vibratoPrescaler_; }
|
andrewm@0
|
63 float getVibratoThreshold() { return vibratoOnsetThresholdX_; }
|
andrewm@0
|
64 float getVibratoRatio() { return vibratoOnsetRatioX_; }
|
andrewm@0
|
65 timestamp_diff_type getVibratoTimeout() { return vibratoTimeout_; }
|
andrewm@0
|
66
|
andrewm@0
|
67 void setVibratoControl(int vibratoControl);
|
andrewm@0
|
68 void setVibratoRange(float range, bool updateCurrent = false);
|
andrewm@0
|
69 void setVibratoPrescaler(float prescaler, bool updateCurrent = false);
|
andrewm@0
|
70 void setVibratoThreshold(float threshold, bool updateCurrent = false);
|
andrewm@0
|
71 void setVibratoThresholds(float thresholdX, float thresholdY, float ratioX, float ratioY, bool updateCurrent = false);
|
andrewm@0
|
72 void setVibratoTimeout(timestamp_diff_type timeout, bool updateCurrent = false);
|
andrewm@0
|
73
|
andrewm@49
|
74 #ifndef TOUCHKEYS_NO_GUI
|
andrewm@0
|
75 // ***** GUI Support *****
|
andrewm@0
|
76 bool hasBasicEditor() { return true; }
|
andrewm@0
|
77 MappingEditorComponent* createBasicEditor();
|
andrewm@0
|
78 bool hasExtendedEditor() { return false; }
|
andrewm@0
|
79 MappingEditorComponent* createExtendedEditor() { return nullptr; }
|
andrewm@49
|
80 #endif
|
andrewm@49
|
81
|
andrewm@49
|
82 // ****** OSC Control Support ******
|
andrewm@49
|
83 OscMessage* oscControlMethod(const char *path, const char *types,
|
andrewm@49
|
84 int numValues, lo_arg **values, void *data);
|
andrewm@0
|
85
|
andrewm@35
|
86 // ****** Preset Save/Load ******
|
andrewm@35
|
87 XmlElement* getPreset();
|
andrewm@35
|
88 bool loadPreset(XmlElement const* preset);
|
andrewm@35
|
89
|
andrewm@0
|
90 private:
|
andrewm@0
|
91 // ***** Private Methods *****
|
andrewm@0
|
92 void initializeMappingParameters(int noteNumber, TouchkeyVibratoMapping *mapping);
|
andrewm@0
|
93
|
andrewm@0
|
94 void configurePitchWheelVibrato();
|
andrewm@0
|
95 void configureControlChangeVibrato();
|
andrewm@0
|
96
|
andrewm@0
|
97 int vibratoControl_; // Controller to use with vibrato
|
andrewm@0
|
98 float vibratoRange_; // Range that the vibrato should use, in semitones or CC values
|
andrewm@0
|
99 float vibratoPrescaler_; // Prescaler value to use before nonlinear vibrato mapping
|
andrewm@0
|
100 float vibratoTimeout_; // Timeout for vibrato detection
|
andrewm@0
|
101 float vibratoOnsetThresholdX_; // Thresholds for detection
|
andrewm@0
|
102 float vibratoOnsetThresholdY_;
|
andrewm@0
|
103 float vibratoOnsetRatioX_;
|
andrewm@0
|
104 float vibratoOnsetRatioY_;
|
andrewm@0
|
105 };
|
andrewm@0
|
106
|
andrewm@0
|
107 #endif /* defined(__touchkeys__TouchkeyVibratoMappingFactory__) */
|