MIDI (.mid)
背景
-
- MIME 类型:audio/midi
- 标准的 MIDI 文件格式.
- 音频格式.
- 用于控制电子乐器,计算机声卡和编曲器.
- 存储离散声音事件序列,例如一个音符的起止,速度和音色信息以及乐器和声音库编码.
- MIDI 是 Musical Instrument Digital Interface(乐器数字接口)的缩写.
- 二进制文件格式.
- 1983年引入.
- 由 MIDI 制造商协会(美国)和音乐电子工业 MIDI 委员会(日本)开发和出版.
Import 与 Export
- Import["file.mid"] 导入一个 MIDI 文件,返回一个声音对象.
- Export["file.mid",expr] 把声音对象导出至 MIDI.
- Import["file.mid",elem] 从一个 MIDI 文件中导入指定的元素.
- Import["file.mid",{elem,suba,subb,…}] 导入一个子元素.
- Import["file.mid",{{elem1,elem2,…}}] 导入多个元素.
- 导入格式可以用 Import["file","MIDI"] 或 Import["file",{"MIDI",elem,…}] 指定.
- Export["file.mid",Sound[…]] 从一个包含 SoundNote 基元的 Sound 表达式中创建一个 MIDI 文件.
- Export["file.mid",expr,elem] 通过把 expr 作为指定的参数 elem,创建一个 MIDI 文件.
- 文件格式可以用 Export["file",Sound[…],"MIDI"] 明确指定.
- 请到以下参考页面了解完整的基本信息:
-
Import, Export 从文件导入或导出到文件 CloudImport, CloudExport 从云对象导入或导出到云对象 ImportString, ExportString 从字符串导入或导出到字符串 ImportByteArray, ExportByteArray 从字节数组导入或导出到字节数组
导入参数
- 通用的 Import 元素:
-
"Elements" 该文件可用的参数和选项列表 "Summary" 文件摘要 "Rules" 所有可用参数的规则列表 - 数据表示元素:
-
"Sound" MIDI 文件表示为一个 Sound 对象 "Sound",n MIDI 文件的第 n 个声道,以 Sound 对象表示 "SoundNotes" MIDI 文件中所有声道的音符 "SoundNotes",n MIDI 文件中第 n 个声道的音符 "RawData" MIDI 文件中所有声道的原始事件 "RawData",n MIDI 文件中第 n 个声道的原始事件 - 元数据元素:
-
"Metadata" MIDI 文件中所有声道的元数据 "Metadata",n MIDI 文件中第 n 个声道的元数据 "Duration" 持续时间(以秒为单位) "Header" MIDI 文件中的标头 "TrackCount" MIDI 文件中的声道数 - 表示参数的数据:
-
"Sound" 一个包含 SoundNote 基元的 Sound 表达式 - 对于 MIDI 文件,默认情况下,Export 使用"Sound"参数.
- Export["file.mid",Sound[ SoundNote[0]]] 创建一个 MIDI 文件表示“中央 C”音符在默认的 "Piano" 样式中被播放1秒.
- Wolfram 语言中的音调规范0对应于 MIDI 音高水平60.
- Export["file.mid",Sound[SoundNote[pitch,t,"style"]]] 指定音长 t 和仪器样式. 支持以下通用 MIDI 样式:
-
"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" - 打击乐的声音表示为形式为 SoundNote["perc",t] 的一个表达式. 可能的打击乐样式包括:
-
"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" - Import 默认情况下,当从 MIDI 导入时,使用 "Sound" 元素.