OS/2 eZine - http://www.os2ezine.com
Spacer
16 August 2001

Check out the new JunkSpy at http://www.junkspy.com/os2ezine


Making and Playing mp3 files with OS/2

I've become hooked on playing mp3 files (or more correctly, MPEG-1 layer 3 audio files) on my computer. It is so much more convenient to have all my CD's available on my computer, than to have to get out the disc, put it in the player and then only listen to the songs that I want to hear. The problem was that none of the software available for OS/2 to create mp3s did exactly what I wanted to do, which was this:
  1. Create an mp3 file directly from the tracks on a CD with no intermediate steps.
  2. Have automatic file naming using the online CD database www.freedb.org.
  3. Store information about the mp3 in the extended attributes on the file.
  4. Store the mp3 files in an "artist name\album name" directory structure.
When Tonigy was released, it became possible to use any mp3 encoder, such as lame, to directly create an mp3 from the CD. Tonigy is an installable file system which, among other things, presents an audio CD as a series of WAV files on an added drive letter. The first item on my list was taken care of. Audio CD Creator enables lookup of CD titles with an online CD database, with the use of its helper program querycddb.exe. Audio CD Creator is a set of workplace shell classes that is a front-end to burning CDs with cdrecord.exe. The second item on my list seemed possible. I decided to write a rexx program to tie the first two items together, and take care of items three and four as well. The result is tutil.cmd which stands for Tonigy Utility.

How to Install it

First, download Tonigy (http://www.defgroup.com/tonigy/index.html). It is shareware so you can try it to make sure it works for you before you register it. If you decide to use it, be sure to register it. When you install Tonigy, you will get a control panel that will mount a drive letter that is linked to your CD-ROM drive. When you have an audio CD in the CD-ROM drive, the tracks will show up as WAV files on the Tonigy drive. Make a note of both your CD-ROM drive letter, and the Tonigy drive letter.

Next download Audio CD Creator (http://www.os2world.com/cdwriting/). You don't have to have a CD recorder to install it, and you can do other useful things with it without a CD recorder, so I recommend installing the whole thing. When its installed, it creates a "CD-Writing Utilities" folder on the desktop that contains, among other things, a template to "Create an Audio CD." This isn't necessary for the creation of mp3 files, but it comes in handy when you want to play them.

Now download tutil.zip (http://www.users.qwest.net/~scorey1/) from my web site. The archive contains three files: the rexx program tutil.cmd, the configuration file tutil.opt and a readme.txt file. When you selected the location where you installed Audio CD Creator, a "bin" directory was created in the "audiocdcreator" directory. The easiest way to install the rexx program is to copy tutil.cmd and tutil.opt to that "bin" directory, since it requires that querycddb.exe is in the same directory. On my system, I have tutil.cmd and tutil.opt in D:\apps\audiocdcreator\bin. You should also download Lame (http://users.ox.ac.uk/~magd1113/mpeg) and put it in the same directory.

Before tutil.cmd will work, you need to edit the tutil.opt file so that it has all of the necessary information about your CD-ROM drive letters, and options for encoding. The first line of tutil.opt just identifies it as the tutil.cmd configuration file. The second line is where you put your CD-ROM drive letter and the third line is where you put your Tonigy drive letter. The next four lines deal with freedb.org access. Line four is the part of your e-mail address that comes before the "@" sign and line five is the part of your e-mail address that comes after the "@" sign. Line six is the online CD database host. A list of alternate hosts is available at www.freedb.org (http://www.freedb.org/sections.php?op=viewarticle&artid=9) so you can choose one that is closer to you. Line seven is the port for the online CD database and should be 888. The eighth line is the path where you want to store your mp3 files. If you're like me, it should be on a drive with lots of space. The ninth line has the encoding options for Lame. I find that a bit rate of 160 is sufficient for listening from my computer, but if you want to save some hard disk space you could set it to something lower like 128 or 112, but the quality of sound goes down with lower bit rates. Conversely, if you want higher quality sound, but aren't concerned about disk space set it to 320. The rest of the tutil.opt file just contains documentation about the format of the file.

How to Use It

Now you are ready to make some mp3 files. Put an audio CD into your CD-ROM drive, start the Tonigy Control program and attach the drive.

Now open a command prompt and change to the directory where you've put the required files. (On my system it's D:\apps\audiocdcreator\bin) By default, tutil.cmd looks up the CD on the online database, and if it is found it writes information about each track to the extended attributes of the files on the Tonigy drive. To create the mp3 files, type "tutil /mp3" and it should look up the CD online, and then start Lame to encode the tracks.

Tutil.cmd will create an artist directory under the main mp3 directory that you specified, and then an album directory under the artist directory, if they don't already exist. The mp3 filename will be in the format of "tracknumber-trackname.mp3" or "07-Three Day Weekend.mp3" for example. I have a 400 MHz Celeron and I get an encoding speed of about 2.2x real time.

If you type "tutil /?" you get a list of options for tutil.cmd. I've already told you the default behavior (with no command line options) and the /mp3 switch. The other switches are:

/c - copy files to dir specified in config file
/noeas - don't write extended attributes to tonigy drive
/keep - keep the temp file cddbxxxx.tmp which contains the CD info
/ask - ask which track to encode (only use with /mp3 or /c)
/nogenre - don't include genre in the ID3 tag
/? or /h - this help message

You can also specify a different configuration file on the command line:

tutil c:\differentconfig.file

The /c switch will just copy the WAV files to the mp3 directory. I added the /nogenre switch because Lame sometimes has a problem with the genre category returned by the online database. The /keep switch won't delete the temporary file that is created which contains the information returned by the online CD database. The /ask switch will interactively ask you for a track or range of tracks to encode so you don't have to encode the whole CD. And the /noeas switch won't write any extended attributes to any of the files. The extended attributes that are written are: CDARTIST, CDTITLE, TRACKNUMBER, TRACKTITLE, CATEGORY and TITLE. In addition, the track number and title are written to the .LONGNAME extended attribute of the mp3 file, and the WAV files on the Tonigy drive.

Playing the files

Now that you've got your CD collection encoded, you need some way to play them. My favorite mp3 player is Z! available at dink.org (http://dink.org) for free, so download it and install it. But I wanted a better way of managing playlists. Rexx comes to the rescue again, along with two more free software packages.

First, you'll need WPS-Wizard from Chris Wohlgemuth, the person who wrote Audio CD Creator, and available from www.os2world.com (http://www.os2world.com/cdwriting) where you can also get Audio CD Creator. WPS-Wizard allows you to easily add workplace shell extensions of your own. When you install it, you get a WPS-Wizard folder that includes a configuration object and a folder of templates, among other things. The default configuration works just fine for me. Open the folder of templates and tear off a "Menu Folder" and place it in the WPS-Wizard folder. Its settings notebook will open up to a page where you need to drop the object you want to modify, in this case we want to modify the "Create Audio-CD" object.

Open the "CD-Writing Utilities" folder and tear off a "Create Audio-CD" folder. Drop it in the "CD-Writing Utilities" folder, and then pick it up again and drag it to the settings notebook of the WPS-Wizard "Menu Folder" that you just created. Close the settings notebook and the "Menu Folder" should now be changed to "Context menu for Audio-CD-Creator (CWAudioFolder)."

Download playshadows.zip (http://www.users.qwest.net/~scorey1/) from my web site. Unzip the playshadows.cmd file from the archive and copy it somewhere in your PATH. Then you need to edit it to tell it where you have placed Z! The eleventh line of playshadows.cmd contains the line "mp3player='d:\apps\z\z.exe -p' " Change that line to wherever you have placed z.exe but be sure you keep the -p on the end, which tells Z! to use a playlist. Now you need to create a program object in the WPS-Wizard Context menu for Audio-CD-Creator folder for the rexx program that will play the files.

Open your OS/2 templates folder and drag a program object to the "Context menu for Audio-CD-Creator (CWAudioFolder)" folder. The new program object's properties notebook should open automatically. Fill in the "Path and Filename" field with the location of playshadows.cmd. On my system it's "D:\apps\misc\playshadows.cmd." Fill in the "Parameters" field with "%*" and then switch to the "Icon" tab of the notebook. Fill in the "Title" field with whatever you want the context menu of the Audio-CD-Creator to say. I chose "~Play MP3s." The "~" character turns the letter after it into the keyboard shortcut for the context menu.

There's one more thing you need to get before playshadows.cmd will work. Download WPTOOLS (http://members.brabant.chello.nl/~henk.kelder/henk/index.html#WPTOOLS). This package is incredibly useful for maintaining your INI files, and deserves an article all its own. But for right now, all we need is the file wptools.dll which you need to place somewhere in your LIBPATH.

Now all you need to do is to use the workplace shell to drag some mp3 files to an Audio-CD-Creator folder, which will create shadows of the files you are dragging in that folder. When you drop the files, the cumulative playing time of the mp3 files in the folder will be displayed, which is useful when you want to record the songs to a cassette or Mini Disc and you need to know how much time is being taken up by the songs. Bring up the context menu of the folder, and choose "Play MP3s" or just press the letter "p" on your keyboard (if you named your WPS-Wizard program object "~Play MP3s") and Z! should start playing the songs.

Conclusion

I haven't done extensive testing of these rexx programs. All I can say is that they work for me. However, I will be happy to help anyone to get them to work. I would also appreciate any other comments or suggestions or improvements to the programs. Just let me know what you need, or what you are doing with them.

I'd like to thank the authors of all the software mentioned in this article, and also Bill Schindler for writing the book Down to Earth REXX which helped me tremendously with writing these programs.


My web site with Tonigy Utility: http://www.users.qwest.net/~scorey1/ (http://www.users.qwest.net/~scorey1/)
Tonigy: http://www.defgroup.com/tonigy/index.html (http://www.defgroup.com/tonigy/index.html)
Audio CD Creator and WPS-Wizard: http://www.os2world.com/cdwriting/ (http://www.os2world.com/cdwriting/)
Lame: http://users.ox.ac.uk/~magd1113/mpeg (http://users.ox.ac.uk/~magd1113/mpeg)
Z!: http://dink.org (http://dink.org)
WPTOOLS: http://members.brabant.chello.nl/~henk.kelder/henk/index.html#WPTOOLS (http://members.brabant.chello.nl/~henk.kelder/henk/index.html#WPTOOLS)
freedb.org Online CD Database: http://www.freedb.org (http://www.freedb.org)


Steve Corey (mailto:razorblade@qwest.net) is a recording engineer and drummer who lives in Salt Lake City, Utah, USA. He has been using OS/2 since version 2.1.

This article is courtesy of www.os2ezine.com. You can view it online at http://www.os2ezine.com/20010816/page_4.html.

Copyright (C) 2001. All Rights Reserved.