Reverse Engineering Casio's .CR5 File Format
I recently found a revived interest in a Casio CTK-810IN electronic keyboard I have had since childhood. The keyboard has an SD card slot where you can save and play MIDI(1) files. This is something that has interested me since childhood, since MIDI files sounds much better on the keyboard using high quality samples than my computer with its basic soundfont.
- MIDI (as far as this article is concerned) is a format for storing audio data. But unlike most formats which store a long stream of amplitudes polled 44 to 48 thousand times a second, MIDI files store data about the notes that are played - their pitch, duration, velocity and instrument. Since the files don't contain any actual audio, how they sound depends on what device is playing them, since that's where the audio samples for each instrument are stored. If you've worked with computer graphics, think of MIDI files as the SVG of music.
But there's a catch. You need a special piece of software called the Casio SMF Converter to convert the .mid file used by computers to a format compatible with the keyboard. This program is extremely old and only available for Windows. As a programming exercise, I decided to attempt to reverse engineer the file format to create my own cross-platform SMF converter. However I have no prior experience with this kind of stuff, so I decided to start with something simpler. My keyboard happens to use another proprietary format, so I decided to tackle that one first.