📜 ⬆️ ⬇️

“Unnecessary” MIDI recordings, or How software developers follow standards

So, let's talk a bit about the MIDI standard. Despite the fact that its main purpose was to create a single communication protocol between musical instruments, it gained quite a lot of popularity in the form of a file format. Due to the limited bank of samples and the poor quality of reproduction by the majority of standard software synthesizers, with an increase in the volume of data carriers and the spread of high-quality audio cards, this format has practically gone into oblivion, being supplanted by digitized audio recordings. Nevertheless, he managed to gain some popularity, especially on mobile devices, which until recently were rather limited in terms of iron.
But the essence of the story, in fact, is not that. The essence of the study of how conscientious in our time, software manufacturers are supported standards.

We go to Wikipedia . For a long time, the existence there has grown quite detailed, sometimes still inaccurate, but generally good, an article on this standard. So, read carefully and find here such an interesting point:

The format is designed so that any sequencer can read and write such a file so that its data is not lost, and so that the format is flexible enough so that applications can store their specific information in files that is understandable only to these applications but not understandable. other software applications, and when downloading MIDI files, information that is incomprehensible to other software applications does not lead to confusion, but is simply ignored. ... Various sequencer programs are able to read MIDI files just like to the different text editors read ASCII-files, which may contain auxiliary information that is understandable only to this editor. But unlike ASCII files, MIDI files contain digital information, and moreover, this information is stored as records, that is, groups of bytes that contain their own header, consisting of a recording identifier and recording length. These records can be formatted, loaded, ignored, etc., independently of each other. In order to work with the recordings, the application programs use additional information recorded in the MIDI file. For example, it is possible that the program “wants” to keep the flag indicating that the user has set the metronome sound on. A program can insert this flag into a MIDI file in such a way that another application program can skip this flag without attention. In the future, perhaps the existing MIDI format will be expanded and new record types will appear. New programs for working with MIDI files will recognize new types of recordings. However, old MIDI files can be played in their original form. The MIDI format is designed in such a way that its earlier versions will be compatible with its extensions.


As we can see, the standard does not impose any restrictions on the recordings that a MIDI file can contain, that is, in addition to the standard MThd and MTrk, it can contain anything, provided that it is correctly stored as a record with a four-byte header and four-byte length records And any player that supports playback of MIDI files must ignore such a record. But is it? To check this, we need a file containing such non-standard entries. You can, of course, create it from any MIDI file yourself, by editing it in a hex editor, but there are real examples of such files ...
')
So, surely many visitors who have an idea about Sony Ericsson phones on A100 / A200 platforms, remember the simple polyphonic editor MusicDJ. Its essence is that of the finished segments of drum, bass, keyboard and wind parts of different styles is going to a kind of musical work. The majority, of course, didn’t go beyond the “Hello world” of the simple “tili-tili-trailing-vali”; something worthwhile was written in this editor. And how sad they were when it turned out that their products could not be played on either the computer or other phones. But the point is not that the files are saved in some kind of proprietary format not known to anyone. These are regular MIDI files, but with one “but”: they contain a “non-standard” recording with the SEM1 header. Why is it needed? The fact is that MusicDJ allows you to not only create melodies, but also edit them. And since it is rather difficult to recognize in which pieces it was assembled from, it is rather difficult to write a sequence of numbers for these pieces into the file. Everything is simple - the editor reads the SEM1 record, restores the sequence of pieces of music and the segments themselves may not even read. So, take the sample file from the standard ringtones - MusicDJ demo - and view it in hexadecimal:


As we see, nothing is broken, everything is in order with MThd , with SEM1 too, the record length corresponds to the specified one. We try to play ... Windows Media Player, Media Player Classic, Nokia Multimedia Player, Winamp, GOMPlayer, KMPlayer ... all, as one, give a playback error. Even AIMP and XMPlay with their vaunted bassmidi library, which uses not a synthesizer, but a so-called. “Sound fonts”, due to which it provides excellent sound quality, they refuse to “chew” the file.

But “our proud Varyag doesn’t surrender to the enemy” ... On the disk from the phone’s configuration (in this case, the W660i), along with a program for converting music to MP3 and some edited Photoshop edition (more like AcdSee functionality, and Trial- version) is the Apple QuickTime Player installer (by the way, despite the fact that iTunes has long been the player's role on Macs, this is a simple product that many people had during Win98 because of the support of a large number of codecs, it is still supported and updated by the corporation, and for MacOS, and for Windows). It is curious that about why he is there, in fact, lies, the documentation does not say anything. Install, open it in our ill-fated file, and - lo and behold! - it is reproduced. The reason for this is simple - QuickTime Player uses its own synthesizer (developed, however, by Roland), which for some reason copes with such a trifle. On the other hand, the melody is played in it with a noticeable panning, although the music on the phone with headphones sounds uniquely single-channel, and there are no panning commands in the file. Apparently, this way the synthesizer imitates the sound of the orchestra (although this, in fact, must be taken care of when recording the file, and not during playback).

To confirm the hypothesis, we arm ourselves with a hex editor, delete the “unusual” entry from the file, and - voila! - the file is played in any player. But in MusicDJ, you can’t edit it already. Sad, but true. And the question is involuntarily raised: why such a trifle, like an unknown entry in the file, brings players to a stupor? Why does streaming stop when a few dozen bits are lost? Why can a small scratch on a DVD drive lead to its complete non-recognition by DVD players? The answer is one: if architects designed houses in such a way as programmers write code, then all cities in seismic zones would have been in ruins for a long time ... And this is not even a matter of conscience, but in a rigid time frame, turning the creative profession into a way of earning, formalization software certification process ... It’s sad to see that the volumes and resource-intensiveness of operating systems are growing faster than the capacity of the drives, the frequency of the processors and the amount of RAM.

Source: https://habr.com/ru/post/167087/


All Articles