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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

The event class describes the properties of events.

On this page:

Classes

Event Class

Description

The state of an Event object is described by the following fields.

Available in: Processor.

Fields

.typeThe type of event. See Event Types for details.number
.idThe ID of the event.number
.noteThe note number in the range of 0 to 127.number
.velocityThe note-on velocity in the range of 0 to 127.number
.controllerThe controller number. See Controller Numbers for a description of the different controllers.number
.valueThe value of a controller, pitch bend or note expression event. The value range depends on the event type.number
.bendThe value of a pitch bend event in the range of -1.0 to 1.0.number
.noteExpressionTypeThe type of note expression event. See Note Expression Types for details.number
.ppqPositionThe position of the event in ppq relative to the song start. The host must be in in playback. This value will be 0.0 if the host is not in playback.number

Fields per Event Type

Which of the fields are used, depends on the Event Type.

 noteOn

noteOff

controllernoteExpression
.type(tick)(tick)(tick)(tick)
.id(tick)(tick) (tick)
.note(tick)(tick)  
.velocity(tick)(tick)  
.controller  (tick) 
.value  (tick)(tick)
.bend  (tick) 
.noteExpressionType   (tick)
.ppqPosition(tick)(tick)(tick)(tick)

Example

-- print the fields of an Event object
function printEventMembers(event)
    print("Event Type:", event.type)
    print("ID:", event.id)
    print("Note #:", event.note)
    print("Velocity:", event.velocity)
    print("Controller #:", event.controller)
    print("Value:", event.value)
    print("Pitch Bend:", event.bend)
    print("Note Expression Type:", event.noteExpressionType)
    print("PPQ:", event.ppqPosition, "\n")
end

function onNote(event)
    printEventMembers(event)
    postEvent(event)
end

function onRelease(event)
    printEventMembers(event)
    postEvent(event)
end
 
function onController(event)
    printEventMembers(event)
    postEvent(event)
end
 
function onNoteExpression(event)
    printEventMembers(event)
    -- postEvent(event), not needed for note expression
end

Constructors

Event Constructor

Event(type)

Description

Constructor to create a new Event object of the specified type.

Available in: Processor.

Arguments

typeThe type of event. See Event Types for details.enum or number

Return Values

Returns a new Event object of the specified type.

The fields of the Event object must be set after its creation.

Example

-- create new note-on event
function onNote(event)
    local newEvent = Event(EventType.noteOn)
    newEvent.note = event.note + 12
    newEvent.velocity = event.velocity
    local id = postEvent(newEvent)
	waitForRelease()
	releaseVoice(id)
end

  • No labels