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: TouchkeyVibratoMappingFactory.h: factory for the vibrato mapping class, andrewm@0: which creates vibrato through side-to-side motion of the finger on the andrewm@0: key surface. andrewm@0: */ andrewm@0: andrewm@0: #ifndef __touchkeys__TouchkeyVibratoMappingFactory__ andrewm@0: #define __touchkeys__TouchkeyVibratoMappingFactory__ andrewm@0: andrewm@0: #include andrewm@0: andrewm@0: #include "../TouchkeyBaseMappingFactory.h" andrewm@0: #include "TouchkeyVibratoMapping.h" andrewm@0: andrewm@0: // Factory class to produce Touchkey vibrato (pitch-bend) mappings 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 TouchkeyVibratoMappingFactory : public TouchkeyBaseMappingFactory { andrewm@0: private: andrewm@0: static const int kDefaultVibratoControl; andrewm@0: andrewm@0: public: andrewm@0: andrewm@0: // ***** Constructor ***** andrewm@0: andrewm@0: // Default constructor, containing a reference to the PianoKeyboard class. andrewm@0: TouchkeyVibratoMappingFactory(PianoKeyboard &keyboard, MidiKeyboardSegment& segment); andrewm@0: andrewm@0: // ***** Destructor ***** andrewm@0: andrewm@0: ~TouchkeyVibratoMappingFactory(); andrewm@0: andrewm@0: // ***** Accessors / Modifiers ***** andrewm@0: andrewm@0: virtual const std::string factoryTypeName() { return "Vibrato"; } andrewm@7: andrewm@0: void setName(const string& name); andrewm@0: andrewm@0: // ***** Vibrato-Specific Methods ***** andrewm@0: andrewm@0: int getVibratoControl() { return vibratoControl_; } andrewm@0: float getVibratoRange() { return vibratoRange_; } andrewm@0: float getVibratoPrescaler() { return vibratoPrescaler_; } andrewm@0: float getVibratoThreshold() { return vibratoOnsetThresholdX_; } andrewm@0: float getVibratoRatio() { return vibratoOnsetRatioX_; } andrewm@0: timestamp_diff_type getVibratoTimeout() { return vibratoTimeout_; } andrewm@0: andrewm@0: void setVibratoControl(int vibratoControl); andrewm@0: void setVibratoRange(float range, bool updateCurrent = false); andrewm@0: void setVibratoPrescaler(float prescaler, bool updateCurrent = false); andrewm@0: void setVibratoThreshold(float threshold, bool updateCurrent = false); andrewm@0: void setVibratoThresholds(float thresholdX, float thresholdY, float ratioX, float ratioY, bool updateCurrent = false); andrewm@0: void setVibratoTimeout(timestamp_diff_type timeout, bool updateCurrent = false); 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@35: // ****** Preset Save/Load ****** andrewm@35: XmlElement* getPreset(); andrewm@35: bool loadPreset(XmlElement const* preset); andrewm@35: andrewm@0: private: andrewm@0: // ***** Private Methods ***** andrewm@0: void initializeMappingParameters(int noteNumber, TouchkeyVibratoMapping *mapping); andrewm@0: andrewm@0: void configurePitchWheelVibrato(); andrewm@0: void configureControlChangeVibrato(); andrewm@0: andrewm@0: int vibratoControl_; // Controller to use with vibrato andrewm@0: float vibratoRange_; // Range that the vibrato should use, in semitones or CC values andrewm@0: float vibratoPrescaler_; // Prescaler value to use before nonlinear vibrato mapping andrewm@0: float vibratoTimeout_; // Timeout for vibrato detection andrewm@0: float vibratoOnsetThresholdX_; // Thresholds for detection andrewm@0: float vibratoOnsetThresholdY_; andrewm@0: float vibratoOnsetRatioX_; andrewm@0: float vibratoOnsetRatioY_; andrewm@0: }; andrewm@0: andrewm@0: #endif /* defined(__touchkeys__TouchkeyVibratoMappingFactory__) */