123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #ifndef PADSELECTIONCONFIGURATION_H
- #define PADSELECTIONCONFIGURATION_H
- class MidiMessage;
- #include <json/json.h>
- class PadSelection;
- class InputOperation
- {
- public:
- enum OperationType {TRANSLATION, DROP, RANGE, REORDER};
- InputOperation(OperationType t) : m_type(t){}
- virtual ~InputOperation(){}
- virtual MidiMessage* execute(PadSelection*, MidiMessage* in, int i) const=0;
- OperationType get_type() const {return m_type;}
- static InputOperation* from_json(Json::Value&);
- protected:
- OperationType m_type;
- };
- class TranslationOperation : public InputOperation
- {
- public:
- enum Mode {FIXED, RELATIVE, UNCHANGED};
- TranslationOperation() : InputOperation(TRANSLATION){
- m_channel=m_key=m_velocity=0;
- m_channel_mode=m_key_mode=m_velocity_mode=RELATIVE;
- }
- TranslationOperation(Json::Value& v);
- virtual ~TranslationOperation(){}
- void set(int ch, int k, int vel){
- m_channel=ch;
- m_key=k;
- m_velocity=vel;
- }
- void set_mode(Mode ch, Mode k, Mode vel){
- if(ch!=UNCHANGED) m_channel_mode=ch;
- if(k!=UNCHANGED) m_key_mode=k;
- if(vel!=UNCHANGED) m_velocity_mode=vel;
- }
- virtual MidiMessage* execute(PadSelection*, MidiMessage* m, int i) const;
- static Mode parse_mode(const std::string& v);
- protected:
- Mode m_channel_mode;
- int m_channel;
- Mode m_key_mode;
- int m_key;
- Mode m_velocity_mode;
- int m_velocity;
- };
- class DropOperation : public InputOperation
- {
- public:
- enum Mode {FIXED, RELATIVE, UNCHANGED};
- DropOperation() : InputOperation(DROP){
- }
- virtual ~DropOperation(){}
- virtual MidiMessage* execute(PadSelection*, MidiMessage* m, int i) const {return NULL;}
- protected:
- };
- class ReorderOperation : public InputOperation
- {
- public:
- ReorderOperation() : InputOperation(REORDER){
- m_offset=0;
- }
- ReorderOperation(Json::Value& v);
- virtual ~ReorderOperation(){}
- virtual MidiMessage* execute(PadSelection*, MidiMessage* m, int i) const ;
- protected:
- int m_offset;
- };
- class RangeOperation : public InputOperation
- {
- public:
- RangeOperation() : InputOperation(RANGE){
- }
- RangeOperation(Json::Value& v) : InputOperation(RANGE)
- {
- m_key = v["key"].asInt();
- m_length = v["length"].asInt();
- Json::Value a = v["range"];
- int s = a.size();
- for(int i=0; i<s; i++) m_range.push_back(a[i].asInt());
- }
- virtual ~RangeOperation(){}
- virtual MidiMessage* execute(PadSelection*, MidiMessage* m, int i) const;
- protected:
- std::vector<int> m_range;
- int m_key;
- int m_length;
- };
- #endif // PADSELECTIONCONFIGURATION_H
|