#!/usr/local/bin/perl
#


## fork off an autolyre process with a waveform, spectrogram, and lola file. ##

if(($auto_lyre_pid = fork) == 0) {
  exec("auto_lyre",
	"-xrm", "auto_lyre*waveform*horizscaleon:TRUE",
	"-xrm", "auto_lyre*tdat*horizscaleon:FALSE",
	"-xrm", "auto_lyre*lola*horizscaleon:FALSE",
	"-xrm", "auto_lyre*secsppix:.0025",
        "-xrm", $exp,
        "-xrm", $poscolors,
        "-xrm", "auto_lyre*tdat*exp:3",
        "-xrm", "auto_lyre*tdat*poscolors:150",
        "-geometry", "1000x490+0+0",
        "-basename", "foo",
        "-config", "W100.wav,S150.dft,L80.lola");
}


##  None of the foo.* files exist yet but autolyre will be looking for stuff there.
##  Now we move the appropriate files into the foo.* files.

open(FILE,"ls *.wav |");

while($file=<FILE>) {
  chop($file);

  # extract the base name
  ($base,$ext) = split(/\./,$file);


  system("cp $base.wav foo.wav");
  if (-e "$base.dft") { 
    system("cp $base.dft foo.dft"); 
  } else { 
    system("cp SIL.dft foo.dft");
  }
  if (-e "$base.lola") {
    system("cp $base.lola foo.lola");
  } else {
    system("cp SIL.lola foo.lola");
  }

  print <<EOF;
Do you want to see another?(y/n)

EOF

  $answer=<STDIN>;
  chop($answer);
  if ($answer eq "n") { last; }

  system("/bin/rm foo.*");
}


kill(2,$auto_lyre_pid);
system("/bin/rm foo.*");



