I've been using this set of scripts for just over a year now to create
audio cdroms from a batch of mp3 files. Last night I had a dream that I 
published them on sunsite and became famous. So here they are...

The scripts enclosed work together to allow a person with a cd-writer
drive to take a batch of mp3 files and burn a nice audio cd out of them,
with NO DISK SPACE REQUIRED! this is due to its use of FIFOS instead of
actual files.  the load_fifos program "loads" the fifos with copies of the
mpg123 program set to decode each mp3 into a raw output, and pipes the raw
output to the fifos.

The *script* which "does all the work" is load_fifos. load_fifos works
like this: load_fifos loops x times, where x is the number of mp3 files
you wish to burn. In each loop, the program calls another copy of mpg123
with a different mp3 filename and connects its standard output to a
different FIFO and places it in the background with the & operator.  
you're probably saying "damn! that's a lot of running mpg123 programs, can
my cpu handle this!!!?" the answer is yes. that is, as long as your cpu
can handle at least one running mpg123. because only one mpg123 runs at a
time. even if your cpu isn't fast enough to actually play mp3 files,
there's a very good chance that it is fast enough to decode the mp3s at a
speed fast enough to burn them to cdrom. 
(feedback on this subject highly appreciated)
 
run load_fifos from the commandline with the mp3 file-names as its
arguements. it accepts no special options, so you can even call it with
filenames with hyphens and such.

example:
	load_fifos ~/mp3/cd1/*3 
or
	load_fifos song1.mp3 song2.mp3 song3.mp3 song4.mp3

note:	the mp3 files will burn to cd in the exact order they are entered
	on the command-line, so dont just use load_fifos * if you are burning
	a batch of mp3s with names like 01,10,11,12,20,21... 

after the load_fifos command has been run, the next step is to run the
cdrecord program. its syntax may vary from one comptuer to the next, but
it should look something like this:
	cdrecord dev=0,0 fs=16m -v -pad -swab `fifox 4`

pay close attention to these arguements: -pad -swab `fifox 4`.
-pad, and -swab are *MANDATORY* when converting mp3's to audio-cd with
fifos.  for more information on those options, see the cdrecord manpage.  
if you fail to use the two options, your cdrom will fail as the first 
track finishes. 

as for the `fifox 4` option... this is where our fifos come in. the two
"`" characters tell linux to execute the command enclosed within them.  
thus that option actually expands to the standard output produced by the
fifox script- which is a cdrecord-specificly-formatted-output of options
that tell cdrecord which fifos to use and what order they go in.  try
running fifox <any number 1-100> and see for yourself what it does :)


here is a complete scenario that should clear up any further uncertainties...

lets say I just gathered up 72 minutes worth of mp3s that I would like to 
burn to a cdrom... they are in the directory /tmp/my-cd. there
are 12 mp3 files total. 

I will now load my fifos with the command:

	load_fifos /tmp/my-cd/*3

I obviously dont care what order the songs go in, or else i would have
painstakingly specified the name of each of the mp3 files. This command
loads all the mp3s into the fifos. (I like to use *3 because sometimes
windows saves mp3 files as upper-case and sometimes they're half and half.
there's no telling. but they always end in a 3.)


next, I will load my scsi-cdrom modules (might not apply to you)

	modprobe ide-scsi

now I burn the cdrom!!!

	cdrecord dev=0,0 fs=16m -v -pad -swab `fifox 12`


from here you should see a nice verbose output thanks to the -v option. 
the cdrom should burn successfully now.


Notes: 

(1) After the fifos are loaded, they stay loaded until somebody either
reads their contents, or kills the parent program (usually sh mpg123...).  
to unload them, i suggest using the ps command to get a listing, then kill
each one of them individually. (personally, I am the only one using my
computer, so I tend to do a kill `pidof sh` which wipes out all copies of
sh in one swipe.)

(2) If you start cdrecord with the `fifox <number>` option, be warned that
each fifo is read at this point, thus you either have to burn the cdrom,
or unload all the fifos and start the process over. I say this because
upon reading a fifo, it is bound to the program that reads it, meaning
when the reader program dies, that fifo dies too. so if you cancel a
running cdrecord process (even after 1 or 2 seconds!) you could lose
anywhere from none of the fifos to all of them. its best to unload and
start over. (when i say "lose a fifo", i mean you lose the fifo's
connection to the mp3 file. its nothing serious. you just have to reload
the fifos with load_fifos.)

(3) I run linux. These scripts were also developed under linux. however
the whole process relies upon these 3 scripts, and a directory of 100
fifos. So I imagine this package would be compatible with any standard
UNIX which supports mpg123 and has a similar version of cdrecord. 

(4) They're just scripts! therefore they are very easily modified to fit
specific needs - such as porting to other UNIces, and other programs
besides mpg123 - there is even a comment line in the load_fifos script
which shows exactly how to use the l3dec program for the same purpose.


All scripts and text files enclosed written by 
Brad Hein / Regulator Del Sol 1999-2000
