Page tree
Skip to end of metadata
Go to start of metadata

onRelease(event)

Description

This callback function is called when the script module receives a note-off event.

Available in: Processor.

Arguments

event

Fields

Note-off events use the following fields of the Event object.

.typeThe type of event (2 = noteOff). See Event Types for details.number
.idThe note ID of the note-off event.number
.noteThe note number in the range of 0 to 127.number
.velocityThe note-off velocity in the range of 0 to 127.number

Example

-- print all held notes
local heldNotes = {}

function stringOfNotes()
    local ret =""
    for note, velocity in pairs(heldNotes) do
        ret = ret.." "..tostring(note)
    end
    return ret
end

function onNote(event)
    heldNotes[event.note] = event.velocity
    print("Held notes:", stringOfNotes())
    local id = postEvent(event)
end

function onRelease(event)
    heldNotes[event.note] = nil
    print("Held notes:", stringOfNotes())
    postEvent(event)
end

1 Comment