6

So I decoded a midi file using a MIDI to CSV converter I found online.

The ouput is :

2, 3072, Note_on_c, 1, 26, 96

After reading on MIDI format, I still don't understand what I see here. What each character represents? 2? 3072 ... ?

Sample data:

    2, 0, MIDI_port, 0
    2, 0, Title_t, "Bass Synt"
    2, 3072, Note_on_c, 1, 26, 96
    2, 3072, Note_on_c, 1, 38, 86
    2, 3220, Note_on_c, 1, 38, 0
    2, 3220, Note_on_c, 1, 26, 0
    2, 3648, Note_on_c, 1, 26, 97
    2, 3648, Note_on_c, 1, 38, 96
    2, 3788, Note_on_c, 1, 38, 0
    2, 3788, Note_on_c, 1, 26, 0
12

I've used this before and I know there is a ton of documentation for this program.

If you scan the documentation you can find out what the results of each event means. This is directly from the documentation:

Track, Time, Note_on_c, Channel, Note, Velocity

Send a command to play the specified Note (Middle C is defined as Note number 60; all other notes are relative in the MIDI specification, but most instruments conform to the well-tempered scale) on the given Channel with Velocity (0 to 127). A Note_on_c event with Velocity zero is equivalent to a Note_off_c.

In the beginning of the documentation it defines track, time. and type as:

Track

Numeric field identifying the track to which this record belongs. Tracks of MIDI data are numbered starting at 1. Track 0 is reserved for file header, information, and end of file records.

Time

Absolute time, in terms of MIDI clocks, at which this event occurs. Meta-events for which time is not meaningful (for example, song title, copyright information, etc.) have an absolute time of 0.

Type

Name identifying the type of the record. Record types are text consisting of upper and lower case letters and the underscore (“_”), contain no embedded spaces, and are not enclosed in quotes. csvmidi ignores upper/lower case in the Type field; the specifications “Note_on_c”, “Note_On_C”, and “NOTE_ON_C” are considered identical.

So the event is turning the note 26(D2) on channel 1 at velocity 96 at time 3072 using track 2.

  • I did read this, but I still don't understand it. Sorry if I'm slow. What is a track? ie. what does track 2 mean. And what is time 3072 Still don't get the Note_on_c thing – Conrad C Nov 10 '14 at 4:40
  • MIDI allows for up to 16 tracks - each track can have a different sound patch assigned to it. Track 1 might be a flute sound, track 2 a violin, track 3 and electric guitar, etc. Track 10 is generally reserved for percussion. – Steve Mansfield Nov 10 '14 at 11:41
4

The other answers are pretty good already. Here's a very quick and dirty description of a MIDI file format:

A MIDI file may contain up to 65,536 tracks (usually these tracks are intended to play simultaneously). Each track is just a sequence of events. Each event occurs at a specific time (specified as the number of "ticks" since the beginning of the track), and describes a message that gets sent (usually to either a hardware or software synthesizer). There are many types of events, but they usually belong to one of two types: Channel Events, and Meta Events (I'm ignoring a third type called System Exclusive events).

Meta Events don't necessarily contain musical information, but rather metadata, such as a track name, instrument name, or lyrics. They also can contain "gloabl" information that affects the entire playback, such as tempo, time signature, and key-signature are also treated as meta events. In your sample data, the MIDI_port and Title_t (which is the track title) are meta events.

Channel Events are where most of the musical action occurs. These include things like playing notes (Note On and Note Off events), depressing/releasing the sustain pedal, changing the instrument (or "patch"), introducing pitch bends, changing the volume or pan settings, changing effects like reverb or chorus, tweaking the synthesizer parameters like attack and sustain, etc...

The important thing to keep in mind about channel events is that they are all tagged with a "channel" number (from 1 to 16 -- or technically 0 to 15, depending on the software) and they will only affect other events that are on the same channel as they are on. So, for example, a note that starts with a Note On event on, say, channel 7 can only be stopped by a Note Off event on channel 7. A "sustain pedal" event on channel 3 will only sustain notes that are played on channel 3. Changing the instrument on channel 2 to a Xylophone will cause all notes on channel 2 to be played on a Xylophone, etc...

For Note On events, you have to specify what channel the event occurs on, but also the pitch (note number in semitones, where 60 is middle C) and how hard the key is struck ("velocity", from 0-127, which usually determines the loudness). Once the note begins, it will continue playing until a Note Off event is received for the same pitch and channel. Or alternatively (as in your case), you can send another Note On event with a velocity of 0. So in your case:

2, 3072, Note_on_c, 1, 26, 96

This says that track 2 contains the following event: At 3072 ticks after the beginning of the song, begin playing note 26 (the D just shy of 3 octaves below middle C) on channel 1, with a "velocity" of 96 (out of 127, that's probably about a mezzo-forte). This note will stop playing later, when the following event is received (because it has the same channel & note, but has a velocity of 0). It occurs 148 ticks later.

2, 3220, Note_on_c, 1, 26, 0

2

MIDI allows for 16 channels, not tracks. Sequencing software will then allocate channels to its track structure.

In terms of decoding a standard MIDI file (SMF) we need to understand the internal structure. There are two main types of MIDI file, type zero has a 'chunk' of header information followed by just one 'track' of MIDI data. This track contains all the note on and note off commands for every channel, in the sequence in which they occurred when they were recorded. Each MIDI 'event' will have a 'time stamp' directly before it (unless two or more events occurred at exactly the same instance) telling the playback device precisely how much time to leave between the last MIDI event and the current event.

This time stamp is defined as 'delta time' and is measured as a number of 'ticks'. The length of each 'tick' is calculated from data included primarily at the start of the MIDI file. It includes the number of ticks per quarter note (96 was the norm for this back in the eighties, 480 or 960 has become the new norm), and the speed of playback in terms of beats per minute. Clearly if the tempo is changed part way through the file, the calculation of number of ticks has to be redone from that point.

Type zero MIDI files were essential for old hardware working from floppy disks, where they could only read the data a small amount at a time.

The other main type of MIDI file is known as type one. A type one MIDI file generally separates the MIDI data into one internal track per channel (a simplification). There can theoretically be as many tracks as you like, thus allowing dozens of tracks for sequencing large orchestral works. Modern sequencer software works in type one mode. Within the header information is embedded a count of the number of tracks. Otherwise the internal structure of delta time and MIDI event is the same.

So, your data, track 2 within the MIDI file with a delta time of 3072. Refer to the TPQN within the header and the last tempo setting meta-data before the note on command to work out where the note occurs in relative time.

Oh, and the notes are in equal temperament not well temperament (whatever that is). We are still unsure what Bach meant when he wrote "woltemperirte clavier", although many theories have been expounded. It is now thought highly unlikely to be equal temperament.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.