This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

MIDI (.mid)

MIME type: audio/midi
Standard MIDI file format.
Audio format.
Used for controlling electronic musical instruments, computer sound cards, and sequencers.
Stores a sequence of discrete sound events such as the beginning and end of a note, velocity and timbre information, and instrument and sound bank codes.
MIDI is an acronym for Musical Instrument Digital Interface.
Binary file format.
Introduced in 1983.
Developed and published by the MIDI Manufacturers Association (U.S.) and the Association of Musical Electronic Industry MIDI committee (Japan).
  • Export fully supports the standard MIDI file format.
  • Export exports a sound object to MIDI.
  • Export creates a MIDI file by treating expr as specifying element elem.
  • The file format can be explicitly specified using Export["file", Sound[...], "MIDI"].
  • See the reference pages for full general information on Export.
  • Data representation element:
"Sound"a Sound expression consisting of SoundNote primitives
  • Export by default uses the element for MIDI files.
  • Export["file.mid", Sound[ SoundNote[0]]] creates a MIDI file representing the "middle C" note played for 1 second in the default style.
  • The pitch specification 0 in Mathematica corresponds to MIDI pitch level 60.
  • Export["file.mid", Sound[SoundNote[pitch, t, "style"]]] specifies a duration t and an instrument style. The following General MIDI styles are supported:
  • "Accordion""Agogo""AltoSax""Applause"
    "Atmosphere""Bagpipe""Bandoneon""Banjo"
    "BaritoneSax""Bass""BassAndLead""Bassoon"
    "Bird""BlownBottle""Bowed""BrassSection"
    "Breath""Brightness""BrightPiano""Calliope"
    "Celesta""Cello""Charang""Chiff"
    "Choir""Clarinet""Clavi""Contrabass"
    "Crystal""DrawbarOrgan""Dulcimer""Echoes"
    "ElectricBass""ElectricGrandPiano""ElectricGuitar""ElectricPiano"
    "ElectricPiano2""EnglishHorn""Fiddle""Fifths"
    "Flute""FrenchHorn""FretlessBass""FretNoise"
    "Glockenspiel""Goblins""Guitar""GuitarDistorted"
    "GuitarHarmonics""GuitarMuted""GuitarOverdriven""Gunshot"
    "Halo""Harmonica""Harp""Harpsichord"
    "Helicopter""HonkyTonkPiano""JazzGuitar""Kalimba"
    "Koto""Marimba""MelodicTom""Metallic"
    "MusicBox""MutedTrumpet""NewAge""Oboe"
    "Ocarina""OrchestraHit""Organ""PanFlute"
    "PercussiveOrgan""Piano""Piccolo""PickedBass"
    "PizzicatoStrings""Polysynth""Rain""Recorder"
    "ReedOrgan""ReverseCymbal""RockOrgan""Sawtooth"
    "SciFi""Seashore""Shakuhachi""Shamisen"
    "Shanai""Sitar""SlapBass""SlapBass2"
    "SopranoSax""Soundtrack""Square""Steeldrums"
    "SteelGuitar""Strings""Strings2""Sweep"
    "SynthBass""SynthBass2""SynthBrass""SynthBrass2"
    "SynthDrum""SynthStrings""SynthStrings2""SynthVoice"
    "Taiko""Telephone""TenorSax""Timpani"
    "Tinklebell""TremoloStrings""Trombone""Trumpet"
    "Tuba""TubularBells""Vibraphone""Viola"
    "Violin""Voice""VoiceAahs""VoiceOohs"
    "Warm""Whistle""Woodblock""Xylophone"
  • Percussion sounds are represented as an expression of the form SoundNote. Possible percussion styles include:
  • "BassDrum""BassDrum2""BellTree""Cabasa"
    "Castanets""ChineseCymbal""Clap""Claves"
    "Cowbell""CrashCymbal""CrashCymbal2""ElectricSnare"
    "GuiroLong""GuiroShort""HighAgogo""HighBongo"
    "HighCongaMute""HighCongaOpen""HighFloorTom""HighTimbale"
    "HighTom""HighWoodblock""HiHatClosed""HiHatOpen"
    "HiHatPedal""JingleBell""LowAgogo""LowBongo"
    "LowConga""LowFloorTom""LowTimbale""LowTom"
    "LowWoodblock""Maracas""MetronomeBell""MetronomeClick"
    "MidTom""MidTom2""MuteCuica""MuteSurdo"
    "MuteTriangle""OpenCuica""OpenSurdo""OpenTriangle"
    "RideBell""RideCymbal""RideCymbal2""ScratchPull"
    "ScratchPush""Shaker""SideStick""Slap"
    "Snare""SplashCymbal""SquareClick""Sticks"
    "Tambourine""Vibraslap""WhistleLong""WhistleShort"
A sequence of three notes, each played for 1.75 seconds:
Export to a MIDI file:
This exports some chord notes to MIDI:
Export a few percussion sounds to MIDI:
This creates a musical fragment in the style of WolframTones by taking cellular automaton data and mapping it to musical notes:
Export to MIDI:
Generate a basic algorithmic composition and export it to MIDI:
A sequence of three notes, each played for 1.75 seconds:
In[1]:=
Click for copyable input
Out[1]=
Export to a MIDI file:
In[2]:=
Click for copyable input
Out[2]=
This exports some chord notes to MIDI:
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
 
Export a few percussion sounds to MIDI:
In[1]:=
Click for copyable input
Out[1]=
 
This creates a musical fragment in the style of WolframTones by taking cellular automaton data and mapping it to musical notes:
In[1]:=
Click for copyable input
Out[1]=
Export to MIDI:
In[2]:=
Click for copyable input
Out[2]=
 
Generate a basic algorithmic composition and export it to MIDI:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=