NOW LOADING

WinRT API Standard MIDI File Reading and Writing


Read a Standard MIDI File into a playable sequence, and write one back out
Windows.Devices.Midi2.Utilities.Files

This namespace reads MIDI files from disk or from a stream, and turns them into a MidiSequence. A sequence isn’t tied to any file format. Everything you do with the music after that, including playing it, is in Windows.Devices.Midi2.Utilities.Sequencing.

It also writes one back out. MidiStandardFileWriter takes any sequence, whether you read it from a file, built it yourself, or recorded it from a device, and saves it as a Standard MIDI File. Read a file, write it back, and reading the result again gives you the same sequence.

Reading and writing are both asynchronous, because a MIDI file may come from anywhere: a download, an email attachment, or a document a browser handed to your app.

A MIDI file usually comes from somewhere your app doesn’t control. So the reader never sets aside memory for a length the file claims, until it has checked that the bytes are really there. MidiFileReadOptions is where you set those limits, if the generous defaults aren’t what you want.

Samples

Types in this namespace

Click or tap the type name to view more details.

Type Description
MidiFileReadOptions Limits applied while reading a MIDI file, so a hostile or broken file cannot ask for an unreasonable amount of memory
MidiFileReadResult The outcome of reading a MIDI file, and the sequence it produced
MidiFileReadStatus Describes the outcome of reading a MIDI file
MidiFileWriteOptions Choices about how a sequence is written out as a Standard MIDI File
MidiFileWriteResult The outcome of writing a sequence out as a Standard MIDI File
MidiFileWriteStatus Describes the outcome of writing a Standard MIDI File
MidiStandardFileReader Reads a Standard MIDI File into a sequence you can play or draw
MidiStandardFileWriter Writes a sequence out as a Standard MIDI File

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.