A MIDI file does not store notes in seconds. It stores them in ticks, and a separate tempo map says how long each tick lasts. Two files with identical notes can therefore play for different lengths, and a single tempo change halfway through can make a song much longer than its bar count suggests.
This guide builds a small file you can reproduce in any DAW or notation program, calculates its length by hand, and checks every number in the MIDI Player & Piano Roll.
Build a four-bar file with one tempo change
Create a new project in 4/4 at 120 BPM. Add a tempo change to 60 BPM at the start of bar 3. On a piano track on MIDI channel 1, enter a C major scale as quarter notes from C4 up to C5, then repeat it, for 16 notes. On a second track on channel 10, put a kick drum (note 36) on every beat for the same four bars.
Export it as a Standard MIDI File, type 1. Many programs write 480 ticks per quarter note; some use 960. Either is fine, because the tick count per beat changes but the length in seconds does not.
Input
Format 1, 480 ticks per quarter, 4/4
Tempo: 120 BPM, then 60 BPM from bar 3
Piano (ch 1): 16 quarter notes
Drums (ch 10): 16 kicksExpected result
3 tracks: tempo map, Piano, Drums
32 notes
16 beats in totalCalculate the length from the tempo map
A tempo event stores microseconds per quarter note. 120 BPM is 500,000 microseconds, or half a second per beat. 60 BPM is 1,000,000 microseconds, or one second per beat. To convert ticks to seconds, divide by the ticks per quarter and multiply by the seconds per beat that apply at that point in the file.
Bars 1 and 2 hold 8 beats, which is 3,840 ticks at 480 per quarter. At half a second per beat they last 4 seconds. Bars 3 and 4 hold another 8 beats at one second each, which is 8 seconds. The whole file lasts 12 seconds, not the 8 seconds you would get by assuming 120 BPM throughout.
- Open the MIDI Player & Piano Roll and choose your exported file. It is read in the browser and not uploaded.
- Check MIDI metadata: Ticks per quarter, Duration, Notes, and Time signature.
- Select Copy Summary and look at the Tempo line, which reports the range of tempos in the file.
Input
tempo-change-scale.midExpected result
Format: 1
Tracks: 3
Ticks per quarter: 480
Duration: 0:12
Tempo: 60–120 BPM (2 tempo changes)
Time signature: 4/4
Notes: 32Check bar and beat positions after the change
Drag the playback position and watch the Bar:Beat readout. At 1.4 seconds the player shows bar 1, beat 3, because 1.4 seconds at half a second per beat is 2.8 beats into the file. At 5.2 seconds it shows bar 3, beat 2: the first two bars took 4 seconds, and the remaining 1.2 seconds is 1.2 beats at the slower tempo. At 8.0 seconds it shows bar 4, beat 1.
If a position in your own file does not match what you expect, look for a tempo event you did not intend, such as one left at the end of a copied section. The Copy Summary text counts every tempo event, including the opening tempo, so a file with one change after the start reports two.
Keep tracks and channels apart
Tracks organize the file; channels decide which instrument plays. In the example, the tempo map is track 1, so the piano is track 2 even though it plays on channel 1. The program change summary reads Track 2, Ch 1: Acoustic Grand Piano (program 0).
MIDI data numbers channels from 0 to 15, while most software displays them as 1 to 16. The drums are written to data channel 9, which appears as channel 10. In General MIDI, channel 10 is reserved for percussion, so note 36 plays a bass drum rather than a pitched note. The player shows that channel as Standard Drum Kit.
Use the Tracks and Channels panels to hide notes from the piano roll or mute them independently. Muting the drums while leaving them visible is a quick way to hear whether the piano part is in time on its own.
Know what the player does not do
The player is for checking timing, structure, and arrangement. It is not a renderer for a finished recording.
- Sound comes from lightweight Web Audio synthesis with General MIDI presets, not a sound font or your DAW's instruments, so balance and tone will differ.
- Standard MIDI Files in format 0 and format 1 are supported. Files that use SMPTE time division instead of ticks per quarter note are rejected with an error.
- It reads and plays files but does not edit or export them. Fix the tempo map in your DAW and export again.
- The duration runs to the last note or event in the file, so a stray controller message or marker placed after the music ends can make it longer than what you hear.
Try the tools
Start with the worked example above, then try the tool with your own inputs.
References and corrections
- The MIDI Association: Standard MIDI Files specification
- The MIDI Association: General MIDI Level 1
- MDN: Web Audio API
Found a result that differs from this guide? Send a correction with a small, non-sensitive example and your expected result.