“Extra” MIDI Records, or How Software Developers Respect Standards

So, let's talk a little about the MIDI standard . Despite the fact that its main purpose was to create a single protocol for communication between musical instruments, it gained quite a lot of popularity in the form of a file format. Due to the limited sample bank and low quality playback of most standard software synthesizers, with the increase in the volume of storage media and the spread of high-quality audio cards, this format has practically disappeared, being supplanted by digitized audio recordings. Nevertheless, he managed to gain some popularity, especially on mobile devices, which until recently were quite limited in terms of hardware.
But the essence of the story, in fact, is not that. The point is to study how shamefully standards are being maintained by software manufacturers these days.

We go to Wikipedia . Over a long time, the existence there has grown quite detailed, in places still inaccurate, but generally good, an article on this standard. So, we read carefully and find here is such an interesting moment:

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 save their specific information in files that is understandable only to these applications, but not understandable other application programs, and when loading MIDI files, information incomprehensible to other application programs does not lead to misunderstandings, but is simply ignored. ... Various sequencer programs can read MIDI files, similar to 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 in addition, this information is saved as records, that is, groups of bytes that contain their own header, consisting of a record identifier and a record length. These records can be formatted, loaded, ignored, etc. independently of each other. To work with recordings, application programs use additional information recorded in a MIDI file. For example, it may be that the program "wants" to save a flag indicating that the user has set the metronome sound on. A program can insert this flag into a MIDI file so that another application can skip this flag without attention. In the future, perhaps the existing MIDI format will be expanded and new types of recordings will appear. New programs for working with MIDI files will recognize new types of records. However, older MIDI files can be played back in their original form. MIDI format is designed in such a way

As we can see, the standard does not impose any restrictions on the records that a MIDI file can contain, that is, in addition to the standard MThd and MTrk, it can contain anything you like, provided that it is correctly saved as a record with a four-byte header and four-byte length records. And any player that supports playback of MIDI files is required to ignore such a recording. But is it? To verify 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 a kind of musical piece is assembled from ready-made sections of drum, bass, keyboard and wind parts of different styles. Most, of course, didn’t go beyond the “Hello world” to the simple “tili-tili-trawl-wali”, only a few wrote something worthwhile in this editor. And how did they get upset when it turned out that neither their computer nor other phones reproduced their submissions. But the point is not that the files are saved in some proprietary format that is not known to anyone. These are ordinary MIDI files, but with one “but”: they contain a “non-standard” record with the title SEM1. Why is it needed? The fact is that MusicDJ allows you to not only create tunes, but also edit created ones. And since it is rather difficult to recognize in which file it is assembled from which pieces, the sequence of numbers of these pieces is separately recorded in the file. It's simple - the editor reads the SEM1 record , restores the sequence of music sections and the segments themselves may no longer even read. So, we take the sample file of the standard ringtones - a MusicDJ demo - and view it in HEX:

As we can see, not broken anything with MThd okay with SEM1also, the record length matches the specified. Trying 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 much-praised bassmidi library, which uses not a synthesizer, but the so-called. “Sound fonts”, due to which it provides excellent sound quality, they refuse to “chew” the file.

But “our proud Varangian doesn’t surrender to the enemy” ... On the phone’s CD (in this case W660i), along with a program for converting music to MP3 and some clipped Photoshop edition (more like AcdSee in functionality, and even Trial- version) is the installer of the Apple QuickTime Player (by the way, despite the fact that iTunes has long played the role of a player on Macs, this is a simple product, which was used by many in Win98 due to the support of a large number of codecs, is still supported and updated by the corporation, and how for MacOS and Windows). It is curious that nothing is said in the documentation about why he actually lies there. We install, open in it our ill-fated file, and - lo and behold! - it is reproduced. The reason is simple - QuickTime Player uses its own synthesizer (developed, however, by Roland), which somehow copes with such a trifle. On the other hand, a melody is played in it with noticeable punning, although on the phone in the headphones the music 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, you need to take care of when recording the file, and not when playing it).

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, of course, it cannot be edited. Sad, but true. And the question involuntarily arises: why such a trifle as an unknown record in a file leads players into a stupor? Why does streaming stop when a few tens of bits are lost? Why can a small scratch on a DVD drive make it completely unrecognizable by DVD players? There is only one answer: if architects so designed houses, how programmers write code, then all the cities in seismic zones would have been in ruins for a long time ... And this is not even a matter of conscience, but a tight time frame, turning a creative profession into a way of earning, formalizing software certification process ... It's sad to see

Also popular now: