Skip to content

Commit

Permalink
impl more i7 mods
Browse files Browse the repository at this point in the history
  • Loading branch information
samba committed Jul 20, 2024
1 parent 492d0c4 commit c02dbff
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 2 deletions.
68 changes: 68 additions & 0 deletions examples/lua/devices/integra7/i7mfxtype.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
-- <command name="i7mfxtype" where="voicingStrategy" using="lua/voicings/inversion.lua">
-- set the mfx type for a part.
-- </command>
-- <param name="partId" optional="-1" type="1..16" type="number">the part number, will be detected via instrument channel if not set.</param>
-- <param name="typeNr" type="0..67" type="number">the mfx type</param>
-- <param name="toneType" type="[sna, sns, snd, pcms, pcmd]">the type of the tone on the target part</param>
-- <param name="deviceId" optional="1" type="number">an alternative device id</param>

require "lua/com/com"
require "_model"
require "_integra7"
local i7p = require "i7parameter"

parameters = {
{ name="partId", default=-1 },
{ name="typeNr" },
{ name="toneType" },
{ name="deviceId", default=17 },
}

local toneTypeMap = {
sna = Mfx_Types.SNA,
sns = Mfx_Types.SNS,
snd = Mfx_Types.SND,
pcms = Mfx_Types.PCMS,
pcmd = Mfx_Types.PCMD
}


function execute(params, timeinfo, context)
local part_ids = i7p.get_partids(params, context)
local mfxType = toneTypeMap[params.toneType]
if mfxType == nil then
error("invalid tone type " .. params.toneType)
end
local typeNr = tonumber(params.typeNr)
if typeNr < 0 or typeNr > 67 then
error("typeNr out of bounds " .. typeNr)
end
local device_id = tonumber(params.deviceId)
if device_id == nil or device_id < 17 or device_id > 32 then
error("invalid device id: " .. device_id)
end
local messages = {}
for _, part_id in pairs(part_ids) do
local sysex = Get_Set_Mfx_Type_Messages(mfxType, part_id, typeNr, device_id)
table.insert(messages, { -- set type
["type"] = "sysex",
["sysexData"] = sysex[2],
})
-- table.insert(messages, { -- set default values
-- ["type"] = "sysex",
-- ["offset"] = -2,
-- ["sysexData"] = sysex[2],
-- })
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

return {execute = execute}
11 changes: 9 additions & 2 deletions examples/lua/devices/integra7/i7parameter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-- <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>

-- <param name="deviceId" optional="1" type="number">an alternative device id</param>

require "lua/com/com"
require "_integra7"
Expand All @@ -13,6 +13,7 @@ parameters = {
{ name="parameterId"},
{ name="value"},
{ name="partId", default=-1 },
{ name="deviceId", default=17 },
}

local function get_partids(params, context)
Expand Down Expand Up @@ -40,6 +41,10 @@ function execute(params, timeinfo, context)
local messages = {}
local value = tonumber(params.value)
local node_id_template = params.parameterId
local device_id = tonumber(params.deviceId)
if device_id == nil or device_id < 17 or device_id > 32 then
error("invalid device id: " .. device_id)
end
for _, part_id in pairs(part_ids) do
local sysex = Create_Sysex_Message_For_Node(part_id, node_id_template, value)
table.insert(messages, {
Expand All @@ -56,4 +61,6 @@ function perform(events, params, timeinfo, context)
table.insert(events, message)
end
return events
end
end

return {execute = execute, get_partids = get_partids}
38 changes: 38 additions & 0 deletions examples/lua/devices/integra7/i7sntcmod.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-- <command name="i7sntcmod" where="voicingStrategy" using="lua/voicings/inversion.lua">
-- set a mod value for a sna tone type instrument
-- </command>
-- <param name="partId" optional="-1" type="1..16" type="number">the part number, will be detected via instrument channel if not set.</param>
-- <param name="modNr" type="1..32" type="number">the mod number.</param>
-- <param name="value" type="number">the value</param>
-- <param name="deviceId" optional="1" type="number">an alternative device id</param>

require "lua/com/com"
local i7p = require "i7parameter"

parameters = {
{ name="partId", default=-1 },
{ name="modNr"},
{ name="value"},
{ name="deviceId", default=17 },
}

local node_id_template = "PRM-_FPARTxxx-_SNTONE-_SNTC-SNTC_MOD_PRM%i"

function execute(params, timeinfo, context)
local modNr = tonumber(params.modNr)
if modNr < 1 or modNr > 32 then
error("modNr out of bounds " .. modNr)
end
params.parameterId = string.format(node_id_template, modNr)
return i7p.execute(params, timeinfo, context)
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

return {execute = execute}
44 changes: 44 additions & 0 deletions rendertests/tests/integra7-mfx.sheet
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- #skip-event-plausibility-test
using "/chords/default.chords";
using "../../examples/lua/devices/integra7/i7mfxtype.lua";
using "../../examples/lua/mods/myArpeggio.lua";

tempo: 150;
device: MyDevice midi _useDevice="DIN 3";
instrumentDef:guitar _onDevice=MyDevice _ch=0; -- _pc=0 _bankMsb=89 _bankLsb=64 _pc=5;
instrumentConf: guitar
mod myArpeggio
--mod i7mfxtype _toneType="sna" _typeNr=51
;


[
instrument: guitar;
{
r1 |
/call: i7mfxtype _toneType="sna" _typeNr=51/
r1
}
]

[
type: template;
name: chords;
instrument: guitar;
{
<II III V VII I>1 :(x3) |
|:
<I II III V VII>1 :(x3)|
}
]



[
type: accomp;
{
/template: chords/
r1 | r1 |
C | F | G7 :(x10)|
}
]
34 changes: 34 additions & 0 deletions rendertests/tests/integra7-tonevar.sheet
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- #skip-event-plausibility-test
using "/chords/default.chords";
using "../../examples/lua/devices/integra7/i7sntcmod.lua";
using "../../examples/lua/mods/myArpeggio.lua";

tempo: 150;
device: MyDevice midi _useDevice="DIN 3";
instrumentDef:guitar _onDevice=MyDevice _pc=0 _ch=6 _bankMsb=89 _bankLsb=64 _pc=97;
instrumentConf: guitar
mod myArpeggio
;

[
type: template;
name: chords;
instrument: guitar;
{
/modOnce: i7sntcmod _modNr=10 _value=2/
<II III V VII I>1 :(x3)
|:
/modOnce: i7sntcmod _modNr=10 _value=1/
<I II III V VII>1 :(x3)|
}
]



[
type: accomp;
{
/template: chords/
C | F | G7 :|
}
]

0 comments on commit c02dbff

Please sign in to comment.