midiEventsPlayed
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​
Parameters | Type | Summary |
---|---|---|
argsJavaScript | alphaTab.synth.MidiEventsPlayedEventArgs | The information about the played events. |
args.net | AlphaTab.Synth.MidiEventsPlayedEventArgs | The information about the played events. |
argsAndroid | alphaTab.synth.MidiEventsPlayedEventArgs | The information about the played events. |
MidiEventsPlayedEventArgs Properties​
Parameters | Type | Summary |
---|---|---|
eventsJavaScript | alphaTab.midi.MidiEvent[] | The played midi events. |
Events.net | IList<AlphaTab.Midi.MidiEvent> | The current time position within the song in milliseconds. |
eventsAndroid | alphaTab.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.
Parameters | Type | Summary |
---|---|---|
trackAll | number | The track to which this event belongs. |
messageAll | number | The 32-bit encoded raw midi message. Deprecated since 1.3.0. Use the properties of the subclasses instead. |
tickAll | number | The absolute midi tick of when this event is played. |
channelAll | number | The midi channel to which this event belongs (not valid for all events). |
commandAll | alphaTab.midi.MidiEventType | The type of this event. (Deprecated since 1.3, use |
typeAll | alphaTab.midi.MidiEventType | The type of this event. since 1.3.0 |
data1All | number | 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) |
data2All | number | 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.720Indicates a time signature change. Type: alphaTab.midi.MidiEventType.TimeSignature
Parameters | Type | Summary |
---|---|---|
numeratorAll | number | The time signature numerator. |
denominatorIndexAll | number | The MIDI denominator index (the actual denominator is calculated via |
thirtySecondNodesInQuarterAll | number | The number of MIDI clocks in a metronome click. |
midiClocksPerMetronomeClickAll | number | 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.720Represents a metronome event. Type: alphaTab.midi.MidiEventType.AlphaTabMetronome
.
Parameters | Type | Summary |
---|---|---|
metronomeNumeratorAll | number | The counter of the metronome as per time signature. |
metronomeDurationInTicksAll | number | The duration of this metronome tick in MIDI Ticks. |
metronomeDurationInMillisecondsAll | number | The duration of this metronome tick in MIDI milliseconds. |
alphaTab.midi.AlphaTabRestEvent​
since 1.3.0-alpha.720Represents a metronome event. Type: alphaTab.midi.MidiEventType.AlphaTabRest
.
Parameters | Type | Summary |
---|---|---|
counterAll | number | The counter of the metronome as per time signature. |
durationInTicksAll | number | The duration of this metronome tick in MIDI Ticks. |
durationInMillisAll | number | The duration of this metronome tick in MIDI milliseconds. |
alphaTab.midi.NoteOnEvent​
since 1.3.0-alpha.720Represents a note which started playing. Type: alphaTab.midi.MidiEventType.NoteOn
.
Parameters | Type | Summary |
---|---|---|
channelAll | number | The midi channel on which it plays. |
noteKeyAll | number | The key of the note. (aka. note height) |
noteVelocityAll | number | The velocity of the note. (aka. note intensity or loudness) |
alphaTab.midi.NoteOffEvent​
since 1.3.0-alpha.720Represents a note which stopped playing. Type: alphaTab.midi.MidiEventType.NoteOff
.
Parameters | Type | Summary |
---|---|---|
channelAll | number | The midi channel on which it plays. |
noteKeyAll | number | The key of the note. (aka. note height) |
noteVelocityAll | number | The velocity of the note. (aka. note intensity or loudness) |
alphaTab.midi.ControlChangeEvent​
since 1.3.0-alpha.720Represents a change of a midi controller on a channel. Type: alphaTab.midi.MidiEventType.ControlChange
.
Parameters | Type | Summary |
---|---|---|
channelAll | number | The midi channel on which it plays. |
controllerAll | alphaTab.midi.ControllerType | The controller for which the value changes. |
valueAll | number | The new value of the controller. The meaning of the value depends on the controller. |
alphaTab.midi.ProgramChangeEvent​
since 1.3.0-alpha.720Represents a change of a MIDI program on a channel. Type: alphaTab.midi.MidiEventType.ProgramChange
.
Parameters | Type | Summary |
---|---|---|
channelAll | number | The midi channel on which it plays. |
programAll | number | The new MIDI program used on the channel. |
alphaTab.midi.TempoChangeEvent​
since 1.3.0-alpha.720Represents the change of the played tempo. Type: alphaTab.midi.MidiEventType.TempoChange
.
Parameters | Type | Summary |
---|---|---|
microSecondsPerQuarterNoteAll | number | The tempo in microseconds per quarter note (USQ). (BPM = 60000000 / USQ) |
alphaTab.midi.PitchBendEvent​
since 1.3.0-alpha.720Represents the pitch-bend (aka. pitch wheel) change on a whole midi channel. Type: alphaTab.midi.MidiEventType.PitchBend
.
Parameters | Type | Summary |
---|---|---|
channelAll | number | The midi channel for which the pitch-bend is applied. |
valueAll | number | The pitch wheel value as per MIDI1.0 spec. |
alphaTab.midi.NoteBendEvent​
since 1.3.0-alpha.720Represents 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
.
Parameters | Type | Summary |
---|---|---|
channelAll | number | The midi channel for which the pitch-bend is applied. |
noteKeyAll | number | The key of the note on the channel for which to apply the bend. |
valueAll | number | The pitch wheel value as per MIDI1.0 spec. |
alphaTab.midi.EndOfTrackEvent​
since 1.3.0-alpha.720Indicates the end of a midi track. Type: alphaTab.midi.MidiEventType.EndOfTrack
.
Parameters | Type | Summary |
---|---|---|
channelAll | number | The midi channel for which the pitch-bend is applied. |
noteKeyAll | number | The key of the note on the channel for which to apply the bend. |
valueAll | number | The pitch wheel value as per MIDI1.0 spec. |
alphaTab.midi.MetaEvent (deprecated since 1.3)​
Any Meta Events.
Parameters | Type | Summary |
---|---|---|
metaStatusAll | alphaTab.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).
Parameters | Type | Summary |
---|---|---|
dataAll | Uint8Array | 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).
Parameters | Type | Summary |
---|---|---|
valueAll | number | The number value of this meta event. |
alphaTab.midi.Midi20PerNotePitchBendEvent (deprecated since 1.3)​
A Midi 2.0 comparable per-note pitch bend.
Parameters | Type | Summary |
---|---|---|
noteKeyAll | number | The key of the note on the related channel which should be bent. |
pitchAll | number | 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).
Parameters | Type | Summary |
---|---|---|
dataAll | Uint8Array | The raw binary data attached to this event. |
isMetronomeAll | boolean | Whether this event is a metronome tick event. |
metronomeNumeratorAll | boolean | 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). |
metronomeDurationInTicksAll | boolean | If the event is a metronome event it contains the current duration of the metronome event in ticks. |
metronomeDurationInMillisecondsAll | boolean | 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. |
isRestAll | boolean | Whether this event is a rest play event. |
manufacturerIdAll | number | The manufacturer ID of this specific event (0x7D for alphaTab). |
Examples​
- JavaScript
- jQuery
- C#
- Android
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);
}
}
});
$('#alphaTab')
.alphaTab('midiEventsPlayedFilter', [alphaTab.midi.MidiEventType.AlphaTabMetronome])
.on('alphaTab.midiEventsPlayed', (e, args) => {
for(const midi of args.events) {
if(midi.isMetronome) {
console.log('Metronome tick ' + midi.tick);
}
}
});
var api = new AlphaTabApi<MyControl>(...);
api.MidiEventsPlayedFilter = new MidiEventType[] { AlphaTab.Midi.MidiEventType.AlphaTabMetronome };
api.MidiEventsPlayed.On(e =>
{
foreach(var midi of e.events)
{
if(midi is AlphaTab.Midi.AlphaTabMetronomeEvent sysex && sysex.IsMetronome)
{
Console.WriteLine("Metronome tick " + midi.Tick);
}
}
});
val api = AlphaTabApi<MyControl>(...);
api.midiEventsPlayedFilter = alphaTab.collections.List<alphaTab.midi.MidiEventType>( alphaTab.midi.MidiEventType.AlphaTabMetronome )
api.midiEventsPlayed.on { e ->
for (midi in e.events) {
if(midi instanceof alphaTab.midi.AlphaTabMetronomeEvent && midi.isMetronome) {
println("Metronome tick " + midi.tick);
}
}
}