From f10a6900c6b0b3d9aff5a2904862c2a0f67ac8cf Mon Sep 17 00:00:00 2001 From: zawz Date: Tue, 3 Mar 2020 10:25:14 +0100 Subject: [PATCH] Move to new zfd format --- Makefile | 4 +++- README.md | 2 +- help_format/mim-format | 5 +++-- help_format/zfd-format | 2 ++ include/format.hpp | 2 +- include/help.h | 4 ++-- src/format.cpp | 3 ++- src/system.cpp | 4 +++- 8 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 330bfec..c6dc143 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,11 @@ NAME = zmidimap LDFLAGS = -lpthread CC=g++ -CXXFLAGS= -I$(IDIR) -Wall -pedantic -std=c++17 -O2 +CXXFLAGS= -I$(IDIR) -Wall -pedantic -std=c++17 ifeq ($(DEBUG),true) CXXFLAGS += -g +else + CXXFLAGS += -O2 endif ifeq ($(STATIC),true) LDFLAGS += -l:libztd.a diff --git a/README.md b/README.md index 4412564..815eaf7 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Download the .deb package then run: `sudo dpkg -i zmidimap.deb ; sudo apt -f ins ### Standalone -Download ``zmidimap-static.tar.gz`` for a standalone executable without library dependency +Download ``zmidimap.tar.gz`` for a standalone executable ### From source diff --git a/help_format/mim-format b/help_format/mim-format index c575316..4a87ddd 100644 --- a/help_format/mim-format +++ b/help_format/mim-format @@ -21,5 +21,6 @@ Device > mandatory Shell command can be concatenated with \"\" or '' -Comments are written by starting a line with // -see --command-tags for optional command tags +Comments are written with // or # and end at end of line +Multiple tags can be put on the same line by separating them with ; +See --command-tags for optional command tags diff --git a/help_format/zfd-format b/help_format/zfd-format index f69ec33..b1099f5 100644 --- a/help_format/zfd-format +++ b/help_format/zfd-format @@ -1,5 +1,7 @@ -- [ZFD FILE FORMAT] -- +ZFD format: http://zawz.net/doc/ztd/zfd.html + [,] -- format -- diff --git a/include/format.hpp b/include/format.hpp index f19cc65..1039a51 100644 --- a/include/format.hpp +++ b/include/format.hpp @@ -3,7 +3,7 @@ #include -ztd::chunkdat mimtochk(const std::string& mim); +ztd::chunkdat mimtochk(std::string mim); std::string file_strimport(const std::string& path); diff --git a/include/help.h b/include/help.h index bb2eeac..5a68182 100644 --- a/include/help.h +++ b/include/help.h @@ -1,7 +1,7 @@ #ifndef HELP_H #define HELP_H -#define ZFD_FORMAT "zmidimap\n-- [ZFD FILE FORMAT] --\n\n[,]\n\n-- format --\n {\n name=\n commands=[,]\n }\n--\n*name: string referring to client name of the device\n\n format\n {\n type=\n shell=\n =\n =\n ...\n }\n--\n*type: type of the signal: note/controller/pitch/system/connect/disconnect\n > mandatory\n*shell: shell command to be executed\n > mandatory\n\nShell command can be concatenated with \"\" or ''\nsee --command-tags for optional command tags" -#define MIM_FORMAT "zmidimap\n-- [MIM FILE FORMAT] --\n\nDevice \n Command \n shell=\n =\n =\n ...\n\nDevice \n...\n\n--\n*name: string referring to client name of the device\n > mandatory\n*type: type of the signal: note/controller/pitch/system/connect/disconnect\n > mandatory\n*shell: shell command to be executed\n > mandatory\n\nShell command can be concatenated with \"\" or ''\nsee --command-tags for optional command tags" +#define ZFD_FORMAT "zmidimap\n-- [ZFD FILE FORMAT] --\n\nZFD format: http://zawz.net/doc/ztd/zfd.html\n\n[,]\n\n-- format --\n {\n name=\n commands=[,]\n }\n--\n*name: string referring to client name of the device\n\n format\n {\n type=\n shell=\n =\n =\n ...\n }\n--\n*type: type of the signal: note/controller/pitch/system/connect/disconnect\n > mandatory\n*shell: shell command to be executed\n > mandatory\n\nShell command can be concatenated with \"\" or ''\nsee --command-tags for optional command tags" +#define MIM_FORMAT "zmidimap\n-- [MIM FILE FORMAT] --\n\nDevice \n Command \n shell=\n =\n =\n ...\n Command \n ...\n\nDevice \n...\n\n--\n*name: string referring to client name of the device\n > mandatory\n*type: type of the signal: note/controller/pitch/system/connect/disconnect\n > mandatory\n*shell: shell command to be executed\n > mandatory\n\nShell command can be concatenated with \"\" or ''\nComments are written with // or # and end at end of line\nMultiple tags can be put on the same line by separating them with ;\nSee --command-tags for optional command tags" #define SHELL_FORMAT "zmidimap\n-- [SHELL FORMAT] --\n\nShell command follows regular shell format\n\n-- [Environment] --\n\n[Note]\n $id: id of the note\n $channel: channel of the note\n $velocity: velocity of the note\n\n[Controller]\n $value: value of the controller (remapped)\n $id: id of the controller\n $channel: channel of the controller\n $rawvalue: original value of the controller\n\n[Pitch]\n $value: value of the bend (remapped)\n $rawvalue: original value of the bend\n\n[System]\n $code: hexadecimal code of the system signal" #define COMMAND_TAGS "zmidimap\n-- [COMMAND TAGS] --\n\n[Note tags]\n id=\n channel=\n trigger=\n--\n *id: note id from 0 to 127\n > optional, default 0:127\n *channel: value from 0 to 16 for channel, * for any channel\n > optional, default *\n *trigger: note velocity from 0 to 127 that triggers the command\n > optional, default 1:127\n\n[Controller tags]\n id=\n channel=\n range=\n remap=\n float=\n--\n *id: controller id from 0 to 127\n > optional, default 0:127\n *channel: value from 0 to 16 for channel, * for any channel\n > optional, default *\n *range: controller value from 0 to 127 that triggers command\n > optional, default 0:127\n *remap: remaps the range to given interval\n > optional, default same as range\n *float: boolean value defining if output is a floating point value\n > optional, default false\n\n[Pitch bend tags]\n range=\n remap=\n float=\n--\n *range: controller value from -8192 to 8191 that triggers command\n > optional, default -8192:8191\n *remap: remaps the range to given interval\n > optional, default same as range\n *float: boolean value defining if output is a floating point value\n > optional, default false\n\n[Interval Format]\n x:y range from x to y\n x single value x\n * all possible values" #endif //HELP_H diff --git a/src/format.cpp b/src/format.cpp index d5a5bd9..871eb6f 100644 --- a/src/format.cpp +++ b/src/format.cpp @@ -71,8 +71,9 @@ ztd::chunkdat mimtochk_commands(const std::string& mim) return chk; } -ztd::chunkdat mimtochk(const std::string& mim) +ztd::chunkdat mimtochk(std::string mim) { + mim = ztd::filedat::removeComments(mim); ztd::chunkdat chk; unsigned int i=0,j=0; _find_next(mim,i, "Device "); diff --git a/src/system.cpp b/src/system.cpp index 92e24e4..86c1d5c 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -96,7 +96,9 @@ void announce_loop() device_check(); } - ztd::pclose2(stream, announce_thread_pid); + int ret = WEXITSTATUS(ztd::pclose2(stream, announce_thread_pid)); + if( ret != 0 ) + throw std::runtime_error("ALSA error"); if(buff != NULL) free(buff);