MUSC 108. Introduction to Music Technology - Fall 2013

05Lab4 - Create the SMF Header Track and Track 1

[Overview] [Syllabus]

Open the SMF Tab

Excel SMF Template Rules

  1. ALL cells in yellow Yellow bullet must be filled in by you.
  2. Cells in green green bullet are already pre-filled. Leave them alone.
  3. There can be no empty rows. Every row must contain data in column A, or begin with a semi-colon.
  4. Comment lines begin with a semi-colon.
  5. No commas allowed in any cell.
  6. An ( h ) above a cell indicates data that must be entered as hex.
  7. A ( d ) above a cell indicates data that must be entered as decimal.

SMF Legend

Header Track (MThd)

The first chunk in every SMF is called the header track. They are rows 10-11 in the SMFTemplate. Row 10 begins with a semicolon and is a comment. It provides a consise description of the MThd format. Line 10 indicates that the SMF header has five componenets:

  1. ID
  2. Length
  3. SMF Type (h)
  4. NumTracks (h)
  5. PPQ (d)

The values of these five items will be entered in row 11. The ID, Length, and SMF Type are prefilled with the correct values.

You'll need to fill in the two remaining yellow cells in row 11.

The ( h ) and ( d ) directly above the yellow cells in row 10 indicate whether the number format is Hex or Decimal.

Track 1 - the tempo track (MTrk)

All tracks after the header chunk uses the ID marker MTrk to indicate the beginning of a track chunk. This is followed immediately by four bytes that indicate the length of the data to follow. Track 1 is a special track often called the Tempo Track or Conductor Track and uses meta events to provide general song information.

This is the Track 1 section from the SMF tab.

Track 1 Chunk

Fill in Track 1 details

The first 4 bytes of a track chunk are MTrk. The second four bytes indicates the number of data bytes to follow. The track length is set to 0. MIDIDisplay will calculate the actual length for you. The MTrk header is already filled in.

MTrk header

The remainder of track 1 consists of meta-events.

Meta-Events

The MIDI Manufacturer's Association defined a series of events called meta events to represent information like time signature, key signature, tempo, copyright, instrument track names, text, etc.

All meta events follow this format: FF cc nn dd

You'll be always use these four Meta Events in Track 1.

  1. Key Signature
  2. Time Signature
  3. Tempo
  4. End of track

Important: A Delta Time (PPQ value) precedes every meta event and MIDI message. Delta times are in column A.

Key Signature Meta Event

Your midterm project must include a meta-event for the key signature.

Key signature meta event

The format for the Key Signature meta event is:

The two data bytes are documented as sf and mi.

sf represents the number of sharps and flats in the key signature as shown in the following table. Sharps are numbered from 1 - 7, while flats are numbered negative 1 - 7. A standard convention in computer counting is that negative numbers count backwards from FF.

Number Sharps Flats Hex Code
7 sharps 7
6 sharps 6
5 sharps 5
4 sharps 4
3 sharps 3
2 sharps 2
1 sharp 1
0 sharps or flats 0
1 flat FF
2 flats FE
3 flats FD
4 flats FC
5 flats FB
6 flats FA
7 flats F9

mi indicates whether the song is in a major or minor key. Use one for a minor key and zero for a major key.

Going For Baroque is in the key of C minor. You'll need to fill in this is the data:

Note: The comment in row 17 says all numbers must be in hex.

Key Signature meta event

Time Signature Meta Event

Your midterm project must include a meta-event for the time signature.

Time signature meta event

The format for the Time Signature meta event is:

nn the upper number of the time signature.

dd the lower number of the key signature expressed as a power of two.

cc the number of MIDI clocks ($F8) per quarter note. MIDI clocks were an early attempt to synchronize multiple MIDI synthesizers. It is not that accurate. Better synchronization methods are used today. However, the SMF still requires an entry. The cc value in simple time is $18 (24 decimal). In compound time it is $24 (36 decimal).

bb the number of notated thirty second notes in a quarter note (8 is the standard value).

Going For Baroque has a time signature of three four. This is the information you need to fill in.

The completed time signature meta event is.

Time signature meta event

Note: The comment in row 20 says all numbers must be in hex.

Tempo Meta Event

Tempo meta event

The Tempo meta event is:

Tempo Formulas

The tempo of Going for Baroque is 100 beats per minute.

The microsecond duration of one quarter note at a tempo of 100 bpm is 60,000,000/100 = 600,00 μs. Convert 600,000 to hex.

Hex Conversion Methods

Hex convert Method 1

You want to use a tempo of 60. Type this into the Google search bar "1000000*60/100 in hex" and you'll get 0x927C0. The 0x prefix is common way of indicating hexadecimal numbers.

Hex convert Method 2

Try this Excel formula in an empty cell: =DEC2HEX(1000000*60/100). If the DEC2HEX function is installed you'll get 927C0.

Hex convert Method 3

Use the Apple Calculator found in the /Applications folder. Choose Programmer from the View menu. The shortcut is Apple-3. Enter 600000 in base 10 and then click base 16. You'll get 927c0 as the answer.

Apple calculatore hex mode Apple calculator in hex

Split the hex number into three parts 9 27 c0. This is the information you need to fill in:

The completed tempo meta event is:

Tempo meta event

End of track Meta Event

Every track ends with the End of Track meta event. It is filled in for you.

End of Track meta event

Save And save Often

Continue with 05Lab5.

[Overview] [Syllabus]

Revised John Ellinger, January - September 2013