In this tool-assisted education video, I demonstrate how to write a MIDI player from scratch.
Please see this page for more details, including the source code:
http://bisqwit.iki.fi/jutut/kuvat/programming_examples/midiplay.html
MIDI is a Music Interchange file format which describes music in abstract terms such as "piano key C-4 pressed down". A synthesizer is required to reproduce audible music from MIDI files. In this tool-assisted education video, I create one such synthesizer program from scratch, using the OPL3 hardware synthesizer as the backend for generating the actual sounds.
You see me type every line. The resulting program contains the rudimentary features for playing most MIDI files just fine, including the pitch slides and pans, but it lacks other special effects like vibrato, nor does it support any more tunings than the standard equal-interval mathematical tuning. It supports the loopStart/loopEnd mechanism found in authentic Final Fantasy VII MIDI files.
This is probably my best MS-DOS MIDI player so far (at least in some aspects), and I have written two. The first one, written in 1998, however eventually evolved also to convert them into S3Ms...
This was also the most difficult production-for-show so far in terms of getting it right; BASIC has its own unique challenges at debugging it, and I did accidentally introduce many bugs into this program, despite writing it from a script. I did fix them too, though. But more time was consumed doing that than I had planned.
Music played during this video:
- Zoolook by Jogeir Liljedalh (a few seconds in the beginning)
- Predicament / Chrono Cross (BGM during programming)
- Chmmr and Arilou themes / Star Control III (MIDI)
- Barret and battle themes / Final Fantasy VII (MIDI)
- Airship and Big whale themes / Final Fantasy IV (MIDI, sequenced by Andrew Thompson)
My favourite part of this video: 08:53 onwards.
P.S. Eventually this program evolved into a C++ opensource project! Check it out here: http://bisqwit.iki.fi/source/adlmidi.html
You have to use CTRL-Scroll lock now instead of CTRL - Break.
kiyotewolf 3 months ago
@kiyotewolf Thanks for the tip: It did not work, though. I tried it, back then. DOSBox simply does not generate the break signal.
Bisqwit 3 months ago
OPL sounded amazing
mattedj 6 months ago
@mattedj The attraction with it for me is that it allows for great music without the use of any copyright data - e.g. audio recordings, i.e. samples. (And I cannot choose good samples anyway.) With OPL, it's just input a few numbers, and there you have a good instrument.
Bisqwit 6 months ago
Wow, GW-BASIC still being used in 2010?! O__o
I remember writing small programs with it as a child in the early 90s :-)
I even created a stupid "key smasher" game in GW-BASIC complete with characters and animations made in Autodesk Animator (shown through AAPLAY with the shell command xD). It was a terrible game but fun to play with friends :-)
OMA2k 6 months ago
@OMA2k I use it for creating entertaining videos. Pretty much for nothing else. I use QBasic marginally more (in the recent 8 years or so, PHP took its place for me), but for these videos, sometimes GW-BASIC is the handier tool, because it naturally allows for more concise implementations. Also, I can have syntax highlighting for GW-BASIC within its "IDE", which I cannot do for QBasic. (In a recent video, I used an editor that I created myself to provide similar experience for QBasic.)
Bisqwit 6 months ago