MUSC 108. Introduction to Music Technology - Fall 2013

03 Standard MIDI Files (SMF) Introduction

[Overview] [Syllabus]

Standard MIDI File Overview

The Standard MIDI File (SMF) specification was first published in 1990. The specification describes the low level format that all MIDI files follow. As a result of this standard, users can create, play, save, and share MIDI files across every major computing platform including, Windows, Mac, Linux, and Unix. Standard MIDI Files normally end with a ".mid" file extension. Complete SMF documentation can be found on the Reference page for Unit 4.

A Standard MIDI File is built in "chunks." There are two chunk types, the header chunk and the track chunk. All SMF's begin with one header chunk followed by a series of track chunks. The header chunk has the same format in every MIDI file. The first four bytes in every MIDI file spell "MThd" (MIDI Track header). These four bytes identify the file as a SMF on all computers. The header chunk is a fixed length and provides three pieces of information: the SMF type, the number of tracks in the file, and the PPQ value. Up to 17 tracks can follow the header chunk. The first four bytes at the beginning of every track chunk spell "MTrk" (MIDI Track). Track 1 is traditionally reserved for information about the song key, time signature and tempo. Tracks 2-17 contain the same MIDI data you've been creating in the MIDIDisplay using PPQ time. The end of every track is identified by the End of Track meta event. A typical SMF can be visualized like this.

SMF Overview

I've created a SMF Excel template that you'll be using for your midterm project. MIDIDisplay will convert the Excel template into a Standard MIDI file.

Excel template

Legend

green bullet Cells in green are already filled in for you.

Yellow bullet Cells in yellow indicate data you need to enter.

White bullet Cells in white are comments and must begin with a semicolon.

An h above a cell indicates data that is entered in hex.

A d above a cell indicates data that is entered in decimal.

Overview of the SMF Excel Template

Header Chunk

The header chunk always begins MThd. The Length of the Header Chunk is always 6.

Header Chunk

This is the corresponding portion of the Excel template.

Header Chunk

You'll be using type 1 Standard MIDI Files where each instrument is on a separate track. The Number of Tracks in the SMF will be the number of instrument tracks plus one for the Tempo track (Track Chunk 1). The PPQ value will be 480 for a quarter note.

Track 1 is the Tempo Track

All Tracks after the Header Chunk begin with MTrk.

Tempo Track

Meta-Events

Track Chunk 1 contains meta event data and tempo data. Meta events are used to provide additional information that helps music notation programs convert the MIDI data to a musical score. The MIDI Manufacturer's Association has defined a series of events that begin with FF to represent information like time signature, key signature, tempo, copyright, instrument names, text, lyrics, etc. Your midterm project must include meta events for key signature, time signature and tempo. You'll learn more about meta events in Units 4 and 5. This is the Tempo track portion of the Excel template.

Track 1 Chunk

Two Important Points for all Tracks

  1. Every meta event or MIDI event is preceded by a PPQ time.
  2. Every track must end with with the End of Track meta event (<PPQ> FF 2F 0).

Track Chunks 2-17 are the Instrument Tracks

All Tracks after the Track 1 are instrument tracks and contain the the same data you've been using in MIDIDisplay with times in PPQ.

Track chunk two

This is the corresponding portion of the Excel template. Each instrument track begins with the following MIDI Control messages: Reset All Controllers, Volume, Pan, and Patch change. The NON NOF messages follow that and the track ends with another Reset All Controllers message and the End of Track meta event.

SMF Template Track 3

[Overview] [Syllabus]

Revised John Ellinger, January - September 2013