Midi is a binary format file. The basic structure of this file is generally "file header data description". The file header generally includes the file type; and MIDI data is composed of several sub-data with the same format. , these sub-data record all the information of a track in a multi-track format.
#The operating environment of this tutorial: Dell G3 computer, Windows 7 system.
MIDI files are binary files. Such files generally have the following basic structure: File header Data description File header generally includes the file type, because Midi files only have . There are two types with the extension mid, Class 0 and Class 1, and there are more formats of bitmap files that everyone is familiar with, so there is such a thing as a file header.
Unlike waveform files, MIDI files do not sample music, but record each note of the music as a number, so the file is much smaller than waveform files, which can meet the needs of long-term music. . The MIDI standard specifies the mixing and pronunciation of various tones, and these numbers can be resynthesized into music through an output device.
The main limitation of MIDI music is that it lacks the ability to reproduce true natural sounds and therefore cannot be used in situations where speech is required. In addition, MIDI can only record a limited combination of musical instruments specified by the standard, and the playback quality is limited by the synthesis chip of the sound card. In recent years, popular foreign sound cards generally use the wavetable method for music synthesis, which greatly improves the quality of MIDI music.
MIDI files have several alternative formats, such as RMI and CIF. The CMF file (creative music format) is a music file used with the Sound Blaster card. RMI files are a sub-format of RIFF (resource interchange file format) files used by Windows, called RMID, which is the format that contains MIDI files.
Midi format composition:
MIDI data is composed of several sub-data with the same format. These sub-data are recorded in a multi-track format. All information for a track. To add an additional track, simply append the data after the previous track, but don't forget to change the nn nn (number of tracks) in the file header.
Look at the global audio track first. The global audio track includes additional information about the song (such as title and copyright), song speed and system code (Sysx). Whether it is a global audio track or an audio track containing notes, it all starts with "4D 54 72 6B", which is actually the ASCII character "MTrk", followed by a 4-byte integer, which marks the bytes of the track Number, this does not include the previous 4 bytes and the 4 bytes itself. We can understand this in the following examples.
The next step is to record the data. Each data has the same structure: time difference event. The so-called time difference refers to the amount of time from the previous event to this event, and its unit is tick (the minimum time unit of MIDI). Its composition is rather special and will be explained here in binary.
Recommended: "Programming Video"
The above is the detailed content of What file format is midi?. For more information, please follow other related articles on the PHP Chinese website!