#!/usr/bin/perl # Time-stamp: <2010-08-29 12:11:38 rsmith> # # Compiles a list of wav files into flac files. # # Author: R.F. Smith # Time-stamp: <2008-07-30 23:53:00 rsmith> # # To the extent possible under law, Roland Smith has waived all copyright and # related or neighboring rights to make-flac. This work is published from the # Netherlands. See http://creativecommons.org/publicdomain/zero/1.0/ # Check for programs that this script needs. chomp($flac = `which flac 2>/dev/null`); -x $flac || die "Cannot find flac: $!\n"; #chomp($norm = `which normalize 2>/dev/null`); #-x $norm || die "Cannot find normalize: $!\n"; # Get the name of the file containing the titles. if ($ARGV[0] ne "") { $fname = $ARGV[0]; } else { $fname = "titels"; } # open the list of song titles open (TITELS, $fname) || die "cannot open $fname: $!\n"; # The titels file format is as follows: # ------------------------------------ # album title # artist # 01 title of 1st song # .. # 14 title of 14th song # .. # get the album title and performer name chomp($album = ); $album ne "" || die "cannot read album name"; chomp($artist = ); $artist ne "" || die "cannot read artist name"; # Normalize the wav files. #printf("Normalizing .wav files...\n"); #`$norm -b track*.cdda.wav`; # go over all the songs while() { chomp; ($num, $title) = split (' ', $_, 2); printf ("Encoding \"%s\" as %s\n", $title, "track".$num.".flac"); # invoke the flac encoder. do { $rc = system ($flac, "-8", "-TARTIST=".$artist, "-TALBUM=".$album, "-TTITLE=".$title, "-TTRACKNUMBER=".$num, "-o", "track".$num.".flac", "track".$num.".cdda.wav"); if ($rc != 0) {print "\nError,", $rc, "starting again";} } until $rc == 0; }