Jam Origin

MIDI Guitar & MIDI Bass user forum

OnFrame Bug

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.

1 Like

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:
            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")

function OnNote(channel, pitch, velocity)
	fd:write(os.time(os.date("!*t")), ",note,", pitch, ",", velocity, "\n")

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")

function OnStop()
1 Like