NOW LOADING

WinRT API Sequencing and Playback


Music on a timeline, and a player which sends it to your MIDI endpoints
Windows.Devices.Midi2.Utilities.Sequencing

This namespace holds music on a timeline, called a sequence, and a player that sends it out. It isn’t tied to any file format, on purpose. A Standard MIDI File read with MidiStandardFileReader gives you a MidiSequence, and so does an app that builds one itself with MidiSequenceBuilder.

MidiSequencePlayer gives its messages to the service with a timestamp on each one, and lets the service send them at the right time. It doesn’t wake up to send each one itself. That’s what keeps playback steady when the PC is busy, and it’s why a sequence has to be prepared before playback starts.

How the API is laid out, and why

A sequence isn’t a collection of message objects. It’s a way to reach the data it stores. Real files can have millions of events, so the busiest parts of a sequence are never handed to your app one item at a time:

  • Small data that a display needs all of, such as the tempo map, time signatures, tracks, text, and lyrics, comes as normal IVectorView collections. Each is built once and kept.
  • Large data, the notes, is copied into an array you own with FillNotesInTickRange. So drawing a frame takes one call, not one call per note.
  • The largest data, the raw Universal MIDI Packets, is never handed to your app at all. The player reads it straight from the sequence.

If you’re drawing a piano roll, this difference decides whether your app is fast or too slow to use.

Samples

Types in this namespace

Click or tap the type name to view more details.

Type Description
MidiSequence Music on a timeline, ready to be played or drawn
MidiSequenceBarPosition Where a tick falls in bars and beats
MidiSequenceBuilder Builds a sequence in memory, without a file
MidiSequenceFormat How the tracks in a sequence relate to each other
MidiSequenceLyricLine Lyric syllables reassembled into a line you can display
MidiSequenceNote A note with both ends already paired
MidiSequencePlayer Plays a sequence to one or more endpoints
MidiSequencePlayerPosition Everything a transport display needs, read in one call
MidiSequencePlayerState What a sequence player is currently doing
MidiSequenceTempoChange One tempo change in a sequence, in both the file's terms and in beats per minute
MidiSequenceTextEvent A piece of text carried in a sequence, with the tick it belongs to
MidiSequenceTextKind What kind of text a sequence text event carries
MidiSequenceTimeSignature One time signature change in a sequence
MidiSequenceTimingMode Whether the ticks in a sequence are musical or measured in real time
MidiSequenceTrack One track of a sequence, and what the file said about it
MidiSequenceTrackRouting Where one track's messages are sent during playback

Didn't find what you were looking for?

Windows MIDI Services is an open source project with all source available on GitHub. We have a great community on Discord as well. Between GitHub and Discord, you should find the information you are looking for.