diff --git a/README b/README index 88672d4..ab2c7b4 100644 --- a/README +++ b/README @@ -25,24 +25,25 @@ To scan a device's inputs use `$ aseqdump -p ` Format is a regular shell format -- Environment -- Global -$channel: channel of the - - - Note $id: id of the note +$channel: channel of the note $velocity: velocity of the note - Controller -$id: id of the controller $value: value of the controller (remapped) +$id: id of the controller +$channel: channel of the controller $rawvalue: original value of the controller -- Pitch bend +- Pitch $value: value of the bend (remapped) $rawvalue: original value of the bend +- System +$code: hexadecimal code of the system signal + -- FILE FORMAT -- [,] @@ -57,32 +58,33 @@ $rawvalue: original value of the bend - format (global): { - type= + type= shell= - channel=<*/x> } - *type: type of the signal: note/controller/pitch > mandatory *shell: shell command to be executed > mandatory -*channel: value from 0 to 16 for channel. Can use * for any channel - > optional, default * - format (note) { id= + channel=<*/x> trigger= } - *id: value from 0 to 127 referring to id of note/controller > optional, default 0:127 +*channel: value from 0 to 16 for channel. Can use * for any channel + > optional, default * *trigger: note velocity from 0 to 127 that triggers the command. Can enter an interval x:y or single value > optional, default 1:127 - format (controller) { id= + channel=<*/x> range= remap= float= @@ -90,6 +92,8 @@ $rawvalue: original value of the bend - *id: value from 0 to 127 referring to id of note/controller > optional, default 0:127 +*channel: value from 0 to 16 for channel. Can use * for any channel + > optional, default * *range: controller value from 0 to 127 that triggers command. Can enter an interval x:y or single value > optional, default 0:127 *remap: remaps the range to given interval. Interval can be inversed and float diff --git a/include/command.hpp b/include/command.hpp index 295b23f..0cccedf 100644 --- a/include/command.hpp +++ b/include/command.hpp @@ -9,7 +9,7 @@ class NoteCommand { public: - NoteCommand(int8_t ch, uint8_t l, uint8_t h, std::string sh); + NoteCommand(int8_t ch, uint8_t l, uint8_t h, std::string const& sh); int8_t channel; uint8_t low; @@ -21,7 +21,7 @@ class ControllerCommand { public: - ControllerCommand(int8_t ch, uint8_t l, uint8_t h, float ml, float mm, bool fl, std::string sh); + ControllerCommand(int8_t ch, uint8_t l, uint8_t h, float ml, float mm, bool fl, std::string const& sh); int8_t channel; uint8_t min; @@ -36,7 +36,7 @@ class PitchCommand { public: - PitchCommand(uint8_t ch, int16_t l, int16_t h, float ml, float mh, bool fl, std::string sh); + PitchCommand(uint8_t ch, int16_t l, int16_t h, float ml, float mh, bool fl, std::string const& sh); int8_t channel; int16_t min; @@ -47,5 +47,13 @@ public: std::string shell; }; +class SystemCommand +{ +public: + + SystemCommand(std::string const& sh); + + std::string shell; +}; #endif //COMMAND_HPP diff --git a/include/device.hpp b/include/device.hpp index 144f410..68f923f 100644 --- a/include/device.hpp +++ b/include/device.hpp @@ -28,7 +28,7 @@ public: std::vector noteCommands[128]; std::vector ctrlCommands[128]; std::vector pitchCommands; - // std::vector sysCommands; + std::vector sysCommands; std::thread thread; private: diff --git a/src/command.cpp b/src/command.cpp index 3eac0b3..45ace6e 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -1,6 +1,6 @@ #include "command.hpp" -NoteCommand::NoteCommand(int8_t ch, uint8_t l, uint8_t h, std::string sh) +NoteCommand::NoteCommand(int8_t ch, uint8_t l, uint8_t h, std::string const& sh) { this->channel=ch; this->low=l; @@ -8,7 +8,7 @@ NoteCommand::NoteCommand(int8_t ch, uint8_t l, uint8_t h, std::string sh) this->shell=sh; } -ControllerCommand::ControllerCommand(int8_t ch, uint8_t l, uint8_t h, float ml, float mh, bool fl, std::string sh) +ControllerCommand::ControllerCommand(int8_t ch, uint8_t l, uint8_t h, float ml, float mh, bool fl, std::string const& sh) { this->channel=ch; this->min=l; @@ -19,7 +19,7 @@ ControllerCommand::ControllerCommand(int8_t ch, uint8_t l, uint8_t h, float ml, this->shell=sh; } -PitchCommand::PitchCommand(uint8_t ch, int16_t l, int16_t h, float ml, float mh, bool fl, std::string sh) +PitchCommand::PitchCommand(uint8_t ch, int16_t l, int16_t h, float ml, float mh, bool fl, std::string const& sh) { this->channel=ch; this->min=l; @@ -29,3 +29,8 @@ PitchCommand::PitchCommand(uint8_t ch, int16_t l, int16_t h, float ml, float mh, this->floating=fl; this->shell=sh; } + +SystemCommand::SystemCommand(std::string const& sh) +{ + this->shell=sh; +} diff --git a/src/device.cpp b/src/device.cpp index 612fea3..f5cb8bc 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -113,7 +113,9 @@ bool Device::import_chunk(Chunk const& ch) std::string tstr=tch["type"].strval(); if(tstr == "system") //type system { - throw std::runtime_error("System commands not implemented yet"); + std::string shell; + shell=tch["shell"].strval(); + this->sysCommands.push_back(SystemCommand(shell)); } else { @@ -237,10 +239,23 @@ void Device::run_signal(char* buff) else if (index(buff, ':') != NULL) // MIDI command { - if (strstr(buff, "System exclusive") != NULL) + if (strstr(buff, "System exclusive") != NULL) //system exclusive { - printf("%s", buff); - //do stuff + char* val=buff+35; + std::string strval; + while(*val != '\n') + { + if(*val != ' ') + strval += *val; + val++; + } + + for( auto it : this->sysCommands ) + { + std::string command="code=" + strval + ";"; + command += it.shell; + std::thread(sh, command).detach(); + } } else {