From 64043e815c6018cff8b6cca3a543c0de080d0736 Mon Sep 17 00:00:00 2001 From: p3r7 <11557146+p3r7@users.noreply.github.com> Date: Sat, 16 Sep 2023 14:50:50 +0200 Subject: [PATCH 1/8] seamstress support --- lib/nb.lua | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/nb.lua b/lib/nb.lua index a67ea3f..1fe222e 100644 --- a/lib/nb.lua +++ b/lib/nb.lua @@ -1,5 +1,13 @@ -local mydir = debug.getinfo(1).source:match("@?" .. _path.code .. "(.*/)") +local mydir +if norns then + mydir = debug.getinfo(1).source:match("@?" .. _path.code .. "(.*/)") +elseif seamstress then + mydir = debug.getinfo(1).source:match("@?" .. seamstress.state.path .. "/(.*/)") +end local player_lib = include(mydir .. "player") +if seamstress and _menu == nil then + _menu = paramsMenu +end local nb = {} if note_players == nil then @@ -23,11 +31,24 @@ local abbreviate = function(s) end local function add_midi_players() - for i, v in ipairs(midi.vports) do + local devices + if norns then + devices = midi.vports + elseif seamstress then + devices = midi.outputs + end + + for i, v in pairs(devices) do + for j = 1, nb.voice_count do (function(i, j) - if v.connected then - local conn = midi.connect(i) + if seamstress or v.connected then + local conn + if norns then + conn = midi.connect(i) + elseif seamstress then + conn = midi.connect_output(i) + end local player = { conn = conn } From 29fa65e3637d964050739ff5c6dbe0033387c199 Mon Sep 17 00:00:00 2001 From: p3r7 <11557146+p3r7@users.noreply.github.com> Date: Sat, 16 Sep 2023 16:34:32 +0200 Subject: [PATCH 2/8] now fiwed in latest seamstress release --- lib/nb.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/nb.lua b/lib/nb.lua index 1fe222e..67685e1 100644 --- a/lib/nb.lua +++ b/lib/nb.lua @@ -5,9 +5,6 @@ elseif seamstress then mydir = debug.getinfo(1).source:match("@?" .. seamstress.state.path .. "/(.*/)") end local player_lib = include(mydir .. "player") -if seamstress and _menu == nil then - _menu = paramsMenu -end local nb = {} if note_players == nil then From 779e7421489d44ea83e579ae00d2c431d16537c8 Mon Sep 17 00:00:00 2001 From: p3r7 <11557146+p3r7@users.noreply.github.com> Date: Tue, 14 Nov 2023 22:32:09 +0100 Subject: [PATCH 3/8] semastress midi hanbdling got closer to norns' in the meantime --- lib/nb.lua | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/lib/nb.lua b/lib/nb.lua index 67685e1..99d825b 100644 --- a/lib/nb.lua +++ b/lib/nb.lua @@ -28,26 +28,15 @@ local abbreviate = function(s) end local function add_midi_players() - local devices - if norns then - devices = midi.vports - elseif seamstress then - devices = midi.outputs - end - - for i, v in pairs(devices) do + for i, v in pairs(midi.vports) do - for j = 1, nb.voice_count do + for j = 1, nb.voice_count do (function(i, j) if seamstress or v.connected then local conn - if norns then - conn = midi.connect(i) - elseif seamstress then - conn = midi.connect_output(i) - end + conn = midi.connect(i) local player = { - conn = conn + conn = conn } function player:add_params() params:add_group("midi_voice_" .. i .. '_' .. j, "midi " .. j .. ": " .. abbreviate(v.name), 3) From c36a54cf08c0e15c2f2df885cb149be87697ca5b Mon Sep 17 00:00:00 2001 From: p3r7 <11557146+p3r7@users.noreply.github.com> Date: Tue, 14 Nov 2023 22:32:50 +0100 Subject: [PATCH 4/8] handle edge-case: scripts w/ "-" in their path --- lib/nb.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/nb.lua b/lib/nb.lua index 99d825b..c9d14d7 100644 --- a/lib/nb.lua +++ b/lib/nb.lua @@ -2,7 +2,8 @@ local mydir if norns then mydir = debug.getinfo(1).source:match("@?" .. _path.code .. "(.*/)") elseif seamstress then - mydir = debug.getinfo(1).source:match("@?" .. seamstress.state.path .. "/(.*/)") + local escaped_script_path, _ = seamstress.state.path:gsub("[%(%)%.%+%-%*%?%[%]%^%$%%]", "%%%1") + mydir = debug.getinfo(1).source:match("@?" .. escaped_script_path .. "/(.*/)") end local player_lib = include(mydir .. "player") local nb = {} From 4d03e8c76e795883ec4a8bce78327925eb3a056c Mon Sep 17 00:00:00 2001 From: p3r7 <11557146+p3r7@users.noreply.github.com> Date: Tue, 14 Nov 2023 23:16:55 +0100 Subject: [PATCH 5/8] format --- lib/nb.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/nb.lua b/lib/nb.lua index c9d14d7..88643e0 100644 --- a/lib/nb.lua +++ b/lib/nb.lua @@ -1,9 +1,9 @@ local mydir if norns then - mydir = debug.getinfo(1).source:match("@?" .. _path.code .. "(.*/)") + mydir = debug.getinfo(1).source:match("@?" .. _path.code .. "(.*/)") elseif seamstress then - local escaped_script_path, _ = seamstress.state.path:gsub("[%(%)%.%+%-%*%?%[%]%^%$%%]", "%%%1") - mydir = debug.getinfo(1).source:match("@?" .. escaped_script_path .. "/(.*/)") + local escaped_script_path, _ = seamstress.state.path:gsub("[%(%)%.%+%-%*%?%[%]%^%$%%]", "%%%1") + mydir = debug.getinfo(1).source:match("@?" .. escaped_script_path .. "/(.*/)") end local player_lib = include(mydir .. "player") local nb = {} @@ -30,14 +30,13 @@ end local function add_midi_players() for i, v in pairs(midi.vports) do - for j = 1, nb.voice_count do (function(i, j) if seamstress or v.connected then local conn conn = midi.connect(i) local player = { - conn = conn + conn = conn } function player:add_params() params:add_group("midi_voice_" .. i .. '_' .. j, "midi " .. j .. ": " .. abbreviate(v.name), 3) From cd5a71062818365126ec6c3a11283efac18df364 Mon Sep 17 00:00:00 2001 From: p3r7 <11557146+p3r7@users.noreply.github.com> Date: Tue, 14 Nov 2023 23:17:58 +0100 Subject: [PATCH 6/8] optim: seamstress vports are now always continuous/sorted --- lib/nb.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nb.lua b/lib/nb.lua index 88643e0..d06006c 100644 --- a/lib/nb.lua +++ b/lib/nb.lua @@ -29,7 +29,7 @@ local abbreviate = function(s) end local function add_midi_players() - for i, v in pairs(midi.vports) do + for i, v in ipairs(midi.vports) do for j = 1, nb.voice_count do (function(i, j) if seamstress or v.connected then From e8f6430189fb0301809274cdd135ef7a0bee9c19 Mon Sep 17 00:00:00 2001 From: p3r7 <11557146+p3r7@users.noreply.github.com> Date: Tue, 14 Nov 2023 23:24:17 +0100 Subject: [PATCH 7/8] semastress vports now also have the connected prop (always true) --- lib/nb.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/nb.lua b/lib/nb.lua index d06006c..7d77e06 100644 --- a/lib/nb.lua +++ b/lib/nb.lua @@ -32,9 +32,8 @@ local function add_midi_players() for i, v in ipairs(midi.vports) do for j = 1, nb.voice_count do (function(i, j) - if seamstress or v.connected then - local conn - conn = midi.connect(i) + if v.connected then + local conn = midi.connect(i) local player = { conn = conn } From 12f20236719a1ad92b9a50babc2cc9dc72f4f120 Mon Sep 17 00:00:00 2001 From: p3r7 <11557146+p3r7@users.noreply.github.com> Date: Tue, 14 Nov 2023 23:26:27 +0100 Subject: [PATCH 8/8] damn tab vs spaces --- lib/nb.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nb.lua b/lib/nb.lua index 7d77e06..2a7b4ad 100644 --- a/lib/nb.lua +++ b/lib/nb.lua @@ -29,10 +29,10 @@ local abbreviate = function(s) end local function add_midi_players() - for i, v in ipairs(midi.vports) do - for j = 1, nb.voice_count do + for i, v in ipairs(midi.vports) do + for j = 1, nb.voice_count do (function(i, j) - if v.connected then + if v.connected then local conn = midi.connect(i) local player = { conn = conn