MP3 Audio CDs


Contents

Hardware

Software

Setup

Copying Audio CDs

Recording Audio

Copying Data CDs

Archiving Data

MP3 Audio

Observations

Useful Links




 
 

MP3 Audio Encoding

How to produce a CD with 10 to 12 hours of audio. It will not be playable in standard audio CD players, but can be played on your SPARCstation (or a PC) with xaudio. The key is to encode it into MP3 using lame or Blade Encode.

From a CD, extract the tracks. If you use the procedure from the audio copy page you can use lame but not Blade Encode. You need to convert all the CDDA files into WAV files with Sox for that. But there is an easier way that avoids the conversion, galette has a built in option, and also seems to extract faster than read_cdda:
galette -a -f WAV track.
this will extract the entire CD into WAVs like track.01.wav, track.02.wav, etc.

From your own recorded audio you will need to convert Sun audio to WAV with Sox:
sox file.au -s -w file.wav
Now you're ready to create MP3s. Sadly even the fastest available encoder for Solaris is slow. But it's all we have since all the quick algorithms are not available for Solaris. But they're getting much better. Here's a little compairison of encode times on a 3:24 WAV file.

    400MHz UltraSPARC 400MHz Wintel
  lame  2:22  2:32
  bladeenc  3:05  3:29
  8hz-mp3  6:40  6:34
  ISO encode 14:35 5:54
  MP3Compr0.9f  N/A  1:41
  xing  N/A  0:29

But what is lacking in software you can make up brute force in hardware, if you have access to a multiprocessor machine: encode the tracks in parrallel.
This script will encode all the *.wav files in a directory in parrallel up to the the number of CPUs in the machine. On a average it takes me about 3 minutes to convert an entire CD into MP3s because I have access to a 23 CPU Sun. The maximum time is just the time needed to encode the longest track. This beats the 12 to 20 minutes it takes to convert a CD on my P400 Wintel box with the quick algorithms (never mind one costs just under $1 million and the other just over $1000). Beware this could consume all the CPU cycles on the entire Sun. I also use 160kb/s instead if the default 128 on CD extrations. It builds a 25% larger file, but is closer in quality to the 176kb/s of CDDA. From non-CD sources I will use 128kb/s. The quality you use depends on two things: what you will be playing it on and your ears. If you will only play it in the SPARCs built in speaker you can use the lowest bitrate (lame -b 32) -- and make a 50 hour CD. If you want a very high quality copy use bladeenc -192. Here's reference links for quality of MP3 encoders: mp3tech, CAD, use, scheller.
#!/bin/sh
N=`/usr/sbin/psrinfo | wc -l`
#uncomment next line of you want to leave a CPU free
#[ $N -gt 1 ] && N=`expr $N - 1`
FILES=`ls -s *.wav | sort -n | awk '{print $2}'`
[ "$FILES" ] || exit
W=`echo "$FILES" | wc -l`
M=`expr $W / $N`
R=`expr $W % $N`
[ $W -lt $N ] && N=$W
I=1
START=1
while [ $I -le $N ]
do
	if [ $I -le $R ]
	then
		STOP=`expr $START + $M`
	else
		STOP=`expr $START + $M - 1`
	fi
	LIST=`echo "$FILES"|sed -n $START,${STOP}p`
	for wav in $LIST
	do
		echo "chose encoder to use below and comment out this line"
		# mp3=`echo $wav | sed 's/\.wav$//'`.mp3 # use only for lame
		# lame -S -b 160 $wav $mp3 >/dev/null 2>&1 && rm $wav
		# bladeenc -160 -DELETE -QUIT $wav >/dev/null < /dev/null
	done &
	START=`expr $STOP + 1`
	I=`expr $I + 1`
done
wait

now the directory will contain track.01.mp3, track.02.mp3, etc. You can set up a directory that has the artist, album name and rename the tracks into the actual names of the songs.

Use the data archiving procedure to copy them to a CD. Just remember if you want put the CD into a PC you need to make a hybrid Rockridge/Joliet CD else it's file names will revert to be of the 8.3 format.

To play the MP3s, it's convient to use the mxaudio GUI. To play it through to your stereo place use the RCA to 1/8" stereo jack cable. You place the RCA side into a line-in device, typically your stereo tape in (maybe labled play) jacks. Plug the other end into the SPARC line out, it has the circle with the arrow head on the inside.

To convert old Sun 8k ulaw audio files into mp3s half their original size use this:
audioconvert -i rate=8k,channels=1,encoding=ulaw,format=sun -f \
  rate=16k,channels=1,encoding=pcm,format=raw file.au | \
  lame -m m -s 16 -b 32 - file.mp3
		
If you want to decode MP3s into a format that can be placed directly onto audio CDs use this:
# first get mp3 type
INFO=`dd count=1 < file.mp3 2>/dev/null | \
 xaudio -v -output=raw:/dev/null 2>&1 | grep stream`
MODE=`echo "$INFO" | awk '{print $NF}'`
RATE=`echo "$INFO" | awk '{printf("%d\n",$(NF-2)/1000)}'`
case "$MODE" in
	*stereo* ) CHAN=2;;
	*single* ) CHAN=1;;
esac
[ "$RATE" = 44 ] && RATE=44.1
# now convert
xaudio -output=raw:- file.mp3 |  \
 if [ "$RATE" = 44.1 -a "$CHAN" = 2 ]
 then
	dd obs=2352
 else
	audioconvert -i rate=${RATE}k,channels=$CHAN,encoding=pcm,format=raw \
	   -f rate=44.1k,channels=2,encoding=pcm,format=raw | dd obs=2352
 fi | dd bs=2352 conv=sync of=file.cdda
		
Now the cdda files can be placed onto a CD as described in the copying audio CDs procdure.


previous next
Copyright © 1999 cdr @ cuzuco.com All rights reserved.