Add support for system reserved signals
This commit is contained in:
parent
c146f55d48
commit
20dd41e434
5 changed files with 53 additions and 21 deletions
24
README
24
README
|
|
@ -25,24 +25,25 @@ To scan a device's inputs use `$ aseqdump -p <client name>`
|
|||
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 --
|
||||
[<device>,<device>]
|
||||
|
|
@ -57,32 +58,33 @@ $rawvalue: original value of the bend
|
|||
|
||||
- <command> format (global):
|
||||
{
|
||||
type=<note/controller/pitch>
|
||||
type=<note/controller/pitch/system>
|
||||
shell=<shell command>
|
||||
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 *
|
||||
|
||||
- <command> format (note)
|
||||
{
|
||||
id=<x/x:y/*>
|
||||
channel=<*/x>
|
||||
trigger=<x/x:y/*>
|
||||
}
|
||||
-
|
||||
*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
|
||||
|
||||
- <command> format (controller)
|
||||
{
|
||||
id=<x/x:y/*>
|
||||
channel=<*/x>
|
||||
range=<x/x:y/*>
|
||||
remap=<x/x:y/*>
|
||||
float=<true/false>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public:
|
|||
std::vector<NoteCommand> noteCommands[128];
|
||||
std::vector<ControllerCommand> ctrlCommands[128];
|
||||
std::vector<PitchCommand> pitchCommands;
|
||||
// std::vector<Command> sysCommands;
|
||||
std::vector<SystemCommand> sysCommands;
|
||||
|
||||
std::thread thread;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue