ACDIR

download

Download: acdir-0.12.zip
Version: 0.12
Updated: 2008/2/17 Sunday
Size: 372.04 KB

Powered by Drain Hole

Introduction

Audio CD Image Reader (ACDIR) is a command-line tool for converting audio CD images into another format such as WAV, MP3, MPC, Ogg Vorbis, etc. This tool can:

  • parse a cuesheet (*.cue file or the one embedded into an audio file)
  • read the audio data (supported format: Microsoft Riff WAVE, etc.)
  • decode the compressed audio data (supported format: Monkey’s Audio, FLAC, WavPack )
  • extract individual tracks to Microsoft Riff WAVE files
  • for each track, call an external encoder with a configurable command-line argument (e.g., setting output files, adding tag information, etc.)
  • send the actual PCM data to the STDIN of the external encoder
  • enumerate cuesheets recursively under a directory
  • process multiple cuesheets
  • skip encoding when the output file exists (useful for encoding newly ripped CD images)

Audio CD image and cuesheet

Exact Audio Copy creates an audio file and cuesheet if we rip a CD by selecting the menu item, "Action" - "Copy Image & Create CUE Sheet". The audio file (e.g., CDImage.wav for an uncompressed image; CDImage.ape for an image losslessly compressed by Monkey’s Audio) contains the audio data of the whole CD. The cuesheet (e.g., CDImage.cue) describes the track layout and CD-TEXT information. An audio CD image, which consists of an audio file and cuesheet, stores a nearly (i.e., excluding CD-EXTRA) perfect duplication of the original CD layout. We can reproduce the original CD by burning the cuesheet using CDRWin, Nero, burnatonce, etc. We can play an audio CD image directly with Soud Player Lilith and foobar 2000. Because an audio CD image is the perfect solution to archive audio CDs, a number of users including me store audio CD images into their hard disc or DVD-R/DVD+R.

However, an audio CD image is far from portable (ca. 300MB to 700MB for album CDs) and is not supported by any portable players. Therefore, a way to convert an audio CD image to another portable format, e.g., MP3, Ogg Vorbis, MPC is needed. A number of softwares handle audio CD images nowadays:

Consider these softwares before using ACDIR.

I once created a patch, LAME with cuesheet input, in order to encode audio CD images with LAME. The binary with this patch enabled is distributed in RareWares. However, I decided to make an external and multipurpose tool because it was hard for me to rewrite the patch for every LAME release. If you like the command-line interface or looking for the patch for the newer versions of LAME, ACDIR is probably what you want. ACDIR add a cuesheet encoding feature to not only LAME but also any command line encoders that handle PCM data input from stdin (e.g., , OggEnc, mppenc, ACMENC, etc.) without source-code modification.

Converting an audio CD image to compressed files (for beginners)

Introduction

The major reason to use ACDIR may be to convert an audio CD image to compressed audio files such as MP3 and Ogg Vorbis. This section presents a quick usage of ACDIR with LAME (lame.exe), Ogg Vorbis (oggenc.exe), MusePack (mppenc.exe), and ACMENC (acmenc.exe) with batch files.

Installation

Place acdir.exe, DLL files (*.dll), batch files (*.bat) included in the ACDIR distribution to a directory in the PATH environment. Also place the external encoders in a directory in the PATH environment. For example, I install all kinds of command-line encoders to "C:\hogehoge\music\tools" and type the following line to register the directory to PATH environment:

set PATH=C:\hogehoge\music\tools;%PATH%

Use with lame.exe

Just use lamecs.bat and specify a cuesheet:

C:\>lamecs CDImage.cue
Audio CD Image Reader (ACDIR) 0.10 alpha  Copyright (c) 2003-2005 by Nyaochi

lame --tt "Jacqueline" --ta "Franz Ferdinand" --tl "Franz Ferdinand" --tn "01"

- "01 - Jacqueline - Franz Ferdinand.mp3"
LAME version 3.97 (alpha 10, Mar 21 2005 09:50:39) (http://www.mp3dev.org/)
warning: alpha versions should be used for testing only
CPU features: MMX (ASM used), SSE (ASM used), SSE2
Using polyphase lowpass filter, transition band: 16538 Hz - 17071 Hz
Encoding <stdin> to 01 - Jacqueline - Franz Ferdinand.mp3
Encoding as 44.1 kHz 128 kbps j-stereo MPEG-1 Layer III (11x) qval=3

lame --tt "Tell Her Tonight" --ta "Franz Ferdinand" --tl "Franz Ferdinand" --tn


"02"  - "02 - Tell Her Tonight - Franz Ferdinand.mp3"
LAME version 3.97 (alpha 10, Mar 21 2005 09:50:39) (http://www.mp3dev.org/)
warning: alpha versions should be used for testing only
CPU features: MMX (ASM used), SSE (ASM used), SSE2
Using polyphase lowpass filter, transition band: 16538 Hz - 17071 Hz
Encoding <stdin> to 02 - Tell Her Tonight - Franz Ferdinand.mp3
Encoding as 44.1 kHz 128 kbps j-stereo MPEG-1 Layer III (11x) qval=3

lame --tt "Take Me Out" --ta "Franz Ferdinand" --tl "Franz Ferdinand" --tn "03"

 - "03 - Take Me Out - Franz Ferdinand.mp3"
LAME version 3.97 (alpha 10, Mar 21 2005 09:50:39) (http://www.mp3dev.org/)
warning: alpha versions should be used for testing only
CPU features: MMX (ASM used), SSE (ASM used), SSE2
Using polyphase lowpass filter, transition band: 16538 Hz - 17071 Hz
Encoding <stdin> to 03 - Take Me Out - Franz Ferdinand.mp3
Encoding as 44.1 kHz 128 kbps j-stereo MPEG-1 Layer III (11x) qval=3 

This example demonstrates encoding an audio CD image (CDImage.cue) in C:\ with LAME. You will get MP3 files named as "tracknumber - trackname - artist.mp3", e.g., "01 - Jacqueline - Franz Ferdinand.mp3", "02 - Tell Her Tonight - Franz Ferdinand.mp3", "03 - Take Me Out - Franz Ferdinand.mp3", … This naming rule is configurable by modifying the batch file. Refer to the next session as for this topic.

If you want to specify LAME options, pass them to –extra-opt option with double-quotations:

C:>lamecs --extra-opt "--preset standard" CDImage.ape
Audio CD Image Reader (ACDIR) 0.10 alpha  Copyright (c) 2003-2005 by Nyaochi

lame --tt "Jacqueline" --ta "Franz Ferdinand" --tl "Franz Ferdinand" --tn "01" -
-preset standard - "01 - Jacqueline - Franz Ferdinand.mp3"

LAME version 3.97 (alpha 10, Mar 21 2005 09:50:39) (http://www.mp3dev.org/)
warning: alpha versions should be used for testing only
CPU features: MMX (ASM used), SSE (ASM used), SSE2
Using polyphase lowpass filter, transition band: 18671 Hz - 19205 Hz
Encoding <stdin> to 01 - Jacqueline - Franz Ferdinand.mp3
Encoding as 44.1 kHz VBR(q=2) j-stereo MPEG-1 Layer III (ca. 7.3x) qval=3

Take a careful look at the input file in the above example: it specifies "CDImage.ape" instead of "CDImage.cue". You may be wondering why ACDIR knows the CD layout without the cuesheet. The answer is, of course, inside the CDImage.ape and what-is-called embedded cuesheet. CDImage.ape in this example contains CUESHEET field in the tag information and the value stores the content of the cuesheet as it is. foobar 2000 supports the playback of the embedded-cuesheet audio files.

ACDIR reads the embedded cuesheet from the CUESHEET field in Monkey’s Audio (*.ape), FLAC (*.flac), OggFLAC (*.ogg), and WavPack (*.wv) files. Note that current ACDIR does not support METADATA_BLOCK_CUESHEET, which is the native support of cuesheet in FLAC specification, because it cannot store TITLE and PERFORMER fields; and ACDIR will not support CDDB access.

Use with oggenc.exe

Similarly, use oggenccs.bat:

C:\>oggenccs --extra-opt "-q4" CDImage.cue
Audio CD Image Reader (ACDIR) 0.10 alpha  Copyright (c) 2003-2005 by Nyaochi

oggenc --title "Jacqueline" --artist "Franz Ferdinand" --album "Franz Ferdinand"

 --tracknum "01" -o "01 - Jacqueline - Franz Ferdinand.ogg" -q4 -
Opening with wav module: WAV file reader
Encoding standard input to
         "01 - Jacqueline - Franz Ferdinand.ogg"
at quality 4.00
        [ 99.8%] [ 0m00s remaining] \

Done encoding file "01 - Jacqueline - Franz Ferdinand.ogg"

        File length:  3m 49.0s
        Elapsed time: 0m 38.0s
        Rate:         6.0270
        Average bitrate: 111.5 kb/s


oggenc --title "Tell Her Tonight" --artist "Franz Ferdinand" --album "Franz Ferd
inand" --tracknum "02" -o "02 - Tell Her Tonight - Franz Ferdinand.ogg" -q4 -
Opening with wav module: WAV file reader
Encoding standard input to
         "02 - Tell Her Tonight - Franz Ferdinand.ogg"

at quality 4.00

Use with mppenc.exe

Again, similarly use mppenccs.bat:

C:\>mppenccs CDImage.cue
Audio CD Image Reader (ACDIR) 0.10 alpha  Copyright (c) 2003-2005 by Nyaochi

mppenc --title "Jacqueline" --artist "Franz Ferdinand" --album "Franz Ferdinand"

 --track "01"  - "01 - Jacqueline - Franz Ferdinand.mpp"
MPC Encoder  1.15v  --Alpha--   (C) 1999-2005 Buschmann/Klemm/Piecha/MDT

 encoding file '-'
       to file '01 - Jacqueline - Franz Ferdinand.mpp'

 SV 7.0 + XLevel coding, Profile 'Standard'

    %|avg.bitrate| speed|play time (proc/tot)| CPU time (proc/tot)| ETA
100.0  155.2 kbps  8.42x     3:49.0    3:49.0     0:27.1    0:27.1

mppenc --title "Tell Her Tonight" --artist "Franz Ferdinand" --album "Franz Ferd
inand" --track "02"  - "02 - Tell Her Tonight - Franz Ferdinand.mpp"

MPC Encoder  1.15v  --Alpha--   (C) 1999-2005 Buschmann/Klemm/Piecha/MDT

 encoding file '-'
       to file '02 - Tell Her Tonight - Franz Ferdinand.mpp'

 SV 7.0 + XLevel coding, Profile 'Standard'

    %|avg.bitrate| speed|play time (proc/tot)| CPU time (proc/tot)| ETA

Use with acmenc.exe

Just simply use acmenccs.bat:

C:>acmenccs --extra-opt "-p fiis-pro -b128" CDImage.cue
Audio CD Image Reader (ACDIR) 0.10 alpha  Copyright (c) 2003-2005 by Nyaochi

acmenc --tt "Jacqueline" --ta "Franz Ferdinand" --tl "Franz Ferdinand" --tn "01"

 -p fiis-pro -b128 - "01 - Franz Ferdinand - Jacqueline.mp3"
ACMENC version 0.6  Copyright (c) 2004 by Nyaochi  (Thu, 16 Sep 2004)
Input: - (Microsoft WAV 44.1kHz 16bit 2ch)
Output: 01 - Franz Ferdinand - Jacqueline.mp3 (MPEG1 Layer-III 44kHz 128Kbit/s 2
ch)
Fraunhofer IIS MPEG Layer-3 Codec (professional) Version 3.3.44
Copyright (C) 1996-2004 Fraunhofer IIS
|%%%%%%%%%%%%%%%%%%%%%%%%%| 100% 16.7sec at 13.7x
Writing MP3 Info frame.

acmenc --tt "Tell Her Tonight" --ta "Franz Ferdinand" --tl "Franz Ferdinand" --t
n "02" -p fiis-pro -b128 - "02 - Franz Ferdinand - Tell Her Tonight.mp3"

ACMENC version 0.6  Copyright (c) 2004 by Nyaochi  (Thu, 16 Sep 2004)
Input: - (Microsoft WAV 44.1kHz 16bit 2ch)
Output: 02 - Franz Ferdinand - Tell Her Tonight.mp3 (MPEG1 Layer-III 44kHz 128Kb
it/s 2ch)
Fraunhofer IIS MPEG Layer-3 Codec (professional) Version 3.3.44
Copyright (C) 1996-2004 Fraunhofer IIS
|%%%%%%%%%%%%%%%%%%%%%%%%%| 100% 9.95sec at 13.8x
Writing MP3 Info frame.

Use with other encoders

ACDIR can be used with all types of encoders that support audio source input from STDIN. I do want to use ACDIR with AAC encoders, but I could not find a solution because encoders such as NEncode, AACEnc, FastEnc, FAAC do not support STDIN input.

ACDIR inside: How ACDIR works with OggEnc (for advanced users)

Introduction

This section describes practical usage of ACDIR, taking an example of converting audio CD images to Ogg Vorbis files with oggenc.exe. We assume that you finished your installation as described in the previous section.

Basic usage

acdir --output "%t.ogg" --pipe "oggenc -o %~#o -t %#t -a %#a -l %#T -N %n -" CUESHEET

This command line converts an audio CD image specified by CUESHEET. ACDIR parse the cuesheet and pass tag information (e.g., track title, track artist, album name, and track number) to the oggenc command-line arguments.

Let us look into the detail of the line. –output option specifies an output filename of each track. "%t.ogg" means that an output file name will be TRACKTITLE.ogg (i.e., %t will be substituted by track title). –pipe option indicates ACDIR to create a process with stdin redirection by evaluating and executing the argument of the option. When evaluating the argument, following variable evaluations (substitutions) occur:

  • %~#o : The double-quoted output filename specified in –output option (i.e., "(TRACK-TITLE).ogg"). ‘#’ indicates the value to be double-quoted. ‘~’ replaces all characters that are invalid for a filename such as ‘/’, ‘:’, ‘*’, ‘?’, etc with white space.
  • %#t : The double-quoted track title
  • %#a : The double-quoted artist (performer)
  • %#T : The double-quoted album name
  • %n : Thetrack number

You can confirm the evaluated command-line by –echo option. The following shows the evaluated command-line strings for an album, "By the Way", by "Red Hot Chili Peppers:

C:\>acdir --output "%t.ogg" --echo "oggenc -o %#o -t %#t -a %#a -l %#T -N %n -" 

CDImage.cue
Audio CD Image Reader (ACDIR) 0.10 alpha  Copyright (c) 2003-2005 by Nyaochi

oggenc -o "By the Way.ogg" -t "By the Way" -a "Red Hot Chili Peppers" -l "By the
 Way" -N 01 -
oggenc -o "Universally Speaking.ogg" -t "Universally Speaking" -a "Red Hot Chili
 Peppers" -l "By the Way" -N 02 -
oggenc -o "This Is the Place.ogg" -t "This Is the Place" -a "Red Hot Chili Peppe
rs" -l "By the Way" -N 03 -
oggenc -o "Dosed.ogg" -t "Dosed" -a "Red Hot Chili Peppers" -l "By the Way" -N 0
4 -
oggenc -o "Don't Forget Me.ogg" -t "Don't Forget Me" -a "Red Hot Chili Peppers"

-l "By the Way" -N 05 -
oggenc -o "The Zephyr Song.ogg" -t "The Zephyr Song" -a "Red Hot Chili Peppers"
-l "By the Way" -N 06 -
oggenc -o "Can't Stop.ogg" -t "Can't Stop" -a "Red Hot Chili Peppers" -l "By the
 Way" -N 07 -
oggenc -o "I Could Die For You.ogg" -t "I Could Die For You" -a "Red Hot Chili P
eppers" -l "By the Way" -N 08 -
oggenc -o "Midnight.ogg" -t "Midnight" -a "Red Hot Chili Peppers" -l "By the Way

" -N 09 -
oggenc -o "Throw Away Your Television.ogg" -t "Throw Away Your Television" -a "R
ed Hot Chili Peppers" -l "By the Way" -N 10 -
oggenc -o "Cabron.ogg" -t "Cabron" -a "Red Hot Chili Peppers" -l "By the Way" -N
 11 -
oggenc -o "Tear.ogg" -t "Tear" -a "Red Hot Chili Peppers" -l "By the Way" -N 12
-
oggenc -o "On Mercury.ogg" -t "On Mercury" -a "Red Hot Chili Peppers" -l "By the
 Way" -N 13 -
oggenc -o "Minor Thing.ogg" -t "Minor Thing" -a "Red Hot Chili Peppers" -l "By t
he Way" -N 14 -
oggenc -o "Warm Tape.ogg" -t "Warm Tape" -a "Red Hot Chili Peppers" -l "By the W
ay" -N 15 -
oggenc -o "Venice Queen.ogg" -t "Venice Queen" -a "Red Hot Chili Peppers" -l "By
 the Way" -N 16 -

The batch file: oggenccs.bat

It is hard to enter such a long command line everytime we convert an audio CD image. To reduce the tedious burden, we create a batch file. Let us look at the content of oggenccs.bat described in the previous section:

@acdir --output "$n - $t - $a.ogg" --pipe "oggenc --title $#t --artist $#a --album $#T
--tracknum $#n -o $~#o $x -" %1 %2 %3 %4 %5 %6 %7 %8 %9

Because ‘%’ in a batch file has a special meaning to represent a variable, we cannot use ‘%’ and use ‘$’ instead, which is interchangeable to ‘%’ in ACDIR specification. $x is a special variable interpreted as the value of –extra-opt option. The variable $x enable us to configure the option for oggenc.exe. The following example passes the additional option "-q 6" to oggenc.exe:

oggenccs --extra-opt "-q 6" CDImage.cue

Command-line reference of ACDIR

As for the detail of command-line usage, refer to the help:

acdir --help
acdir --help-commands
acdir --help-options
acdir --help-variables
acdir -h <command-name>

An advanced example: my personal music collection

This section introduces the way of managing CD image collection, which I believe to be useful for you.

Folder structure

I create "music" folder under "My Document" folder and store "images" and "compressed" folders under the "music" folder. I rip an audio CD with EAC to store the CD image in the "images" folder. I create artist folders under the "images" folder, album folders under each artist folder, and an audio CD image under each album folder. I do not use space, Kana, and Chinese characters to prevent a trouble.

The "compressed" folder has a similar directory tree but stores compressed audio files (i.e., MP3, Ogg Vorbis, etc.). I employ a naming rule such as "01_albumname.ogg", "02_albumname.ogg", …, and "17_albumname.ogg" to order the compressed file according to the track number.

The following shows an example of the folder structure, in which you can see images and compressed folders having the same structure:

music
+---compressed
|   +---CrazyKenBand
|   |   +---777
|   |   |       01_777.ogg
|   |   |       02_777.ogg
|   |   |       ...
|   |   |
|   |   +---AmaiHibi
|   |   |       01_AmaiHibi.ogg
|   |   |       02_AmaiHibi.ogg
|   |   |
|   |   +---BossaMappilla
|   |   |       01_BossaMappilla.ogg
|   |   |       ...
|   |   |
|   |   ...
|   |
|   +---HajimeChitose
|   |   +---hainumikaze
|   |   |       01_hainumikaze.ogg
|   |   |       ...
|   |   |       
|   |   +---hajime-chitose
|   |   |       ...
|   |   ...
|   ...
|
+---images
|   +---CrazyKenBand
|   |   +---777
|   |   |       CDImage.ape
|   |   |       CDImage.ape.cue
|   |   |       
|   |   +---AmaiHibi
|   |   |       CDImage.ape
|   |   |       CDImage.ape.cue
|   |   |       
|   |   +---BossaMappilla
|   |   |       CDImage.ape
|   |   |       CDImage.ape.cue
|   |   |       
|   |   ...
|   |
|   +---HajimeChitose
|   |   +---hainumikaze
|   |   |       CDImage.cue
|   |   |       CDImage.wav
|   |   |       
|   |   +---hajime-chitose
|   |   |       CDImage.cue
|   |   |       CDImage.wav
|   |   ...
|   ...
|
\---tools
        acdir.exe
        oggenc.exe
        oggenccs.bat

Separating audio CD images and compressed audio files, this folder layout has the following merits:

  • We can listen to the audio CD images or the compressed audio files
  • It is easy to transfer the compressed audio to a portable player such as H320.
  • Comparing the "images" and "compressed" folder trees, we can know which CD image should be converted to compressed files
  • We can remove compressed files instantly even when we would like to re-encode as a concequence of the encoder’s improvement

Converting audio CD images to compressed files

Let us consider the way to generate compressed files from the audio CD images.

First, change the current directory to the "images" folder:

cd music\images

Second, enumerate all the cuesheet (*.cue) recursively under the "images" sub-folders and store the list into "list.txt":

acdir --find .\ *.cue > list.txt

This will create a file, "list.txt", that contains a list of relative paths of all the cuesheet files from the "images" folder.

At last, encode all the CD images described in the "list.txt" by using a batch file, cue2ogg.bat:

@acdir --output "..\compressed\$p$n_$d.ogg" --pipe "oggenc -o $#o -t $#t -a $#a
-l $#T -N $n $x -" %1 %2 %3 %4 %5 %6 %7 %8 %9

Note that the powerful variables that determine the output filenames. $p retrieves the relative path of the cuesheet file and therefore reproduce the folder structure to the "compressed" folder. ACDIR makes sure to create the output files by creating necessary sub-folders. At the same time, ACDIR does not call the oggenc encoder when an output file exists.

To encode all the CD images at quality=6, enter the following line:

cue2ogg --targets list.txt --extra-opt "-q6"

If you spell the words before sleeping, the compressed audio files (*.ogg) should be ready in the next moning (depending on the total amount of CD images and CPU speed). In this way, we can convert a number of audio CD images to compressed audio or re-convert the audio CD image with higher quality or latest encoders. Let us keep up with the rapid progress of audio compression!

Download

License

ACDIR is distributed under GNU General Public License (GPL).

Acknowledgement

ACDIR makes use of the following softwares/libraries:

  • Monkey’s Audio
  • Free Lossless Audio Codec (FLAC)
  • WavPack
  • libsndfile
  • utf8.c