One of the first languages ββI tried to write was the assembly language of MIDI files. You must determine the tempo and bank of instruments, and then many lines of notes (note name, initial bit-per-current measure, duration, additional accent), dotted with dashed lines ("meas \ n") and dynamics (ppp, pp, p , mp, mf, f, ff, fff).
In macro language, it was not used to repeat sequences, change channels and record new tracks. This required my first hash table, and the cunning cross-on-fingers called qsort to alternate channels in a time sequence (implicitly carried by each Note-On / Note-Off event).
When I returned to him a year later, he became a victim of bit rot. After a bit of a fight, I rediscovered that the sort-and-output-everything function was called by explicit EOF code. The macro-expanded song was easily 20,000 lines with this important EOF line, so the 1 / 200,000th chance to be noticed, trying to understand what is going wrong on the check!
I'm a little glad that all the evidence is safely hidden in a dead processor under a microwave trolley. Horror !!
Edit: After further reflection in the MIDI format, there are some interesting things. It has an integer type of variable length (IIRC using the sign bit for the signal of the last byte). It is byte-oriented, designed to work on 9 parallel wires; and he has a crazy time synchronization that I never understood. But all I cared about was that the Windows95 media player could interpret the output (it could even use an 8-bit bank of MIDI tunes built into the sound card, and the cymbals were perfectly distorted).
source share