-
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 16, 2024
1 parent
6b280dd
commit 2e29fb0
Showing
13 changed files
with
318 additions
and
113 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,58 @@ | ||
-- <command name="integra7" where="mod" using="lua/devices/integra7/integra7.lua"> | ||
-- creates 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/devices/integra7/_model" | ||
require "lua/com/com" | ||
|
||
parameters = { | ||
-- { name="parameterId"}, | ||
-- { name="value"}, | ||
-- { name="partId", default=-1 }, | ||
} | ||
|
||
local function get_partids(params) | ||
if params.partIdsFromInstrument ~= nil then | ||
return params.partIdsFromInstrument | ||
end | ||
if isnumber(params.partId) then | ||
return { tonumber(params.partId) } | ||
end | ||
local function get_id_from_instrument() | ||
|
||
end | ||
end | ||
|
||
function execute(params, timeinfo) | ||
local part_ids = get_partids(params); | ||
local value = tonumber(params.value) | ||
local node_id = string.format(NODE_ID_TEMPLATE, part_nr) | ||
|
||
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 { | ||
{ | ||
["type"] = "sysex", | ||
["sysexData"] = sysex, | ||
} | ||
} | ||
end | ||
|
||
local function get_partids_from_instrument(events) | ||
|
||
end | ||
|
||
function perform(events, params, timeinfo) | ||
params.partIdsFromInstrument = get_partids_from_instrument(events) | ||
local midiMessage = execute(params, timeinfo) | ||
table.insert(events, midiMessage[1]) | ||
return events | ||
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
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
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,25 @@ | ||
|
||
using "./modinstrumentinfo.lua"; | ||
|
||
device: _setName=MyDevice _isType=midi _useDevice="FLUID Synth"; | ||
instrumentDef: _setName=piano _onDevice=MyDevice _ch=0 _pc=1 _cc=8; | ||
|
||
instrumentDef: _setName=p1 _onDevice=MyDevice _ch=1 _pc=100; | ||
instrumentDef: _setName=p2 _onDevice=MyDevice _ch=2 _pc=12; | ||
instrumentSection: mySection p1 p2; | ||
|
||
[ | ||
instrument: piano; | ||
{ | ||
/call: modinstrumentinfo/ | ||
c d e f | g a b c' | ||
} | ||
] | ||
|
||
[ | ||
instrument: mySection; | ||
{ | ||
/call: modinstrumentinfo/ | ||
c, d, e, f, | g, a, b, c | ||
} | ||
] |
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,30 @@ | ||
using "/chords/default.chords"; | ||
using "../../examples/lua/devices/integra7/integra7.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 | ||
mod integra7 | ||
; | ||
|
||
[ | ||
type: template; | ||
name: chords; | ||
instrument: guitar; | ||
{ | ||
<II III V VII I>1 :(x3) | ||
|: | ||
<I II III V VII>1 :(x3)| | ||
} | ||
] | ||
|
||
[ | ||
type: accomp; | ||
{ | ||
/template: chords/ | ||
C | F | G7 :| | ||
} | ||
] |
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
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 |
---|---|---|
|
@@ -23,4 +23,4 @@ instrument: mySection; | |
/mod: modinstrumentinfo/ | ||
c, d, e, f, | g, a, b, c | ||
} | ||
] | ||
] |
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
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,101 @@ | ||
#include "luaContext.h" | ||
#include <lua.hpp> | ||
#include <compiler/context/IContext.h> | ||
#include <compiler/Instrument.h> | ||
|
||
static const char *LUA_CONTEXT_PROPETRY_CURRENT_INSTRUMENT = "getCurrentInstrument"; | ||
static const char *LUA_EVENT_PROPETRY_INSTRUMENT = "instrument"; | ||
static const char *LUA_INSTRUMENT_PROPERTY_CHILDREN = "children"; | ||
static const char *LUA_INSTRUMENT_PROPERTY_NAME = "name"; | ||
static const char *LUA_INSTRUMENT_PROPERTY_VOLUME = "volume"; | ||
static const char *LUA_INSTRUMENT_PROPERTY_PAN = "pan"; | ||
static const char *LUA_INSTRUMENT_PROPERTY_MIDI_CHANNEL = "midiChannel"; | ||
static const char *LUA_INSTRUMENT_PROPERTY_MIDI_MSB = "midiMsb"; | ||
static const char *LUA_INSTRUMENT_PROPERTY_MIDI_LSB = "midiLsb"; | ||
static const char *LUA_INSTRUMENT_PROPERTY_MIDI_PC = "midiPc"; | ||
|
||
namespace lua | ||
{ | ||
|
||
static void pushInstrument(lua_State *L, compiler::IContext &ctx, compiler::AInstrumentDefPtr instrument) | ||
{ | ||
lua_createtable(L, 4, 0); | ||
if (!instrument) | ||
{ | ||
return; | ||
} | ||
auto top = lua_gettop(L); | ||
// | ||
lua_pushstring(L, LUA_INSTRUMENT_PROPERTY_NAME); | ||
lua_pushstring(L, instrument->uname.c_str()); | ||
lua_settable(L, top); | ||
// | ||
lua_pushstring(L, LUA_INSTRUMENT_PROPERTY_VOLUME); | ||
lua_pushnumber(L, instrument->volume); | ||
lua_settable(L, top); | ||
// | ||
lua_pushstring(L, LUA_INSTRUMENT_PROPERTY_PAN); | ||
lua_pushnumber(L, instrument->pan); | ||
lua_settable(L, top); | ||
// | ||
auto instrumentSection = std::dynamic_pointer_cast<compiler::InstrumentSectionDef>(instrument); | ||
if (instrumentSection) | ||
{ | ||
lua_pushstring(L, LUA_INSTRUMENT_PROPERTY_CHILDREN); | ||
lua_createtable(L, instrumentSection->instrumentNames.size(), 0); | ||
auto childrenTop = lua_gettop(L); | ||
int index = 1; | ||
for (const auto &uname : instrumentSection->instrumentNames) | ||
{ | ||
auto instrumentDef = ctx.getInstrumentDef(uname); | ||
lua_pushinteger(L, index++); | ||
pushInstrument(L, ctx, instrumentDef); | ||
lua_settable(L, childrenTop); | ||
} | ||
lua_settable(L, top); | ||
return; | ||
} | ||
// | ||
auto midiInstrument = std::dynamic_pointer_cast<compiler::MidiInstrumentDef>(instrument); | ||
if (!midiInstrument) | ||
{ | ||
return; | ||
} | ||
lua_pushstring(L, LUA_INSTRUMENT_PROPERTY_MIDI_CHANNEL); | ||
lua_pushinteger(L, midiInstrument->channel); | ||
lua_settable(L, top); | ||
// | ||
lua_pushstring(L, LUA_INSTRUMENT_PROPERTY_MIDI_MSB); | ||
lua_pushinteger(L, midiInstrument->bankMsb); | ||
lua_settable(L, top); | ||
// | ||
lua_pushstring(L, LUA_INSTRUMENT_PROPERTY_MIDI_LSB); | ||
lua_pushinteger(L, midiInstrument->bankLsb); | ||
lua_settable(L, top); | ||
// | ||
lua_pushstring(L, LUA_INSTRUMENT_PROPERTY_MIDI_PC); | ||
lua_pushinteger(L, midiInstrument->pc); | ||
lua_settable(L, top); | ||
} | ||
|
||
static int getCurrentInstrument(lua_State *L) | ||
{ | ||
using namespace lua; | ||
auto luaContext = ALuaObject::getObject<LuaContext>(L, -1); | ||
auto top = lua_gettop(L); | ||
// instrument | ||
auto& context = luaContext->context; | ||
auto instrument = context.currentInstrumentDef(); | ||
pushInstrument(L, context, instrument); | ||
return 1; | ||
} | ||
|
||
static const luaL_Reg libfs[] = { | ||
{"getCurrentInstrument", getCurrentInstrument}, | ||
{NULL, NULL}}; | ||
|
||
void LuaContext::push(lua_State *L) | ||
{ | ||
Base::push(L, libfs, 1); | ||
} | ||
} |
Oops, something went wrong.