view Source/Mappings/Control/TouchkeyControlMappingFactory.h @ 20:dfff66c07936

Lots of minor changes to support building on Visual Studio. A few MSVC-specific #ifdefs to eliminate things Visual Studio doesn't like. This version now compiles on Windows (provided liblo, Juce and pthread are present) but the TouchKeys device support is not yet enabled. Also, the code now needs to be re-checked on Mac and Linux.
author Andrew McPherson <andrewm@eecs.qmul.ac.uk>
date Sun, 09 Feb 2014 18:40:51 +0000
parents 3580ffe87dc8
children e8965409903e
line wrap: on
line source
/*
  TouchKeys: multi-touch musical keyboard control software
  Copyright (c) 2013 Andrew McPherson

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
  =====================================================================

  TouchkeyControlMappingFactory.h: factory for the TouchKeys control
  mapping, which converts an arbitrary touch parameter into a MIDI or
  OSC control message.
*/


#ifndef __touchkeys__TouchkeyControlMappingFactory__
#define __touchkeys__TouchkeyControlMappingFactory__

#include <iostream>

#include "../TouchkeyBaseMappingFactory.h"
#include "TouchkeyControlMapping.h"

// Factory class to produce Touchkey control messages for generic MIDI/OSC controllers

class TouchkeyControlMappingFactory : public TouchkeyBaseMappingFactory<TouchkeyControlMapping> {
private:
    static const int kDefaultController;
    static const float kDefaultOutputRangeMin;
    static const float kDefaultOutputRangeMax;
    static const float kDefaultOutputDefault;
    
public:
    // ***** Constructor *****
    
	// Default constructor, containing a reference to the PianoKeyboard class.
    TouchkeyControlMappingFactory(PianoKeyboard &keyboard, MidiKeyboardSegment& segment);
	
    // ***** Destructor *****
    
    ~TouchkeyControlMappingFactory();
    
    // ***** Accessors / Modifiers *****
    
    virtual const std::string factoryTypeName() { return "Control"; }

    // ***** Class-Specific Methods *****

    int getController() { return midiControllerNumber_; }
    int getInputParameter() { return inputParameter_; }
    int getInputType() { return inputType_; }
    float getRangeInputMin() { return inputRangeMin_; }
    float getRangeInputMax() { return inputRangeMax_; }
    float getRangeInputCenter() { return inputRangeCenter_; }
    float getRangeOutputMin() { return outputRangeMin_; }
    float getRangeOutputMax() { return outputRangeMax_; }
    float getRangeOutputDefault() { return outputDefault_; }
    float getThreshold() { return threshold_; }
    bool getIgnoresTwoFingers() { return ignoresTwoFingers_; }
    bool getIgnoresThreeFingers() { return ignoresThreeFingers_; }
    int getDirection() { return direction_; }
    
    void setInputParameter(int inputParameter);
    void setInputType(int inputType);
    void setController(int controller);
    //void setRange(float inputMin, float inputMax, float inputCenter, float outputMin, float outputMax, float outputDefault);
    void setRangeInputMin(float inputMin);
    void setRangeInputMax(float inputMax);
    void setRangeInputCenter(float inputCenter);
    void setRangeOutputMin(float outputMin);
    void setRangeOutputMax(float outputMax);
    void setRangeOutputDefault(float outputDefault);
    void setThreshold(float threshold);
    void setIgnoresTwoFingers(bool ignoresTwo);
    void setIgnoresThreeFingers(bool ignoresThree);
    void setDirection(int direction);
    
    // ***** GUI Support *****
    bool hasBasicEditor() { return true; }
    MappingEditorComponent* createBasicEditor();
    bool hasExtendedEditor() { return false; }
    MappingEditorComponent* createExtendedEditor() { return nullptr; }
    
private:
    // ***** Private Methods *****
    void initializeMappingParameters(int noteNumber, TouchkeyControlMapping *mapping);

    int inputParameter_;                                // Type of input data
    int inputType_;                                     // Whether data is absolute or relative
    //float inputRangeMin_, inputRangeMax_;               // Input ranges
    float outputRangeMin_, outputRangeMax_;             // Output ranges
    float outputDefault_;                               // Default values
    float threshold_;                                   // Detection threshold for relative motion
    bool ignoresTwoFingers_;                            // Whether this mapping suspends messages when two
    bool ignoresThreeFingers_;                          // or three fingers are present
    int direction_;                                     // Whether the mapping uses the absolute value in negative cases
};

#endif /* defined(__touchkeys__TouchkeyControlMappingFactory__) */