Banana Studio
Guides

What Is a MIDI File and How Does It Work?

A plain guide to what is inside a MIDI file: tracks, note events, velocity, tempo, and why the same file can sound different on every device.

What Is a MIDI File and How Does It Work?
On this page

A MIDI file is small, often only a few kilobytes, yet it can hold a full arrangement for piano, strings, bass, and drums. That is possible because a MIDI file does not store sound at all. It stores instructions: which note to play, when, how hard, and on which instrument.

This guide explains what is inside a MIDI file, how a player turns those instructions into music, and why the same file can sound different from one phone to the next. At the end, we cover when it makes sense to edit, play, or convert a MIDI file on Android.

A MIDI file is a set of instructions

Think of a MIDI file as a detailed score written for machines. Instead of a recording of a pianist, it says something like: at this moment, press middle C at this strength, hold it for this long, then let go.

The most common format is the Standard MIDI File, usually with the extension .mid or .midi. Inside, the data is organized into blocks called chunks:

  • The header chunk (labeled MThd) describes the file as a whole: which format it uses, how many tracks it contains, and how time is measured.
  • Track chunks (labeled MTrk) contain the actual musical events, one chunk per track.

There are three file formats you may come across:

  • Format 0: everything is in a single track. Simple and widely compatible, often used for ringtones and basic players.
  • Format 1: several tracks that play at the same time, such as one for melody, one for bass, and one for drums. This is what most music software exports.
  • Format 2: several independent sequences, like separate patterns. It is rare in practice.

Tracks and channels

A track is an organizational lane in the file. Music software usually puts one instrument part on each track, which makes the file easier to read and edit.

A channel is how the events are routed to a sound. MIDI has 16 channels, and each channel can be assigned one instrument at a time. Every note event carries a channel number, so the player knows which instrument should sound it.

Tracks and channels are related but not the same. A single track can send events on several channels, and several tracks can share one channel. In most well-organized files, though, you will find one track per instrument, each using its own channel.

Under the General MIDI standard, channel 10 is reserved for drums. On that channel, each note number triggers a different drum or percussion sound instead of a pitch. That is why a drum part placed on another channel may suddenly play as a piano or a marimba.

General MIDI standard drum map showing which note number plays which drum sound The General MIDI drum map: on channel 10, note 36 is a bass drum, 38 a snare, 42 a closed hi-hat, and so on. Image: Manudiclemente, CC BY-SA 3.0, via Wikimedia Commons.

Note events: the heart of the file

Most of what a MIDI file contains is note events. Each note is described by two messages:

  • Note On: start playing a note.
  • Note Off: stop playing it.

Each message includes a note number from 0 to 127. Middle C is usually note 60, and each step up or down is one semitone. So a C major chord is simply notes 60, 64, and 67 turned on at the same moment.

Piano keyboard chart showing MIDI note numbers, note names and frequencies, with middle C as note 60 MIDI note numbers on an 88-key piano, from 21 (A0) to 108 (C8), with middle C at 60. Image: CellarDoor85, CC BY-SA 3.0, via Wikimedia Commons.

The length of a note is not stored directly. It is the time between its Note On and its Note Off. Some files use a Note On with a velocity of zero in place of a Note Off; players treat the two the same way.

Velocity

Every Note On also carries a velocity, a value from 0 to 127. The name comes from keyboards: it measures how fast a key was pressed, which in practice means how hard.

Velocity usually controls loudness, but a good instrument also changes its tone with it. A softly played piano note sounds rounder; a hard hit sounds brighter. Files with flat, identical velocities tend to sound mechanical. Files recorded from a real keyboard, or carefully edited, have varied velocities and sound much more human.

Other performance events

Besides notes, tracks contain messages that shape the performance:

  • Program Change: selects the instrument on a channel, such as acoustic piano or violin.
  • Control Change: adjusts settings like volume, pan (left/right position), and the sustain pedal.
  • Pitch Bend: slides the pitch up or down smoothly, common in guitar and synth parts.
  • Aftertouch: pressure applied after a key is down, used by some instruments for vibrato or swells.

How time works: ticks, tempo, and time signature

MIDI events do not use seconds. Each event is stamped with a delta time, the number of ticks since the previous event in that track.

The header defines how many ticks make up one quarter note, a value often called the resolution or PPQN (pulses per quarter note). A higher resolution allows more precise timing.

Ticks become real time through tempo. Tempo is stored as a special meta event that sets the length of one quarter note in microseconds. If a file contains no tempo event, players assume 120 beats per minute. A file can also contain several tempo events, so a song can speed up or slow down partway through.

This design has a useful side effect: changing the tempo of a MIDI file does not change its pitch. The notes are the same; only the clock runs faster or slower.

Meta events

Tempo is one of several meta events, which carry information about the music rather than the performance itself. Others include:

  • Time signature, such as 4/4 or 3/4
  • Key signature
  • Track names and instrument names
  • Lyrics and text markers
  • End of Track, which closes every track chunk

Meta events matter for notation software and karaoke players, which use them to display bar lines, keys, and lyrics.

Why the same MIDI file sounds different on different devices

Because a MIDI file only says "play note 60 on a piano at velocity 90," the device decides what that piano sounds like. This is the main reason one file can sound polished on a computer and thin on a phone.

Several things change from device to device:

  • The sound source: each player or synthesizer uses its own set of instrument samples, and their quality varies widely.
  • Instrument mapping: General MIDI defines 128 standard instruments by number, so program 1 is always some kind of acoustic piano. But the actual recording behind that number is up to the device.
  • Support for controllers: some players ignore certain Control Change messages, so sustain pedal, expression, or effects may be missing.
  • Effects: reverb and chorus amounts, and how they sound, depend on the synthesizer.
  • Polyphony limits: a simple synth may only play a limited number of notes at once and cut off notes in dense passages.
  • Non-standard files: files made for a specific keyboard or sound module may use instrument numbers that mean something else on a General MIDI player.

None of this means the file is broken. It means the file is being interpreted by a different instrument, the way a score sounds different on a grand piano and an upright.

Soundfonts and virtual instruments

To turn MIDI events into sound, a player needs a synthesizer. On Android, that is usually a software synth built into an app or the system.

Soundfonts

A soundfont is a file that packages instrument samples together with instructions for how to play them. The most common format is SF2, with SF3 as a compressed variant. A soundfont maps each instrument number and note range to recorded samples, along with settings for volume, looping, and envelope.

Swapping the soundfont is the easiest way to change how a MIDI file sounds. A small soundfont of a few megabytes keeps things light but may sound basic. A large, high-quality soundfont can make the same file sound much closer to real instruments, at the cost of storage and memory.

If an app lets you load your own soundfont, it is worth trying a few. A General MIDI soundfont is the safest choice for general files, because it covers all 128 standard instruments and the drum kit on channel 10.

Virtual instruments

Virtual instruments are software synths or samplers, often used in music production apps. They can be far more detailed than a soundfont, with multiple velocity layers, articulations, and built-in effects. A producer might route each MIDI track to a different virtual instrument: a piano plugin for one track, a string library for another.

The principle is the same either way. The MIDI file stays identical; the instrument interpreting it is what changes the sound.

When to edit, play, or convert a MIDI file

Knowing how MIDI works makes it easier to choose the right action for the file in front of you.

Edit a MIDI file when

  • Wrong notes or timing need fixing, such as a sloppy recording from a keyboard.
  • You want a different tempo or key for practice or performance.
  • A part should use another instrument, which only requires a Program Change.
  • Velocities are flat and the playback sounds robotic.
  • You want to mute, remove, or isolate one track, for example to practice along with the rest of the band.

Play a MIDI file when

  • You want to preview a file before using it in a project.
  • You are practicing and want a backing track that you can slow down without changing pitch.
  • You want to compare how a file sounds with different soundfonts.

Convert a MIDI file when

  • You need to share the music with someone whose device does not play MIDI well, or who should hear it exactly as you do.
  • You want to lock in a particular soundfont so the result sounds the same everywhere.
  • A file needs to change format, such as from Format 1 to Format 0, for an older device or player that only reads single-track files.
  • You want to use the music in a video, a ringtone, or another app that expects a different file type.

Converting to an audio format captures one specific rendering of the file. Keep the original MIDI as well, so you can still edit notes, tempo, and instruments later.

Converting MIDI to audio on Android with MidiConv

When the goal is an audio file, MidiConv is Banana Studio's MIDI-to-audio converter for Android. It renders MIDI files to MP3, FLAC, AAC, M4A, WAV and other audio formats using The Fluid Release 3 General MIDI soundfont, a full GM set that covers all 128 instruments and the drum kit, so the result does not depend on your phone's built-in synth. It also keeps a history of your past conversions.

MidiConv: convert MIDI to MP3, FLAC and WAV on Android

A typical workflow:

  1. Choose the MIDI file you want to convert.
  2. Pick the output format: WAV or FLAC to keep full quality, MP3, AAC or M4A for smaller files to share.
  3. Convert, then listen to the result before you share it.
  4. Keep the original MIDI file, so you can still edit it and convert again later.

Because the soundfont is large (around 140 MB), the app is a big download, and converting a file can take up to about five minutes. For more on choosing between MIDI and audio, see MIDI vs. audio files: what musicians need to know.

Quick recap

  • A MIDI file stores instructions, not sound: notes, timing, and settings organized into tracks.
  • Each note has a number, a velocity, and a length defined by its Note On and Note Off events.
  • Time is measured in ticks, and tempo events turn ticks into real time.
  • The device's synthesizer, soundfont, or virtual instrument decides what the music actually sounds like.
  • Edit when the notes or arrangement need changing, play when you want to listen or practice, and convert when you need a fixed result or a different format.

Related app

MidiConv, MIDI to MP3, FLAC...

Convert MIDI to MP3, FLAC, AAC, M4A, WAV with highest quality

Related posts