-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
samba
committed
Jul 20, 2024
1 parent
81fe1c3
commit 3d8c31b
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "_model" | ||
|
||
local parameter_partId_placeholder = "xxx" | ||
|
||
function Create_Sysex_Message_For(part_id, parameter_node_id_template, value) | ||
local node_id = string.gsub(parameter_node_id_template, parameter_partId_placeholder, part_id) | ||
local nodeinfo = Get_Node(node_id) | ||
if nodeinfo == nil then | ||
error("no node found for id:" .. node_id) | ||
end | ||
nodeinfo.node:setvalue(value) | ||
local sysex = Create_SysexMessage(nodeinfo) | ||
return sysex | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
-- <command name="integra7" where="mod" using="lua/devices/integra7/integra7.lua"> | ||
-- A generic way to create integra7 parameter sysex messages | ||
-- </command> | ||
-- <param name="parameterId" optional="0" type="string">the parameter (node) id. As placeholder for the partId can `xxx` be used. For exampe `PRM-_PRF-_FPxxx-NEFP_OUT_ASGN`</param> | ||
-- <param name="value" optional="0" type="number|string">the value</param> | ||
-- <param name="partId" optional="1" type="0..15">specifies the part id. If not set, will be determined using its related instrument channel(s), assuming that the channel never changes.</param> | ||
|
||
|
||
require "lua/com/com" | ||
require "_integra7" | ||
|
||
parameters = { | ||
{ name="parameterId"}, | ||
{ name="value"}, | ||
{ name="partId", default=-1 }, | ||
} | ||
|
||
local function get_partids(params, context) | ||
if isnumber(params.partId) then | ||
return { tonumber(params.partId) } | ||
end | ||
local part_ids = {} | ||
local function get_id_from_instrument(instrument) | ||
if instrument.children ~= nil then | ||
for _, child in pairs(instrument.children) do | ||
get_id_from_instrument(child) | ||
end | ||
return | ||
end | ||
table.insert(part_ids, instrument.midiChannel + 1) | ||
end | ||
local instrument = context:getCurrentInstrument() | ||
get_id_from_instrument(instrument) | ||
return part_ids | ||
end | ||
|
||
|
||
function execute(params, timeinfo, context) | ||
local part_ids = get_partids(params, context) | ||
local messages = {} | ||
local value = tonumber(params.value) | ||
local node_id_template = params.parameterId | ||
for _, part_id in pairs(part_ids) do | ||
local sysex = Create_Sysex_Message_For(part_id, node_id_template, value) | ||
table.insert(messages, { | ||
["type"] = "sysex", | ||
["sysexData"] = sysex, | ||
}) | ||
end | ||
return messages | ||
end | ||
|
||
function perform(events, params, timeinfo, context) | ||
local messages = execute(params, timeinfo, context) | ||
for _, message in pairs(messages) do | ||
table.insert(events, message) | ||
end | ||
return events | ||
end |