Classic Computer Magazine Archive START VOL. 3 NO. 12 / JULY 1989

ON DISK!

BABEL

Sound File Conversion for the ST

BY JIM PIERSON-PERRY


The biblical Tower of Babel lends an effective metaphor to the present state of sound file compatibility. Just as the builders of the tower couldn't understand each other, sound file formats aren't compatible, either--or weren't, until now. Contributing editor Jim Pierson-Perry developed Babel so the ST can transfer sound files from format to format easily and painlessly.

Sound files--any old way you choose them. File BABEL.ARC on your START disk.


I love to collect digitized sounds and use them for anything from spicing up the autoboot sequence in one of my programs to making music. Working against me, though, is the absence of a common file format for all of my digitized samples.

Babel grew out this need to transfer, freely between the various ST file formats. The program also has the ability to import sound files from other sources such as Mac Sound-Cap/SoundMaster, Amiga IFF, Hybrid Arts' ADAP and Digidesign's Sound Designer/Softsynth. And there are hundreds of sound files on bulletin board systems across the country that Babel will recognize. (Editor's Note: See Jim's comparison review of three sound digitizer's for the ST in this issue.)

To run Babel, copy the files BABEL.ARC and ARCX.TTP onto a blank, formatted disk and un-ARC BABEL.ARC following the Disk Instructions elsewhere in this issue. Now, double-click on BABEL.PRG to access the program. I've included a few sample files for you to experiment with. Babel was written in HiSoft BASIC and runs in all three resolutions.


babel.jpg
Looks can be deceiving. The Babel screen doesn't have much to it,
so it seems, but you don't need fancy graphics to import and convert
sound samples.

Straightforward Operation

Babel is controlled from the menu bar. (Sorry, no fancy graphics or GEM wonder screens. Babel is a straightforward file utility program--I wanted to save as much memory as possible to accommodate large sound files.) The menu headings are File, Rate and Audio.

The File menu is where all the action is. Click on Load Sample to load a sound file. As the file is read, its internal structure is checked to identify its type. Babel recognizes the formats for Replay4, Digisound, ST Sound Digitizer, Sound Designer/Softsynth, Macintosh SoundCaps/SoundMaster and Amiga IFF. The default is Replay4. Note that any file will be taken even if it's not a sound file. Go ahead and listen to your ST Writer text files--noise to most, though some could call it experimental.

Once the sound is loaded, click on Audition to play it through. I incorporated Replay4 into Babel to run the sampled sounds, so the rates given under the Replay menu are limited to those supported by that program. While the sound is running, press the spacebar if you want to hear it again from the beginning. Adjust the replay rate and listen to the pitch shift up or down. The highest rates are only supported through the cartridge audio out (a Replay4 restriction). A sample in memory will stay there until another is read in; you can save multiple copies in different sound file formats.

Click on Save Sample to save the data to disk. It will be saved using the currently active Save Format choice from the Audio menu. The sound data can be saved in any one of the three current ST sound file formats (Replay4, Digisound and Navarone/Hippo).

A word of warning: Babel does not check a sound file to make sure there is sufficient room on the disk before saving it. Also, it doesn't let you format disks and disables all desk accessories. Since sound files are notoriously long, always have a supply of blank, formatted disks ready before you start playing with Babel.

For a quick test of Babel, click on String Synth to numerically create a sample that sounds convincingly like a plucked string. A dialog box will appear asking for your choice of wavetable size. As the wavetable size increases, the sound gets deeper and lasts longer. String Synth is based on the industry standard Karplus-Strong algorithm, which in turn is based on Bob Damiano's Apple II code implementation in the December 1987 issue of Electronic Musician. It's just a tiny taste of what can be produced by more sophisticated sound-generation programs like Digidesign's Softsynth and Dr. T's Sample Maker.

Shift Base takes the current sample in memory and shifts it from a signed integer basis (like Digisound) to an unsigned integer basis (like Replay4). If you're hearing a lot of background noise over your sample, click on Shift Base to correct the problem.

Rate and Audio control your preferences as to the sound-playback rate, audio-out destination and format for saving files. The default settings are 20 KHz replay rate, with the sound to be played through the monitor speaker and files saved in Replay4 format. You must have the Replay4 or Digisound Professional cartridge installed before you boot. (Remember: Never plug a cartridge in while the computer is on unless you seriously want to trash your equipment!) Note that the Navarone cartridge uses a different scheme than the others and will not work with Babel. You can, however, save files in the Navarone format and play them with the Navarone sound software.


Some Program Take-Apart

The majority of file-format conversions consisted of simply removing a header and adjusting 8-bit integer values from a signed (range of -128 to 127) to an unsigned (0 to 255) system. The Sound Designer format is slightly different because it stores data as 16-bit signed integers. For these, I just took the most significant byte. Macintosh sound files have a different sampling-rate base than Replay4 or Digisound (typically 22 or 11 KHz instead of 20 or 10 KHz). If I were to convert the sound directly, the 10-percent sampling rate difference would cause a change in pitch and voices would sound a little deeper. I opted to "downsample" Mac sound files by throwing out every sixth data byte. This preserved the pitch of the initial sound file without any apparent loss of fidelity. The same process was done for Amiga IFF files that typically run at 8.3 KHz, versus the closest Replay4 equivalent of 7.5 KHz.

There is a "hidden" file-import module that handles sound files created by the IBM MIDIUM librarian program for the Mirage sampler. This is probably of limited interest to most users, unless you have a Mirage or access to MIDIUM data files, but it's there. The only clue to a file being in MIDIUM versus Replay4 format (neither use any recognizable header) is that MIDIUM files are always 61661 bytes long. If you're converting a Replay4 file that matches this length exactly (not likely!) you'll get a dialog box asking if it is a MIDIUM file. Just say no.

The standard in Replay4 file format is a straight sample data dump with no additional information. I have followed the lead of public-domain programs that use Replay4 files and included an additional byte at the start of the sound file denoting the appropriate repIay rate.


The BASICs

Babel was written in HiSoft BASIC Professional. Since most of the preliminary file-conversion code had been hacked using GFA BASIC, I decided to stay with a BASIC language.

However, I needed a language that supported SELECT CASE statement constructions and had a compiler. That ruled out GFA BASIC (versions 2.0 and 3.0). The clincher came with the inclusion of a library file on the Replay4 program disk that could be bound into the standard Hisoft BASIC compiler library (Replay4 was written in Hisoft BASIC). Doing this gave me the ability to read, play and create samples directly from new BASIC commands. Another good argument for using HiSoft BASIC is that the only limit on string size is the available computer memory--no more 32K restrictions. This let me read a sound file in a single operation as well as simplify cut-and-paste operations between large strings. Thanks, HiSoft! (Editor's Note: Look elsewhere in this issue for a review of HiSoft BASIC and HiSoft BASIC Professional.)


Wrap-up

Anyone interested in MIDI applications will want to use Babel as a tool for getting high-quality sound files from Sound Designer format into Replay4/Digisound format. Using the MIDI play functions of these programs turned the ST into a reasonable quality low-budget sampler. Sound files can also be used with Digidrums (by MichTron) and Beat Box (by Digisound) to turn your ST into a drum machine and play multiple sounds simultaneously. Another use for Babel is to prep sound files to work with START's AVS program (November 1988 issue) that marries sound effects with Cyber animation sequences.

It is appropriate to put in a word concerning the ethics of sampling. This is a very heated topic in music circles (see "An American Sampler" in the December 1988 issue of START for more background). But as long as you do it for your own personal use, there shouldn't be a problem.

Contributing Editor Jim Pierson-Perry is a chemical engineer who lives in Elkton, Maryland. This is his first program for START.



Tracking Down Sound Files

When it comes time to beef up your sound file collection, the best places places to go hunting are the national bulletin board services. The Atari and MichTron areas in GEnie and CompuServe have a number of files, mostly in Replay format. Another great source is the MIDI roundtable in GEnie which features many files in Sound Designer format (ADAP files also use this format) with new ones constantly added. Musically oriented samples are the forte of PAN, which offers a large variety in Sound Designer format.

The more adventuresome may want to try the Mac and Amiga libraries. Beware of Mac sound files containing the extenders .PIT or .SIT; these are compressed (similar to .ARC files) and cannot be translated directly by Babel. If you have access to the Magic Sac or Spectre 128, download them with a Mac terminal program and decompress them with the appropriate utility (Packit or Stuffit). You can then use a program like Transverter or Mover to take them from Magic/Spectre into GEM format. Doing this, however, trims the 128-byte Mac header that Babel uses to recognize Mac sound files. Fortunately, the resultant trimmed sound file is identical to and is read as a Replay4 file.

Two things to remember: Mac users don't seem to be very reliable about mentioning if files have been compressed. If Babel spits out garbage from what you thought was a normal Mac sound file, take a look at the input file with a file editing program. If you see the dreaded extenders .PIT or .SIT within the first 128 bytes, you've been nailed. The other things to remember is that there are several different types of sound-file resources on the Mac. The only ones I have tested with Babel are of the Soundcap and Soundmaster genres. Files described as start-up INITs will definitely not work because they contain additional system coding. Then again, maybe if you just trim off the first couple of hundred bytes the sound itself may be OK. I suggest trying this one with one of the ST sound digitizing packages in stead of a file editing utility so you an get visual clues to work with.

Mac-based Sound Designer files require special handling. If you download them directly into GEM files (using FLASH!), you must manually trim the Mac header before Babel will recognize the Sound Designer format. The easiest way to do this is with a file-editing program like the Byte Mechanic (START Special Issue #4). Downloading as a Mac file under Magic Sac/Spectre 128 does not require this step because the trim automatically occurs when you bring the files into GEM as described above. Whew!

Finally, there are a couple of good shareware programs on the BBSs that work with these sound files. Autoplay by David Sullivan lets you designate a sound file to be played when you first boot your ST. Another good one is Playback (by Ric Clayton) which comes in both a desk accessory and normal program versions. In addition to playing any designated Replay4 sound file, it also can be set up to play a startup sound.