Midi
audio/midi
Magic Bytes
Offset: 0
4D 54 68 64
The Musical Instrument Digital Interface (MIDI) file format is a technical standard maintained by the MIDI Association for storing musical performance data rather than recorded audio. It is primarily utilized in music production, notation software, and digital audio workstations to control synthesizers and sequence electronic instruments. Unlike waveform audio, these files contain compact instructions for pitch and duration, making them historically significant for early computer games and low-bandwidth applications.
Validation Code
How to validate .mid files in Python
Python
def is_mid(file_path: str) -> bool:
"""Check if file is a valid MID by magic bytes."""
signature = bytes([0x4D, 0x54, 0x68, 0x64])
with open(file_path, "rb") as f:
return f.read(4) == signature
How to validate .mid files in Node.js
Node.js
function isMID(buffer: Buffer): boolean {
const signature = Buffer.from([0x4D, 0x54, 0x68, 0x64]);
return buffer.subarray(0, 4).equals(signature);
}
Go
func IsMID(data []byte) bool {
signature := []byte{0x4D, 0x54, 0x68, 0x64}
if len(data) < 4 {
return false
}
return bytes.Equal(data[:4], signature)
}
API Endpoint
GET
/api/v1/mid
curl https://filesignature.org/api/v1/mid