Loopp/src/controller/genericmidi.hxx

120 lines
2.7 KiB
C++
Raw Normal View History

2013-09-06 15:18:27 +02:00
#ifndef LUPPP_GENERIC_MIDI_H
#define LUPPP_GENERIC_MIDI_H
#include "controller.hxx"
2013-10-08 15:12:55 +02:00
#include <map>
#include <string>
#include <vector>
2013-09-25 19:07:53 +02:00
2013-10-03 12:24:34 +02:00
#include "../cjson/cJSON.h"
2013-09-06 15:18:27 +02:00
#include "../observer/midi.hxx"
/// a LupppAction represents the Event type, as from Event.hxx
typedef int LupppAction;
2013-09-25 19:07:53 +02:00
2013-09-26 21:51:22 +02:00
class Binding
{
public:
2013-10-03 12:24:34 +02:00
Binding() : status(0), data(0), action(0), active(false),track(-2),scene(-1),send(-1){}
unsigned char status;
unsigned char data;
/// the action this binding relates to: this is an integer based on the
/// event.hxx enumeration of event types
LupppAction action;
2013-09-26 21:51:22 +02:00
/// arguments to the event: track number, scene number etc
2013-10-03 02:18:06 +02:00
int active;
2013-09-26 21:51:22 +02:00
int track;
int scene;
2013-10-03 02:18:06 +02:00
int send;
2013-10-08 15:12:55 +02:00
std::map<int,int> clipStateMap;
};
/** GenericMIDI
* This class is used to load a <controller>.cfg JSON file as a MIDI map.
* The name parameter is the name of the JACK MIDI ports that are registered.
**/
2013-10-02 18:42:52 +02:00
class GenericMIDI : public Controller, public MidiIO
2013-09-06 15:18:27 +02:00
{
public:
/// Loads
GenericMIDI(std::string file);
2013-09-06 15:18:27 +02:00
2013-10-01 17:04:59 +02:00
int registerComponents();
Controller::STATUS status();
std::string getName();
2013-09-06 15:18:27 +02:00
/// track actions
//void mute(int t, bool b);
void metronomeEnable(bool b);
2013-09-26 21:51:22 +02:00
void launchScene( int scene );
2013-09-06 15:18:27 +02:00
void volume(int t, float f);
2013-10-08 15:12:55 +02:00
2013-10-08 15:29:35 +02:00
void recordArm(int t, bool b);
2013-10-08 15:12:55 +02:00
void setSceneState(int track, int clip, GridLogic::State s);
2013-09-06 15:18:27 +02:00
/*
void progress(int t, int s, float f);
void launchScene( int scene );
/// track FX
void trackSend(int t, int send, float v);
*/
2013-10-08 15:29:35 +02:00
void trackSend(int t, int send, float v);
void trackSendActive(int t, int send, bool a);
2013-09-06 15:18:27 +02:00
void reset();
void midi(unsigned char* data);
void process(int nframes);
// for adding bindings from MIDI / GUI event pair
void setupBinding( LupppAction eventType, int midiStatus, int midiData, int track );
2013-09-06 15:18:27 +02:00
private:
STATUS stat;
std::string name;
/// contains midi binding instances
std::vector<Binding*> midiToAction;
std::vector<Binding*> actionToMidi;
2013-09-25 19:07:53 +02:00
int loadController(std::string controllerFile);
2013-09-06 15:18:27 +02:00
2013-10-03 12:24:34 +02:00
/// creates a binding from a cJSON inputBindings / outputBindings object
Binding* setupBinding( cJSON* bindings );
/// for "sampling" a clip in the grid, and applying events to it:
/// footpedal for example
bool shiftPressed;
2013-09-06 15:18:27 +02:00
int footpedalTrack;
int footpedalScene;
/*
2013-09-06 15:18:27 +02:00
/// for handling events
void ccChange( int track, int cc, float value );
void noteOff( int track, int note, int vel );
void noteOn( int track, int note, int vel );
*/
};
#endif // LUPPP_GENERIC_MIDI_H
2013-09-06 15:18:27 +02:00