[paranoia-dev] Wrapper program difficulties

Scott Bronson bronson at trestle.com
Sun Oct 3 21:01:50 PDT 1999



Thanks for your reply, Monty!  With the information you provided, I was
able to get a simple progress bar working.  I've included the super ugly
(it's a one-off hack) prototype Perl script at the end of this E-mail.

> > Finally, cdparanoia outputs a huge amount of unneeded information,
> It tells you every detail of what it's doing.  ...
> In other words, I tried to plan ahead for all the reasonable uses people would 
> think of, but I didn't necessarily come to all the correct conclusions.

It turns out that as long as you keep cdparanoia's -e output away from
a terminal, it doesn't affect system performance too much.  So, I can use
-e after all.

Now that I've got the progress bar working well, it would be nice to
display a bit more comprehensive status.  For instance, I would like
the progress bar to display "jitter", "scratch", etc when cdparanoia
fixes things up.  Is there an easy way of discovering this from
the -e output?  I'm not about to scratch my CDs to experiment...  :)

        - Scott

----------------

To run this prototype: insert an audio CD into your CD-ROM drive, then
run it with no arguments.  It will run cdparanoia on track 2, encoding
it into a .wav in the /tmp directory.  While it's encoding, it will
display the percentage completed.

#!/usr/bin/perl -w

use strict;
use IO::Handle;
use Term::Cap;

ub CD_FRAMESIZE_RAW() { 2352 };

my $terminal = Term::Cap->Tgetent( {OSPEED => 9600} );
print $terminal->Tputs( 'cl' );	# clear screen

my $pid = open( PAR,
        "cdparanoia -w -e 2 /tmp/track2.wav 2>&1 |" )
        or die "Couldn't fork cdparanoia: $!\n";
STDOUT->autoflush( 1 );

my( $from_sec, $to_sec );
while( <PAR> ) {
        if( /^Ripping from sector\s+([0-9]+)\s/ ) {
                $from_sec = $1; 
                $_ = <PAR>;
                ($to_sec) = /to sector\s+([0-9]+)\s/;
                last;
        }
    # safeguard, so we don't rip entire CD before we realize
        # there was an error determining the ranges
        last if /^##/;
}

$from_sec or die "Could not determine from_sec\n";
$to_sec or die "Could not determine to_sec\n";
my $range = $to_sec - $from_sec;

print "ripping from $from_sec\n";
print "          to $to_sec\n";

my $oldpct = "";

while( <PAR> ) {
        /\[wrote\] \@ ([0-9]+)/ && do {
                my $sector = ((1+$1) / (CD_FRAMESIZE_RAW/2)) - 1;
                my $percent = sprintf( "%.1f", 100*($sector-$from_sec)/$range );
                if( $percent ne $oldpct ) {
                    print $terminal->Tgoto( 'cm', 15, 15 ), "Status: $percent%      \n";
                        $oldpct = $percent;
                }
        };
}

close( PAR ) or die "Couldn't close cdparanoia: $!\n";

--- >8 ----
List archives:  http://www.xiph.org/archives/
Paranoia homepage: http://www.xiph.org/paranoia/
To unsubscribe from this list, send mail to 'paranoia-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Paranoia-dev mailing list