From unslider@balance.wiw.org Thu May 18 23:55:57 2000 Date: Wed, 30 Jun 1999 21:37:22 -0400 (EDT) From: unslider Subject: a/b test script here is a cheesy perl script for doing a/b type testing with two mp3 files. perhaps the next mp3 study foo can use something like this. ---cut here--- #!/usr/bin/perl # Invoke two copies of mpg123 to do "A/B" type testing for encoder quality # comparisons. # # Requires mpg123 and play (part of sox) to be installed. Sound card must # support 44kHz/16bit/stereo. # # To use: run 'abtest.pl file1.mp3 file2.mp3'. To switch streams run # abtest.pl with no arguments in another xterm (or virtual console, or # run both on the same terminal like # 'abtest.pl file1.mp3 file2.mp3 & abtest.pl', etc) and enter 1 whenever you # want to switch to the first stream and 2 whenever you want to switch to the # second. Kill both processes when you're done. # # Note that because of buffering there is a delay when switching streams, # typically half a second or so. # # 6/30/99 unSlider # All rights under copyright waived. ABSOLUTELY NO WARRANTY. $file1=shift || do { while(<>) { if(/^1/) { unlink('/tmp/stream2'); } elsif(/^2/) { symlink('/dev/null','/tmp/stream2'); } else { print "Huh?\n"; } } exit; }; $file2=shift ||die "Read source for usage instructions"; open(OUT,"|play -t sw -r 44100 -c 2 -"); open(STREAM1,"mpg123 -s $file1|"); open(STREAM2,"mpg123 -s $file2|"); $curbuf=2; for(;;) { $buf[1]=""; $buf[2]=""; $buf1len=read(STREAM1,$buf[1],1024); $buf2len=0; while($buf2len<$buf1len) { $blah=""; $buf2len+=read(STREAM2,$blah,$buf1len-$buf2len); $buf[2].=$blah; } $oldbuf=$curbuf; if(-e '/tmp/stream2') { $curbuf=2; } else { $curbuf=1; } if($curbuf!=$oldbuf) { print "Switching to stream $curbuf\n"; } print OUT $buf[$curbuf]; } ---cut here--- -- unS. Below is a plot to destroy the world, cunningly disguised as an irc client. use IO::Socket;$n=shift;($r=IO::Socket::INET->new(shift.":".shift))* defined($c=fork)||die;$c&&do{for(;;){print<$r>||die}};do{print$r "USER $n . . .\nNICK $n\n";while(<>){print$r $_}}