Skip to main content

midiEventsPlayed

since 1.2.0

Description​

This event is fired when the synthesizer played certain midi events. This allows reacing on various low level audio playback elements like notes/rests played or metronome ticks.

Refer to the related guide to learn more about this feature.

Also note that the provided data models changed significantly in 1.3.0. We try to provide backwards compatibility until some extend but highly encourage changing to the new models in case of problems.

midiEventsPlayedJavaScript
alphaTab.midiEventsPlayedjQuery
alphaTab.midiEventsPlayedHTML
MidiEventsPlayed.net
midiEventsPlayedAndroid

Types​

function(args)JavaScript
Action<MidiEventsPlayedEventArgs>.net
(e: MidiEventsPlayedEventArgs) -> UnitAndroid

Parameters​

ParametersTypeSummary
argsJavaScriptalphaTab.synth.MidiEventsPlayedEventArgs

The information about the played events.

args.netAlphaTab.Synth.MidiEventsPlayedEventArgs

The information about the played events.

argsAndroidalphaTab.synth.MidiEventsPlayedEventArgs

The information about the played events.

MidiEventsPlayedEventArgs Properties​

ParametersTypeSummary
eventsJavaScriptalphaTab.midi.MidiEvent[]

The played midi events.

Events.netIList<AlphaTab.Midi.MidiEvent>

The current time position within the song in milliseconds.

eventsAndroidalphaTab.collections.List<alphaTab.midi.MidiEvent>

The current time position within the song in milliseconds.

Following midi event classes exist which represent the usual events of a midi file.

alphaTab.midi.MidiEvent​

The base class for all midi events. Check the type property to find out which type it is.

ParametersTypeSummary
trackAllnumber

The track to which this event belongs.

messageAllnumber

The 32-bit encoded raw midi message. Deprecated since 1.3.0. Use the properties of the subclasses instead.

tickAllnumber

The absolute midi tick of when this event is played.

channelAllnumber

The midi channel to which this event belongs (not valid for all events).

commandAllalphaTab.midi.MidiEventType

The type of this event. (Deprecated since 1.3, use type instead)

typeAllalphaTab.midi.MidiEventType

The type of this event.

since 1.3.0
data1Allnumber

The first data byte. Meaning depends on midi event type. (Deprecated since 1.3, use the specific properties of the midi event depending on type)

data2Allnumber

The second data byte Meaning depends on midi event type. (Deprecated since 1.3, use the specific properties of the midi event depending on type)

alphaTab.midi.TimeSignatureEvent​

since 1.3.0-alpha.720

Indicates a time signature change. Type: alphaTab.midi.MidiEventType.TimeSignature

ParametersTypeSummary
numeratorAllnumber

The time signature numerator.

denominatorIndexAllnumber

The MIDI denominator index (the actual denominator is calculated via 2^(index))

thirtySecondNodesInQuarterAllnumber

The number of MIDI clocks in a metronome click.

midiClocksPerMetronomeClickAllnumber

The number of notated 32nd-notes in what MIDI thinks of as a quarter-note (24 MIDI Clocks)

alphaTab.midi.AlphaTabMetronomeEvent​

since 1.3.0-alpha.720

Represents a metronome event. Type: alphaTab.midi.MidiEventType.AlphaTabMetronome.

ParametersTypeSummary
metronomeNumeratorAllnumber

The counter of the metronome as per time signature.

metronomeDurationInTicksAllnumber

The duration of this metronome tick in MIDI Ticks.

metronomeDurationInMillisecondsAllnumber

The duration of this metronome tick in MIDI milliseconds.

alphaTab.midi.AlphaTabRestEvent​

since 1.3.0-alpha.720

Represents a metronome event. Type: alphaTab.midi.MidiEventType.AlphaTabRest.

ParametersTypeSummary
counterAllnumber

The counter of the metronome as per time signature.

durationInTicksAllnumber

The duration of this metronome tick in MIDI Ticks.

durationInMillisAllnumber

The duration of this metronome tick in MIDI milliseconds.

alphaTab.midi.NoteOnEvent​

since 1.3.0-alpha.720

Represents a note which started playing. Type: alphaTab.midi.MidiEventType.NoteOn.

ParametersTypeSummary
channelAllnumber

The midi channel on which it plays.

noteKeyAllnumber

The key of the note. (aka. note height)

noteVelocityAllnumber

The velocity of the note. (aka. note intensity or loudness)

alphaTab.midi.NoteOffEvent​

since 1.3.0-alpha.720

Represents a note which stopped playing. Type: alphaTab.midi.MidiEventType.NoteOff.

ParametersTypeSummary
channelAllnumber

The midi channel on which it plays.

noteKeyAllnumber

The key of the note. (aka. note height)

noteVelocityAllnumber

The velocity of the note. (aka. note intensity or loudness)

alphaTab.midi.ControlChangeEvent​

since 1.3.0-alpha.720

Represents a change of a midi controller on a channel. Type: alphaTab.midi.MidiEventType.ControlChange.

ParametersTypeSummary
channelAllnumber

The midi channel on which it plays.

controllerAllalphaTab.midi.ControllerType

The controller for which the value changes.

valueAllnumber

The new value of the controller. The meaning of the value depends on the controller.

alphaTab.midi.ProgramChangeEvent​

since 1.3.0-alpha.720

Represents a change of a MIDI program on a channel. Type: alphaTab.midi.MidiEventType.ProgramChange.

ParametersTypeSummary
channelAllnumber

The midi channel on which it plays.

programAllnumber

The new MIDI program used on the channel.

alphaTab.midi.TempoChangeEvent​

since 1.3.0-alpha.720

Represents the change of the played tempo. Type: alphaTab.midi.MidiEventType.TempoChange.

ParametersTypeSummary
microSecondsPerQuarterNoteAllnumber

The tempo in microseconds per quarter note (USQ). (BPM = 60000000 / USQ)

alphaTab.midi.PitchBendEvent​

since 1.3.0-alpha.720

Represents the pitch-bend (aka. pitch wheel) change on a whole midi channel. Type: alphaTab.midi.MidiEventType.PitchBend.

ParametersTypeSummary
channelAllnumber

The midi channel for which the pitch-bend is applied.

valueAllnumber

The pitch wheel value as per MIDI1.0 spec.

alphaTab.midi.NoteBendEvent​

since 1.3.0-alpha.720

Represents the pitch-bend (aka. pitch wheel) change on a single played note. This midi message was only introduced in MIDI2.0 and alphaTab has internal support for it. But when exporting SMF1.0 files normal PitchBendEvent are generated. Type: alphaTab.midi.MidiEventType.PerNotePitchBend.

ParametersTypeSummary
channelAllnumber

The midi channel for which the pitch-bend is applied.

noteKeyAllnumber

The key of the note on the channel for which to apply the bend.

valueAllnumber

The pitch wheel value as per MIDI1.0 spec.

alphaTab.midi.EndOfTrackEvent​

since 1.3.0-alpha.720

Indicates the end of a midi track. Type: alphaTab.midi.MidiEventType.EndOfTrack.

ParametersTypeSummary
channelAllnumber

The midi channel for which the pitch-bend is applied.

noteKeyAllnumber

The key of the note on the channel for which to apply the bend.

valueAllnumber

The pitch wheel value as per MIDI1.0 spec.

alphaTab.midi.MetaEvent (deprecated since 1.3)​

Any Meta Events.

ParametersTypeSummary
metaStatusAllalphaTab.midi.MetaEventType

The type of meta event.

alphaTab.midi.MetaDataEvent (deprecated since 1.3)​

Meta Events with a related data array (e.g. time signature changes).

ParametersTypeSummary
dataAllUint8Array

The raw binary data attached to this meta event.

alphaTab.midi.MetaNumberEvent (deprecated since 1.3)​

Meta Events with a number value (e.g. tempo changes).

ParametersTypeSummary
valueAllnumber

The number value of this meta event.

alphaTab.midi.Midi20PerNotePitchBendEvent (deprecated since 1.3)​

A Midi 2.0 comparable per-note pitch bend.

ParametersTypeSummary
noteKeyAllnumber

The key of the note on the related channel which should be bent.

pitchAllnumber

The 32 bit pitch wheel value according to the Midi 2.0 standard.

alphaTab.midi.SystemCommonEvent (deprecated since 1.3)​

Not used in alphaTab by default.

alphaTab.midi.SystemExclusiveEvent (deprecated since 1.3)​

For special alphaTab specific events (e.g. rest played, metronome tick).

ParametersTypeSummary
dataAllUint8Array

The raw binary data attached to this event.

isMetronomeAllboolean

Whether this event is a metronome tick event.

metronomeNumeratorAllboolean

If the event is a metronome event it contains the zero based metronome numerator according to the time signature (e.g. 0, 1, 2 on a 3/4 signature).

metronomeDurationInTicksAllboolean

If the event is a metronome event it contains the current duration of the metronome event in ticks.

metronomeDurationInMillisecondsAllboolean

If the event is a metronome event it contains the current duration of the metronome event in milliseconds. This duration is assuming playback speed=1.

isRestAllboolean

Whether this event is a rest play event.

manufacturerIdAllnumber

The manufacturer ID of this specific event (0x7D for alphaTab).

Examples​

const api = new alphaTab.AlphaTabApi(document.querySelector('#alphaTab'));
api.midiEventsPlayedFilter = [alphaTab.midi.MidiEventType.AlphaTabMetronome];
api.midiEventsPlayed.on(function(e) {
for(const midi of e.events) {
if(midi.isMetronome) {
console.log('Metronome tick ' + midi.tick);
}
}
});