From 15b314d40692d4e86b5a030aab22e68c0f6aff51 Mon Sep 17 00:00:00 2001 From: cbdev Date: Mon, 23 Dec 2019 16:49:29 +0100 Subject: Multi-layering example configuration --- configs/layering.cfg | 18 ++++++++++++++ configs/layering.lua | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 configs/layering.cfg create mode 100644 configs/layering.lua diff --git a/configs/layering.cfg b/configs/layering.cfg new file mode 100644 index 0000000..3acfe5e --- /dev/null +++ b/configs/layering.cfg @@ -0,0 +1,18 @@ +[backend artnet] +bind = 0.0.0.0 + +[midi in] +read = Launch Control + +[artnet out] +destination = 255.255.255.255 +universe = 1 + +[lua layers] +script = layering.lua + +[map] +in.ch0.cc{0..15} > layers.in{0..15} +layers.out{0..511} > out.{1..512} + +in.ch0.note0 > layers.control diff --git a/configs/layering.lua b/configs/layering.lua new file mode 100644 index 0000000..0ced715 --- /dev/null +++ b/configs/layering.lua @@ -0,0 +1,70 @@ +current_layer = 0 + +function control(value) + current_layer = math.floor(value * 31.99); +end + +function in0(value) + output("out"..((current_layer * 16)), value) + print("Output on out"..((current_layer * 16))) +end + +function in1(value) + output("out"..((current_layer * 16)) + 1, value) +end + +function in2(value) + output("out"..((current_layer * 16)) + 2, value) +end + +function in3(value) + output("out"..((current_layer * 16)) + 3, value) +end + +function in4(value) + output("out"..((current_layer * 16)) + 4, value) +end + +function in5(value) + output("out"..((current_layer * 16)) + 5, value) +end + +function in6(value) + output("out"..((current_layer * 16)) + 6, value) +end + +function in7(value) + output("out"..((current_layer * 16)) + 7, value) +end + +function in8(value) + output("out"..((current_layer * 16)) + 8, value) +end + +function in9(value) + output("out"..((current_layer * 16)) + 9, value) +end + +function in10(value) + output("out"..((current_layer * 16)) + 10, value) +end + +function in11(value) + output("out"..((current_layer * 16)) + 11, value) +end + +function in12(value) + output("out"..((current_layer * 16)) + 12, value) +end + +function in13(value) + output("out"..((current_layer * 16)) + 13, value) +end + +function in14(value) + output("out"..((current_layer * 16)) + 14, value) +end + +function in15(value) + output("out"..((current_layer * 16)) + 15, value) +end -- cgit v1.2.3 From f4b448d304c22f7bf9c8b2675707d6924fbaba54 Mon Sep 17 00:00:00 2001 From: cbdev Date: Mon, 23 Dec 2019 17:56:38 +0100 Subject: Add some comments to the layering example --- configs/layering.cfg | 5 +++++ configs/layering.lua | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/configs/layering.cfg b/configs/layering.cfg index 3acfe5e..7adcd6f 100644 --- a/configs/layering.cfg +++ b/configs/layering.cfg @@ -1,3 +1,8 @@ +; This configuration demonstrates how to create a "layered" mapping +; using the Lua backend. The 'control' channel on the layers instance +; selects the offset to which the 16 input channels (mapped from +; the rotaries of a Launch Control) are mapped on the output instance + [backend artnet] bind = 0.0.0.0 diff --git a/configs/layering.lua b/configs/layering.lua index 0ced715..834ed09 100644 --- a/configs/layering.lua +++ b/configs/layering.lua @@ -1,9 +1,15 @@ +-- This global variable has the current base offset for the input channels. +-- We want to map 16 input channels (from MIDI) to 512 output channels (ArtNet), +-- so we have 32 possible offsets (32 * 16 = 512) current_layer = 0 +-- Set the current_layer based on the control input channel function control(value) current_layer = math.floor(value * 31.99); end +-- Handler functions for the input channels +-- Calculate the channel offset and just output the value the input channel provides function in0(value) output("out"..((current_layer * 16)), value) print("Output on out"..((current_layer * 16))) -- cgit v1.2.3 From 535181b25ccbc492f741b9eeb111a02dfd038b41 Mon Sep 17 00:00:00 2001 From: cbdev Date: Mon, 23 Dec 2019 20:22:14 +0100 Subject: Fix lua order of operations --- configs/layering.lua | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/configs/layering.lua b/configs/layering.lua index 834ed09..5d9458d 100644 --- a/configs/layering.lua +++ b/configs/layering.lua @@ -12,65 +12,65 @@ end -- Calculate the channel offset and just output the value the input channel provides function in0(value) output("out"..((current_layer * 16)), value) - print("Output on out"..((current_layer * 16))) + print("Output on out"..(current_layer * 16)) end function in1(value) - output("out"..((current_layer * 16)) + 1, value) + output("out"..((current_layer * 16) + 1), value) end function in2(value) - output("out"..((current_layer * 16)) + 2, value) + output("out"..((current_layer * 16) + 2), value) end function in3(value) - output("out"..((current_layer * 16)) + 3, value) + output("out"..((current_layer * 16) + 3), value) end function in4(value) - output("out"..((current_layer * 16)) + 4, value) + output("out"..((current_layer * 16) + 4), value) end function in5(value) - output("out"..((current_layer * 16)) + 5, value) + output("out"..((current_layer * 16) + 5), value) end function in6(value) - output("out"..((current_layer * 16)) + 6, value) + output("out"..((current_layer * 16) + 6), value) end function in7(value) - output("out"..((current_layer * 16)) + 7, value) + output("out"..((current_layer * 16) + 7), value) end function in8(value) - output("out"..((current_layer * 16)) + 8, value) + output("out"..((current_layer * 16) + 8), value) end function in9(value) - output("out"..((current_layer * 16)) + 9, value) + output("out"..((current_layer * 16) + 9), value) end function in10(value) - output("out"..((current_layer * 16)) + 10, value) + output("out"..((current_layer * 16) + 10), value) end function in11(value) - output("out"..((current_layer * 16)) + 11, value) + output("out"..((current_layer * 16) + 11), value) end function in12(value) - output("out"..((current_layer * 16)) + 12, value) + output("out"..((current_layer * 16) + 12), value) end function in13(value) - output("out"..((current_layer * 16)) + 13, value) + output("out"..((current_layer * 16) + 13), value) end function in14(value) - output("out"..((current_layer * 16)) + 14, value) + output("out"..((current_layer * 16) + 14), value) end function in15(value) - output("out"..((current_layer * 16)) + 15, value) + output("out"..((current_layer * 16) + 15), value) end -- cgit v1.2.3 From cedbf74db776414988621e8113f5869b29c2cb41 Mon Sep 17 00:00:00 2001 From: cbdev Date: Tue, 24 Dec 2019 00:50:05 +0100 Subject: Fix version define for Windows --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 75c9d0d..990aec3 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ midimonster: LDLIBS = -ldl # Replace version string with current git-describe if possible ifneq "$(GITVERSION)" "" midimonster: CFLAGS += -DMIDIMONSTER_VERSION=\"$(GITVERSION)\" +midimonster.exe: CFLAGS += -DMIDIMONSTER_VERSION=\"$(GITVERSION)\" endif # Work around strange linker passing convention differences in Linux and OSX -- cgit v1.2.3 From 67e0226e88efd01a3f6dd60759ce6bca029967dd Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 25 Dec 2019 11:45:27 +0100 Subject: Fix uninitialized variable --- backends/maweb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/maweb.c b/backends/maweb.c index 39a6cb2..f81ab46 100644 --- a/backends/maweb.c +++ b/backends/maweb.c @@ -752,7 +752,7 @@ static ssize_t maweb_handle_ws(instance* inst, ssize_t bytes_read){ static int maweb_handle_fd(instance* inst){ maweb_instance_data* data = (maweb_instance_data*) inst->impl; - ssize_t bytes_read, bytes_left = data->allocated - data->offset, bytes_handled; + ssize_t bytes_read, bytes_left = data->allocated - data->offset, bytes_handled = 0; if(bytes_left < 3){ data->buffer = realloc(data->buffer, (data->allocated + MAWEB_RECV_CHUNK) * sizeof(uint8_t)); -- cgit v1.2.3 From 85fc921042efa68b0a34a413dd84bb1ea7a998cc Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 28 Dec 2019 14:51:26 +0100 Subject: Check API pointer before use, fix spelling --- backend.c | 2 +- installer.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend.c b/backend.c index 2af2f37..a2b120f 100644 --- a/backend.c +++ b/backend.c @@ -189,7 +189,7 @@ void channels_free(){ size_t u; for(u = 0; u < nchannels; u++){ DBGPF("Destroying channel %lu on instance %s\n", channels[u]->ident, channels[u]->instance->name); - if(channels[u]->impl){ + if(channels[u]->impl && channels[u]->instance->backend->channel_free){ channels[u]->instance->backend->channel_free(channels[u]); } free(channels[u]); diff --git a/installer.sh b/installer.sh index c85b70e..15ad203 100755 --- a/installer.sh +++ b/installer.sh @@ -106,7 +106,7 @@ UPDATER-PREP () { printf "\nInitializing repository...\n" cd $tmp_path git init $tmp_path - printf "Sucessfully imported settings from %s\n" "$updater_file" + printf "Successfully imported settings from %s\n" "$updater_file" ) NIGHTLY_CHECK printf "Preparation successful\n\n" -- cgit v1.2.3 From f7e071444605ec72a6f4577dc7fc63b880d4dd61 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 28 Dec 2019 15:11:26 +0100 Subject: Fix OSX CI --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bdaf63a..7db9167 100644 --- a/.travis.yml +++ b/.travis.yml @@ -180,7 +180,8 @@ install: before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache ola lua openssl jack; fi +# 'brew install' sometimes returns non-zero for some arcane reason. Executing 'true' resets the exit code and allows Travis to continue building... + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache ola lua openssl jack; true; fi # OpenSSL is not a proper install due to some Apple bull, so provide additional locations via the environment... # Additionally, newer versions of this "recipe" seem to use the name 'openssl@1.1' instead of plain 'openssl' and there seems to be # no way to programmatically get the link and include paths. Genius! Hardcoding the new version for the time being... -- cgit v1.2.3 From e4374c59881032ef644fbb2fd54a554dc4d914b1 Mon Sep 17 00:00:00 2001 From: Spacelord Date: Tue, 31 Dec 2019 00:35:02 +0100 Subject: Automated travis deployment --- .travis-ci.sh | 33 ++++++++++++++++++++++++++++++++- .travis.yml | 10 ++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/.travis-ci.sh b/.travis-ci.sh index da36c17..593b254 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -76,9 +76,40 @@ elif [[ $TASK = 'windows' ]]; then travis_fold start "make_windows" make windows; travis_fold end "make_windows" + + if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then + mkdir ./deployment + mkdir ./deployment/backends + mkdir ./deployment/docs + cp ./midimonster.exe ./deployment/ + cp ./backends/*.dll ./deployment/backends/ + cp ./monster.cfg ./deployment/monster.cfg + cp ./backends/*.md ./deployment/docs/ + cp -r ./configs ./deployment/ + cd ./deployment + zip -r "./midimonster-$(git describe)-windows.zip" "./" + rm -v !("*.zip") + fi + + else # Otherwise compile as normal travis_fold start "make" make full; + +if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then + mkdir ./deployment + mkdir ./deployment/backends + mkdir ./deployment/docs + cp ./midimonster ./deployment/ + cp ./backends/*.so ./deployment/backends/ + cp ./monster.cfg ./deployment/monster.cfg + cp ./backends/*.md ./deployment/docs/ + cp -r ./configs ./deployment/ + cd ./deployment + tar czf "midimonster-$(git describe)-linux64.tgz" * + rm -v !("*.tgz") + fi + travis_fold end "make" -fi +fi \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 7db9167..3299c66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -200,3 +200,13 @@ before_install: after_script: - if [ "$TASK" = "coverity" ]; then tail -n 10000 ${TRAVIS_BUILD_DIR}/cov-int/build-log.txt; cat ${TRAVIS_BUILD_DIR}/cov-int/scm_log.txt; fi + +deploy: + provider: releases + api_key: $GITHUB_TOKEN +file: + - "./deployment/*" + skip_cleanup: true + draft: true + on: + tags: true \ No newline at end of file -- cgit v1.2.3 From bbcefdf737452e2fcb4b7703a6348825a2112994 Mon Sep 17 00:00:00 2001 From: Spacelord Date: Tue, 31 Dec 2019 00:42:12 +0100 Subject: fix travis deployment --- .travis.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3299c66..ea6ffc5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -204,9 +204,8 @@ after_script: deploy: provider: releases api_key: $GITHUB_TOKEN -file: - - "./deployment/*" - skip_cleanup: true - draft: true - on: - tags: true \ No newline at end of file + file: ./deployment/* + skip_cleanup: true + draft: true + on: + tags: true \ No newline at end of file -- cgit v1.2.3 From 54685b03160279242c51288a306f332c07c82625 Mon Sep 17 00:00:00 2001 From: Spacelord Date: Tue, 31 Dec 2019 00:55:00 +0100 Subject: Diversify automated deploy per host OS --- .travis-ci.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis-ci.sh b/.travis-ci.sh index 593b254..a50398b 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -88,7 +88,7 @@ elif [[ $TASK = 'windows' ]]; then cp -r ./configs ./deployment/ cd ./deployment zip -r "./midimonster-$(git describe)-windows.zip" "./" - rm -v !("*.zip") + rm -v !(*.zip) fi @@ -107,7 +107,7 @@ if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then cp ./backends/*.md ./deployment/docs/ cp -r ./configs ./deployment/ cd ./deployment - tar czf "midimonster-$(git describe)-linux64.tgz" * + tar czf "midimonster-$(git describe)-$TRAVIS_OS_NAME.tgz" * rm -v !("*.tgz") fi -- cgit v1.2.3 From 7d18bbb88b79c23c7e920eaecac75df77c38a02a Mon Sep 17 00:00:00 2001 From: cbdev Date: Tue, 31 Dec 2019 01:27:01 +0100 Subject: Fix deployment directory cleanup --- .travis-ci.sh | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/.travis-ci.sh b/.travis-ci.sh index a50398b..1475dea 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -76,7 +76,7 @@ elif [[ $TASK = 'windows' ]]; then travis_fold start "make_windows" make windows; travis_fold end "make_windows" - + travis_fold start "deploy_windows" if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then mkdir ./deployment mkdir ./deployment/backends @@ -88,28 +88,27 @@ elif [[ $TASK = 'windows' ]]; then cp -r ./configs ./deployment/ cd ./deployment zip -r "./midimonster-$(git describe)-windows.zip" "./" - rm -v !(*.zip) + find . ! -iname '*.zip' -delete fi - - + travis_fold end "deploy_windows" else # Otherwise compile as normal travis_fold start "make" make full; - -if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then - mkdir ./deployment - mkdir ./deployment/backends - mkdir ./deployment/docs - cp ./midimonster ./deployment/ - cp ./backends/*.so ./deployment/backends/ - cp ./monster.cfg ./deployment/monster.cfg - cp ./backends/*.md ./deployment/docs/ - cp -r ./configs ./deployment/ - cd ./deployment - tar czf "midimonster-$(git describe)-$TRAVIS_OS_NAME.tgz" * - rm -v !("*.tgz") - fi - travis_fold end "make" -fi \ No newline at end of file + travis_fold start "deploy_unix" + if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then + mkdir ./deployment + mkdir ./deployment/backends + mkdir ./deployment/docs + cp ./midimonster ./deployment/ + cp ./backends/*.so ./deployment/backends/ + cp ./monster.cfg ./deployment/monster.cfg + cp ./backends/*.md ./deployment/docs/ + cp -r ./configs ./deployment/ + cd ./deployment + tar czf "midimonster-$(git describe)-$TRAVIS_OS_NAME.tgz" * + find . ! -iname '*.tgz' -delete + fi + travis_fold end "deploy_unix" +fi -- cgit v1.2.3 From 599430276d4cc7ca3cec27513a5a318fd5e5de25 Mon Sep 17 00:00:00 2001 From: cbdev Date: Tue, 31 Dec 2019 01:53:23 +0100 Subject: Pull tags in CI before build --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea6ffc5..6c81d1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,6 @@ addons: - *core_build - mingw-w64 - matrix: fast_finish: true include: @@ -179,6 +178,8 @@ install: - if [ "$TASK" = "codespell" ]; then pip install --user git+https://github.com/codespell-project/codespell.git; fi before_install: +# Travis clones with --branch, which omits tags. Since we use them for the version string at build time, fetch them + - git pull --tags - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi # 'brew install' sometimes returns non-zero for some arcane reason. Executing 'true' resets the exit code and allows Travis to continue building... - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache ola lua openssl jack; true; fi @@ -208,4 +209,4 @@ deploy: skip_cleanup: true draft: true on: - tags: true \ No newline at end of file + tags: true -- cgit v1.2.3 From 87fe68ef7d929b2f79e695df649b374fe0e2c572 Mon Sep 17 00:00:00 2001 From: cbdev Date: Tue, 31 Dec 2019 10:33:29 +0100 Subject: Enable globs for Travis deployments --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6c81d1b..21c2a40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -204,6 +204,7 @@ after_script: deploy: provider: releases + file_glob: true api_key: $GITHUB_TOKEN file: ./deployment/* skip_cleanup: true -- cgit v1.2.3 From 3098484d9d8ab3becd6d82297c13963f359460f4 Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 1 Jan 2020 20:16:52 +0100 Subject: Do not install default config if already present (Fixes #43) --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 990aec3..27f7994 100644 --- a/Makefile +++ b/Makefile @@ -79,8 +79,10 @@ install: install -d "$(DESTDIR)$(EXAMPLES)" install -m 0644 configs/* "$(DESTDIR)$(EXAMPLES)" ifdef DEFAULT_CFG +ifeq (,$(wildcard $(DEFAULT_CFG))) install -Dm 0644 monster.cfg "$(DESTDIR)$(DEFAULT_CFG)" endif +endif sanitize: export CC = clang sanitize: export CFLAGS += -g -Wall -Wpedantic -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -- cgit v1.2.3 From 871bc1568f94ee4026fd64df062572b91d45d462 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 4 Jan 2020 18:39:04 +0100 Subject: Add input_channel call to Lua backend --- backends/lua.c | 22 ++++++++++++++++++++++ backends/lua.md | 6 +++--- midimonster.h | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/backends/lua.c b/backends/lua.c index ee9e03f..510fc72 100644 --- a/backends/lua.c +++ b/backends/lua.c @@ -9,6 +9,7 @@ #endif #define LUA_REGISTRY_KEY "_midimonster_lua_instance" +#define LUA_REGISTRY_CURRENT_CHANNEL "_midimonster_lua_channel" static size_t timers = 0; static lua_timer* timer = NULL; @@ -189,6 +190,7 @@ static int lua_callback_interval(lua_State* interpreter){ if(lua_gettable(interpreter, LUA_REGISTRYINDEX) == LUA_TNUMBER){ //already interval'd reference = luaL_checkinteger(interpreter, 4); + DBGPF("Updating interval to %" PRIu64 " msec", interval); } else if(interval){ //get a reference to the function @@ -199,6 +201,8 @@ static int lua_callback_interval(lua_State* interpreter){ lua_pushvalue(interpreter, 1); lua_pushinteger(interpreter, reference); lua_settable(interpreter, LUA_REGISTRYINDEX); + + DBGPF("Registered interval with %" PRIu64 " msec", interval); } //find matching timer @@ -273,6 +277,12 @@ static int lua_callback_output_value(lua_State* interpreter){ return lua_callback_value(interpreter, 0); } +static int lua_callback_input_channel(lua_State* interpreter){ + lua_pushstring(interpreter, LUA_REGISTRY_CURRENT_CHANNEL); + lua_gettable(interpreter, LUA_REGISTRYINDEX); + return 1; +} + static int lua_configure(char* option, char* value){ LOG("No backend configuration possible"); return 1; @@ -320,6 +330,7 @@ static instance* lua_instance(){ lua_register(data->interpreter, "interval", lua_callback_interval); lua_register(data->interpreter, "input_value", lua_callback_input_value); lua_register(data->interpreter, "output_value", lua_callback_output_value); + lua_register(data->interpreter, "input_channel", lua_callback_input_channel); //store instance pointer to the lua state lua_pushstring(data->interpreter, LUA_REGISTRY_KEY); @@ -374,6 +385,11 @@ static int lua_set(instance* inst, size_t num, channel** c, channel_value* v){ data->input[c[n]->ident] = v[n].normalised; //call lua channel handlers if present if(data->reference[c[n]->ident] != LUA_NOREF){ + //push the channel name + lua_pushstring(data->interpreter, LUA_REGISTRY_CURRENT_CHANNEL); + lua_pushstring(data->interpreter, data->channel_name[c[n]->ident]); + lua_settable(data->interpreter, LUA_REGISTRYINDEX); + lua_rawgeti(data->interpreter, LUA_REGISTRYINDEX, data->reference[c[n]->ident]); lua_pushnumber(data->interpreter, v[n].normalised); if(lua_pcall(data->interpreter, 1, 0, 0) != LUA_OK){ @@ -382,6 +398,11 @@ static int lua_set(instance* inst, size_t num, channel** c, channel_value* v){ } } } + + //clear the channel name + lua_pushstring(data->interpreter, LUA_REGISTRY_CURRENT_CHANNEL); + lua_pushnil(data->interpreter); + lua_settable(data->interpreter, LUA_REGISTRYINDEX); return 0; } @@ -422,6 +443,7 @@ static int lua_handle(size_t num, managed_fd* fds){ timer[n].delta %= timer[n].interval; lua_rawgeti(timer[n].interpreter, LUA_REGISTRYINDEX, timer[n].reference); lua_pcall(timer[n].interpreter, 0, 0, 0); + DBGPF("Calling interval timer function %" PRIsize_t, n); } } } diff --git a/backends/lua.md b/backends/lua.md index f38e189..650fdb9 100644 --- a/backends/lua.md +++ b/backends/lua.md @@ -16,7 +16,7 @@ The following functions are provided within the Lua interpreter for interaction | `interval(function, number)` | `interval(update, 100)` | Register a function to be called periodically. Intervals are milliseconds (rounded to the nearest 10 ms) | | `input_value(string)` | `input_value("foo")` | Get the last input value on a channel | | `output_value(string)` | `output_value("bar")` | Get the last output value on a channel | - +| `input_channel()` | `print(input_channel())` | Returns the name of the input channel whose handler function is currently running or `nil` if in an `interval`'ed function (or the initial parse step) | Example script: ``` @@ -58,8 +58,8 @@ lua1.foo > lua2.bar #### Known bugs / problems -Using any of the interface functions (`output`, `interval`, `input_value`, `output_value`) as an -input channel name to a Lua instance will not call any handler functions. +Using any of the interface functions (`output`, `interval`, `input_value`, `output_value`, `input_channel`) +as an input channel name to a Lua instance will not call any handler functions. Using these names as arguments to the output and value interface functions works as intended. Output values will not trigger corresponding input event handlers unless the channel is mapped diff --git a/midimonster.h b/midimonster.h index 5844bb9..c5a6cf5 100644 --- a/midimonster.h +++ b/midimonster.h @@ -7,7 +7,7 @@ /* Core version unless set by the build process */ #ifndef MIDIMONSTER_VERSION - #define MIDIMONSTER_VERSION "v0.3-dist" + #define MIDIMONSTER_VERSION "v0.4-dist" #endif /* Set backend name if unset */ -- cgit v1.2.3 From f8ed6c26683c041ec61dac46d740b4b87df811ad Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 4 Jan 2020 18:58:19 +0100 Subject: Build the Lua backend on Windows using CI --- .travis-ci.sh | 1 + .travis.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.travis-ci.sh b/.travis-ci.sh index 1475dea..c278b33 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -75,6 +75,7 @@ elif [[ $TASK = 'windows' ]]; then # Run sanitized compile travis_fold start "make_windows" make windows; + make -C backends lua.dll travis_fold end "make_windows" travis_fold start "deploy_windows" if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then diff --git a/.travis.yml b/.travis.yml index 21c2a40..5c0a3ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -198,6 +198,8 @@ before_install: #OS X uses something other than $CXX variable - if [ "$TRAVIS_OS_NAME" == "linux" -a \( "$TASK" = "compile" -o "$TASK" = "sanitize" \) ]; then $CXX --version; fi - if [ "$TASK" == "spellintian" -o "$TASK" == "spellintian-duplicates" ]; then wget "http://archive.ubuntu.com/ubuntu/pool/main/l/lintian/lintian_2.5.104_all.deb"; sudo dpkg -i lintian_*.deb; sudo apt-get install -f -y; fi # Install a later lintian +# Download libraries to link with on Windows + - if [ "$TASK" == "windows" ]; then mkdir libs; wget "https://downloads.sourceforge.net/project/luabinaries/5.3.5/Windows%20Libraries/Dynamic/lua-5.3.5_Win64_dllw6_lib.zip" -O lua53.zip; unzip lua53.zip lua53.dll; mv lua53.dll libs; fi after_script: - if [ "$TASK" = "coverity" ]; then tail -n 10000 ${TRAVIS_BUILD_DIR}/cov-int/build-log.txt; cat ${TRAVIS_BUILD_DIR}/cov-int/scm_log.txt; fi -- cgit v1.2.3 From e08b473d0eeb467ad358ba5314157753b4f37c18 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 5 Jan 2020 23:26:04 +0100 Subject: Implement commandline config override (Fixes #26) --- README.md | 7 ++ config.c | 364 ++++++++++++++++++++++++++++++++++++++-------------------- config.h | 44 +++++++ midimonster.c | 29 ++++- midimonster.h | 24 ---- 5 files changed, 314 insertions(+), 154 deletions(-) diff --git a/README.md b/README.md index e955d53..2496dfa 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ The MIDImonster takes as it's first argument the name of an optional configurati to use (`monster.cfg` is used as default if none is specified). The configuration file syntax is explained in the next section. +The current MIDIMonster version can be queried by passing *-v* as command-line argument. + ## Configuration Each protocol supported by MIDIMonster is implemented by a *backend*, which takes @@ -76,6 +78,11 @@ To make an instance available for mapping channels, it requires at least the `[ ]` configuration stanza. Most backends require additional configuration for their instances. +Backend and instance configuration options can also be overriden via command line +arguments using the syntax `-b .