Monday, March 24, 2014

Raw Adlib Capturing with DOSBox & Playback with DOS

One of DOSBox's best features is its ability to capture raw OPL commands and data with timing data to preserve as perfectly as possible the music data for Adlib and Sound Blaster cards.  The capture feature supports OPL2, dual OPL2 and OPL3.  One of the biggest advantages to this format is that the resulting files are quite small, maybe 6-7K for a single track or song.  Another advantage is that you are not capturing a wav file of an emulated OPL2/3, you can take this .dro file and play it back on real hardware.

The resulting files have a .dro extension, which stands for DOSBox Raw OPL format.  Fortunately, the capturing does not begin until the first OPL reads and writes are detected, so there will not be a lot of silent dead time.  However, beginning with 0.73, released on May 27, 2009, DOSBox updated its DRO capture format to version 2, which is incompatible with any software written for version 0.1 (formerly known as 1.0).  For the differences between the two formats, they can be found here :

http://www.shikadi.net/moddingwiki/DRO_Format

If you use DOSBox 0.72 or below (feature has been present since 0.63), then DRO version 1 files will be created.  0.73 or higher will only create DRO version 2 files.  Since most people intend to use DOSBox 0.74 or SVN, I have put together this guide to software.  I recommend using a current SVN build with the following patch applied (use the patch as given in the latest post) :

http://www.vogons.org/viewtopic.php?f=41&t=38029

As you might guess, capturing OPL music from a game may not always give a clean track.  The track may loop and you will need to delete the repeated portion, or a second track may immediately segue from a first track, and you want the tracks separate.  Sound effects may be playing.  The program DRO Trimmer v4r4 will work with version 1 or 2 .dro files, and is quite easy to use.  It also functions as a player for either type of DRO version file.  Get it here  :

http://www.jestarjokin.net/apps/drotrimmer

As its name implies, DRO Trimmer is a bare-bones trimmer.  If you want to use fade-ins and fade-outs or other more sophisticated editing techniques, you will need to use a tracker.  I do not know of any that work with the .DRO format.  Nor do I know of any utilities that would convert DRO into a tracker-friendly format like S3M.

The mainstay of playing Adlib files in DOS on real hardware is a program called AdPlay, based on the AdPlug library.  It can play just about every OPL file format out there, including proprietary formats from Sierra, LucasArts, Origin, Apogee and Westwood.  It also supports various tracker formats and Roland ROL and Creative Labs' CMF formats.  However, the DOS port of AdPlay was last updated in 2007 and thus only supports DRO version 1 files.  However, do not write it off just yet.  Downloads are on this site :

http://adplug.sourceforge.net/index.php

More than just trimming DRO files, the DRO Trimmer program can also convert DRO version 2 files into DRO version 1 files.    Additionally, there is a program called DRO2IMF, which will convert DRO version 1 and 2 files into the IMF format that Apogee games use.  It is located here :

http://www.shikadi.net/utils/dro2imf

You will also need a DPMI extender to run AdPlay, and the one this program expects is called csdpmi.  For this reason, a 386 or better is required for playback.  A version that works with AdPlay can be found here :

ftp://ftp.delorie.com/pub/djgpp/current/v2misc/csdpmi5b.zip

AdPlay will play IMF files and DRO version 1 without a problem, so either should work as a solution. However, I found that the converted IMF file plays correctly with AdPlay while the converted DRO file did not.  I assume a natural DRO version 1 file, as recorded from DOSBox 0.72 or below, would work correctly with AdPlay.  However, because DRO version 1 files are less accurate and would not have the benefit of the patch identified above, I would not advise using the older DOSBox for accurate OPL capture.

Another solution is a program called imfplay, which has the benefit of working with .DRO version 2 files without conversion.  This program I have personally tested in my 486DX2/66.  However, there are several caveats with using it on real hardware.  First, it only supports OPL2 writes, OPL3 writes in a DRO file are ignored.  The irony of this limitation will soon be apparent.  Second, the cache of the 486, internal and external, must be disabled or the music will come out garbled.  Whether it works on faster machines is unknown to me.  Third, a sound card with an OPL3 chip must be used.  OPL3 chips require fewer delays with port writes than OPL2 chips, and imfplay was intended to work with DOSBox, which does not care about delays to its emulated OPL chips.  AdPlay does not have the OPL2 limitation or the slowdown requirement.  You can find imfplay here :

http://software.kvee.cz/imfplay/

One thing I initially overlooked when I first wrote this post was that Harekiet, one of the authors of DOSBox, had written a small utility called DROPLAY that would allow DOSBox to play the v.2 DRO files made with DOSBox 0.73 and later versions.  You can get it in the last post from here :

http://www.vogons.org/viewtopic.php?f=32&t=16217

DROPLAY does work on real hardware, so you can use it with a 486 or even something lesser to play back DRO v.2 tunes.  I would prefer to use DRO files over a converted IMF file because the IMF file may require timing information that seems specific to Apogee games but may not be applicable generally to OPL game music.

2 comments:

  1. Love your blog! Do you have any advice on recovering old low-density 5.25" diskettes? I built a dos machine and am going through old disks and these seem to be the most problematic. I'm unsure if the density of the reading drive is a factor or not...

    ReplyDelete
  2. FWIW, I ended up using a 5.25 drive from a Commodore Colt and it did the trick.

    ReplyDelete