I’m using the lua Midi Machine interface and surprised that the OnFrame notes
value doesn’t adjust its velocity to represent the sustain/decay of a strum. Instead, it just holds a constant velocity until it diminishes.
Is this intended behavior?
I’m using the lua Midi Machine interface and surprised that the OnFrame notes
value doesn’t adjust its velocity to represent the sustain/decay of a strum. Instead, it just holds a constant velocity until it diminishes.
Is this intended behavior?
The OnFrame notes have the initial velocity of the note.
The OnAfterTouch will give you what you are after, if I recall.
added to that: for the aftertouch to work in the midmachines, you also have to enable the aftertouch in the interface.
Excellent. Got it working.
Code ends up as follows!
-- Documentation here:
-- https://www.jamorigin.com/products/midi-machine/
--[[
Getting started. On UNIX machines, you can side-step
the (finicky) IAC MIDI Bus by directly piping MIDI data
to a named pipe. To create one, use the following command:
mkfifo /tmp/midi_guitar_pipe
After which you might write some Python3 that looks like:
with open("/tmp/midi_guitar_pipe") as f:
os.set_blocking(f.fileno(), False)
while True:
time.sleep(0.001)
for msg in f.readlines():
...
Extra note. Lua's time construct only emits whole-seconds-accuracy with os.time. I use this value to discard values more than one second old (as is occasionally case on a fresh start-up)
--]]
function OnAfterTouch(channel, pitch, velocity)
fd:write(os.time(os.date("!*t")), ",aftertouch,", pitch, ",", velocity, "\n")
fd:flush()
end
function OnNote(channel, pitch, velocity)
fd:write(os.time(os.date("!*t")), ",note,", pitch, ",", velocity, "\n")
fd:flush()
end
function OnStart(info)
-- assign a description to be displayed in the header
info.description = "This machine will log the number of notes used."
info.link = "http://jamorigin.com/midi-machine"
-- Read Getting Started up to to see how to use this.
fd = io.open("/tmp/midi_guitar_pipe", "a")
end
function OnStop()
fd:close()
end