@moono i just added it now! i’ve tested it and it seems to work fine, but why don’t you give it a test run and let me know?
it turned out to be a little tricky to code since it needs to accommodate any possible engine function.
here’s how it works:
if you want to add your engine function (or any function for that matter!) you can use the following, an example using the polyperc engine.
engine.name = 'PolyPerc'
MusicUtil=require "musicutil"
if util.file_exists(_path.code.."tmi") then
tmi=include("tmi/lib/tmi")
m=tmi:new({
functions={
{name="polyperc",note_on="engine.amp(<velocity>/127); engine.hz(MusicUtil.note_num_to_freq(<note>))"},
},
})
end
as you can see there is a functions map that you can pass to tmi now. inside that is where the magic happens.
the “name” gives your thing an identifier. the “note_on” defines some lua code to run when a note goes on. the lua code can be anything you want. the lua code can take two values - the midi note ("<note>") and the velocity ("<velocity>", ranging 0-127). its basically up to you to make sure these values fit into whatever function you want. for instance, for the PolyPerc engine you have to enter use engine.amp, so you have the scale the velocity by 127 for it work. similarly, the PolyPerc engine needs to emit notes with the frequency, not the midi note so you have to convert it using the MusicUtil.
you can also write a similar function for note_off which is emitted when notes go off, but PolyPerc doesn’t really have a note off since its one-shots.
this new syntax gives a lot of flexibility. you can write whatever lua code you want to run when notes go “on” and “off” and you can have as many functions as you want. you don’t have to include “<note>” or “<velocity>”, but if you do make sure to transform them for your own purpose within your lua code.