Skip to main content

Event Objects

Objects returned by iterators (context.iterator, context.editor.activeRegion.createSequenceIterator(), context.editor.selection.newIterator()) share a common base surface of timing and state properties. What additional properties they have depends on the context.

What the event represents depends on the context:

  • Arranger section — named section on the Arranger Track. Created via context.editor.model.arranger.addArrangerEvent().
  • Audio event — audio clip events with mediaType="Audio".
  • Chord event — chord track events with a chord sub-object.
  • Instrument Part — arrangement surface with mediaType="Music". For the note-container surface, see Region Object.
  • Pattern event — arrangement surface with mediaType="Pattern".
  • Lyrics — attached to MIDI notes, accessed via getLyricsForNote(note).
  • MIDI note — has pitch and velocity, lives inside an Instrument Part (.region).

Arranger Events

Accessed via context.iterator or context.editor.selection.newIterator() on the Arranger Track when selected arranger sections are available. Created via context.editor.model.arranger.addArrangerEvent().

PropertyTypeWritableExampleDescription
namestringNo"Chorus"Section name.
colornumberNo3138760Section color as integer.
isMutednumberNo01 if muted.
startnumberNo144Start position in beats.
lengthnumberNo64Duration in beats.
startTimeobject - Time ObjectNoStart time object.
endTimeobject - Time ObjectNoEnd time object.
lengthTimeobject - Time ObjectNoDuration time object.
timeContextobject - timeContext ObjectNoTime context for conversions.
timeFormatnumberNo2Time format identifier.
MethodReturnsParametersDescription
globalToRegionData(pos)numberpos (Time Object, req): Time position.Converts global time coordinates to region-local data.

Audio Events

Accessed via context.iterator or context.editor.selection.newIterator() in the TrackEdit or AudioEdit context when selected audio events are available.

PropertyTypeWritableExampleDescription
namestringNo"Drum Loop.wav"Audio clip file name.
colornumberNo2434491Clip color as integer.
mediaTypestringNo"Audio"Identifies this as an audio event.
isMutednumberNo01 if muted.
startnumberNo0Start position in beats.
lengthnumberNo186Duration in beats.
startTimeobject - Time ObjectNoStart time object.
endTimeobject - Time ObjectNoEnd time object.
lengthTimeobject - Time ObjectNoDuration time object.
timeContextobject - timeContext ObjectNoTime context for conversions.
timeFormatnumberNo0Time format identifier.
MethodReturnsParametersDescription
globalToRegionData(pos)numberpos (Time Object, req): Time position.Converts global time coordinates to region-local data.

Chord Events

Accessed via context.iterator or context.editor.selection.newIterator() on the Chord Track when selected chord events are available.

PropertyTypeWritableExampleDescription
namestringNo""Event label (empty string for chord events).
colornumberNo2434491Event color as integer.
isMutednumberNo01 if muted.
startnumberNo112Start position in beats.
lengthnumberNo84Duration in beats.
startTimeobject - Time ObjectNoStart time object.
endTimeobject - Time ObjectNoEnd time object.
lengthTimeobject - Time ObjectNoDuration time object.
chordobject Chord Data ObjectNoChord data sub-object (see below).
timeContextobject - timeContext ObjectNoTime context for conversions.
timeFormatnumberNo2Time format identifier.
MethodReturnsParametersDescription
globalToRegionData(pos)numberpos (Time Object, req): Time position.Converts global time coordinates to region-local data.

Chord Data Object

PropertyDescription
nameFull chord name string, e.g., "Asus4", "Gm", "E".
typeChord type ID (0 maj, 1 min, 2 dim, 3 aug, 4 sus2, 5 sus4, 6 power).
rootRoot note offset as an absolute directional coordinate on the Circle of Fifths Spiral.
bassBass note offset as an absolute directional coordinate on the Circle of Fifths Spiral.
rootPitchRoot pitch as an absolute MIDI value (0 = C, 1 = C#, etc.).
bassPitchBass pitch as an absolute MIDI value.
MethodDescription
hasInterval(interval)Boolean check for whether the chord contains a given interval.

rootPitch / bassPitch: Absolute MIDI pitch values anchored to C=0, independent of key signature.

root / bass: Absolute directional coordinates on the Circle of Fifths Spiral, used to distinguish enharmonic spellings and chord inversion position.

Spiral ID (root)MIDI Pitch (rootPitch)Note NameHarmonic Context
-66G♭Max Flat Pole
-51D♭
-48A♭
-33E♭
-210B♭
-15F
00CCenter (Home)
17G
22D
39A
44E
511B
66F♯Max Sharp Pole
71C♯
88G♯
93D♯
1010A♯
115E♯Theoretical Sharp

Chord-Scrape Workflow

For a ready-to-use chord scraping script, see the Chord Mapping script. It automates the process of exporting chord data to JSON and a results log.

Instrument Part Events

Accessed via context.iterator or context.editor.selection.newIterator() when selected instrument part events are available. This is the track-level arrangement surface of an Instrument Part. For the note-container surface, see Region Object.

PropertyTypeWritableExampleDescription
namestringNo"Track 1"Part label (matches track name).
colornumberNo2434491Part color as integer.
mediaTypestringNo"Music"Identifies this as a music part event.
isMutednumberNo01 if muted.
velocitynumberNo100Default velocity.
startnumberNo0Start position in beats.
lengthnumberNo128Duration in beats.
offsetnumberNo48Offset.
syncPointobjectTime ObjectNoSync point position.
startTimeobject - Time ObjectNoStart time object.
endTimeobject - Time ObjectNoEnd time object.
lengthTimeobject - Time ObjectNoDuration time object.
timeContextobject - timeContext ObjectNoTime context for conversions.
timeFormatnumberNo2Time format identifier.
parentobjectNoParent object.
MethodReturnsParametersDescription
getRoot()objectnoneReturns the root region.
getTrack()objectnoneReturns the containing track.
createSequenceIterator()objectnoneCreates an iterator over all notes in the region.
globalToRegionData(pos)numberpos (Time Object, req): Time position.Converts global time coordinates to region-local data.

Pattern Events

Accessed via context.iterator or context.editor.selection.newIterator() when selected pattern events are available.

PropertyTypeWritableExampleDescription
namestringNo"Track 1"Part label (matches track name).
colornumberNo2434491Part color as integer.
mediaTypestringNo"Pattern"Identifies this as a pattern part event.
isMutednumberNo01 if muted.
velocitynumberNo100Default velocity.
startnumberNo152Start position in beats.
lengthnumberNo56Duration in beats.
offsetnumberNo48Offset.
syncPointobjectTime ObjectNoSync point position.
startTimeobject - Time ObjectNoStart time object.
endTimeobject - Time ObjectNoEnd time object.
lengthTimeobject - Time ObjectNoDuration time object.
timeContextobject - timeContext ObjectNoTime context for conversions.
timeFormatnumberNo2Time format identifier.
parentobjectNoParent object.

| Method | Returns | Parameters | Description | |---|---|---|---|---| | getRoot() | object | none | Returns the root region. | | getTrack() | object | none | Returns the containing track. | | globalToRegionData(pos) | number | pos (Time Object, req): Time position. | Converts global time coordinates to region-local data. |

Lyrics Events

Lyrics are accessed via context.editor.activeRegion.getLyricsForNote(note) on a selected region.

PropertyTypeWritableExampleDescription
textstringNo"Hello world"The lyric text
MethodReturnsParametersDescription
toString()stringnoneReturns the lyric text
clone()object - Lyrics EventnoneReturns a new copy of the lyrics object
// note — selected MIDI note from context.iterator (MusicEdit context)
var lyrics = context.editor.activeRegion.getLyricsForNote(note);
if (lyrics) {
var text = lyrics.text;
}

MIDI Notes

Accessed via context.iterator from the Note Editor in a MusicEdit context when selected notes are available. context.editor.activeRegion.createSequenceIterator() also provides all notes in the selected region.

PropertyTypeWritableExampleDescription
pitchnumberNo48MIDI note number (0–127).
velocitynumberNo0.8MIDI velocity as float (0.0–1.0).
selectednumberNo1Selection state (1 = selected).
isMutednumberNo01 if muted.
startnumberNo6.75Start position in beats.
endnumberNo7End position in beats.
lengthnumberNo0.25Duration in beats.
startTimeobject Time ObjectNoStart time object.
endTimeobject Time ObjectNoEnd time object.
lengthTimeobject Time ObjectNoDuration time object.
regionobject - Region ObjectNoContaining Instrument Part.
timeContextobject - timeContext ObjectNoTime context (secondsToPpq(), ppqToSeconds(), getBarStart()).
timeFormatnumberNo2Time format identifier.
MethodReturnsParametersDescription
clone()object - MIDI NotenoneClones the event.
nextEvent()object - MIDI NotenoneNext event in the region sequence.
previousEvent()object - MIDI NotenonePrevious event in the region sequence.
globalToRegionData(pos)numberpos (Time Object, req): Time position.Converts global time coordinates to region-local data.

timeContext Object

Accessed via the .timeContext property on any event.

MethodReturnsParametersDescription
secondsToPpq(seconds)numberseconds — time in secondsConvert seconds to musical PPQ
ppqToSeconds(beats)numberbeats — time in beatsConvert beats to seconds
getBarStart(musical)numbermusical — musical positionGet the bar start position for a given musical position
// event — selected event from context.iterator
var start = event.startTime.musical;
var barStart = event.timeContext.getBarStart(start);