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.

midiEventsPlayedJavaScript
alphaTab.midiEventsPlayedjQuery
alphaTab.midiEventsPlayedHTML
MidiEventsPlayed.net

Types

function(args)JavaScript
Action<MidiEventsPlayedEventArgs>.net

Parameters

ParametersTypeSummary
argsJavaScriptalphaTab.synth.MidiEventsPlayedEventArgs

The information about the played events.

args.netAlphaTab.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.

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

alphaTab.midi.MidiEvent

General midi events which can be represented by 32bit (e.g. note on, note off, control changes, pitch bends).

ParametersTypeSummary
trackAllnumber

The track to which this event belongs.

messageAllnumber

The 32-bit encoded raw midi message.

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.

data1Allnumber

The first data byte (meaning depends on midi event type)

data2Allnumber

The second data byte (meaning depends on midi event type)

alphaTab.midi.MetaEvent

Any Meta Events.

ParametersTypeSummary
metaStatusAllalphaTab.midi.MetaEventType

The type of meta event.

alphaTab.midi.MetaDataEvent

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

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

ParametersTypeSummary
valueAllnumber

The number value of this meta event.

alphaTab.midi.Midi20PerNotePitchBendEvent

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

Not used in alphaTab by default.

alphaTab.midi.SystemExclusiveEvent

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

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