/ HALion Developer Resource / HALion Script / Reference /

onRetrigger

onRetrigger(event)

(Since HALion 7.0)

Description

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

❕ Note-retrigger events occur only if Mono and Retrigger are active for the corresponding program or layer.

Available in: Processor.

Arguments

ArgumentDescriptionValue Type
eventEvent object of the type noteRetrigger.Event

Fields

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

FieldDescriptionValue Type
.typeThe type of event (6 = noteRetrigger). 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
.tuningThe tune offset in semitones.number

❕ The note ids of the note-retrigger events cannot be used in functions like releaseVoice, changeVolume, changeNoteExpression, etc. You must use the note id of the original note-on event instead. See Example 2 for details.

Example 1

notes = {}
 
function onNote(event)
    local id = postEvent(event)
    print(event)
    local ids = notes[event.note]
    if ids == nil then
        ids = {}
        notes[event.note] = ids
    end
    table.insert(ids, id)
end
 
-- transpose the note-retrigger event
function onRetrigger(event)
    print(event)
    local id = playNote(event.note + 12, event.velocity, 0)
    table.insert(notes[event.note], id)
end
 
function onRelease(event)
    print(event)
    for i, noteId in ipairs(notes[event.note]) do
        releaseVoice(noteId)
    end
    notes[event.note] = nil
end

Example 2

notes = {}
retrigger = {}
function onNote(event)
    local id = postEvent(event)
    print(event)
    retrigger[event.note] = false
    local ids = notes[event.note]
    if ids == nil then
        ids = {}
        notes[event.note] = ids
    end
    table.insert(ids, id)
end
   
-- send the note-retrigger event after 500 ms into release and retrigger only once
function onRetrigger(event)
    if not retrigger[event.note] then
        postEvent(event)
        print(event)
        retrigger[event.note] = true
        wait(500)
        if notes[event.note] then
            for i, noteId in ipairs(notes[event.note]) do
                releaseVoice(noteId)
                print("releaseVoice with id "..noteId)
            end
        end
    end
end
   
function onRelease(event)
    postEvent(event)
    print(event)
    notes[event.note] = nil
end

See also: onNote, onRelease, releaseVoice, postEvent, playNote