home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / cdrdao / examples / wav2dao / wav2dao.pl
Encoding:
Perl Script  |  2000-02-04  |  2.0 KB  |  72 lines

  1. #!/usr/bin/perl
  2.  
  3. use strict 'subs';
  4. use strict 'refs';
  5.  
  6. @dev = ('--device', '/dev/pg0:0,0');
  7.  
  8. sub help {
  9.     print "Syntax: $0 [-H] [options] audiofiles\n";
  10.     print <<"EOF" ;
  11. Use cdrdao on the wav audio file arguments, making an appropriate toc file.
  12. -d cdrw    Use cdrw as the CDRW device (default: $dev[1]).
  13. -o file    Output the toc file on this file - do not use a temporary file.
  14. -p    Perform a 'print-size' cdrdao command.
  15. -i    Perform a 'toc-info' cdrdao command.
  16. -c    Perform a 'show-toc' cdrdao command.
  17. -t    Perform a 'read-test' cdrdao command.
  18. -w    Write the CD in DAO mode (default, if no other action is specified).
  19. -s    Simulate writing only ('simulate' instead of 'write' command).
  20. -j    Do not eject the CD after writing it.
  21. -n    Print the cdrdao commands, instead of executing them.
  22. EOF
  23. }
  24.  
  25. require 'getopts.pl';
  26. &Getopts('o:pictwsjnH');
  27. if ($opt_H) { &help ; exit }
  28. $dev[1] = $opt_d if $opt_d;
  29. $opt_w = 1 unless $opt_p || $opt_i || $opt_c || $opt_t || $opt_w || $opt_s || $opt_o ne "";
  30.  
  31. die "Usage: $0 [options] audiofiles" unless @ARGV;
  32.  
  33. $fname = $opt_o ne "" ? $opt_o : "/tmp/toc$$";
  34. open(F, "> $fname") || die "open($fname): $!, stopped";
  35. print F "CD_DA\n";
  36.  
  37. foreach (@ARGV) {
  38.     print F "\nTRACK AUDIO\nNO COPY\n";
  39. #    print F "NO PRE_EMPHASIS\nTWO_CHANNEL_AUDIO\n";
  40.     print F "FILE \"$_\" 0\n";
  41. #    print F "START 00:02:00\n" if $no++;
  42. }
  43. close F;
  44.  
  45. if ($opt_p) {
  46.     if ($opt_n) { print "cdrdao print-size $fname\n" }
  47.     else { system 'cdrdao', 'print-size', $fname}
  48. }
  49.  
  50. if ($opt_i) {
  51.     if ($opt_n) { print "cdrdao toc-info $fname\n" }
  52.     else { system 'cdrdao', 'toc-info', $fname}
  53. }
  54.  
  55. if ($opt_c) {
  56.     if ($opt_n) { print "cdrdao show-toc $fname\n" }
  57.     else { system 'cdrdao', 'show-toc', $fname}
  58. }
  59. if ($opt_t) {
  60.     if ($opt_n) { print "cdrdao read-test $fname\n" }
  61.     else { system 'cdrdao', 'read-test', $fname}
  62. }
  63.  
  64. if ($opt_w || $opt_s) {
  65.     unshift @dev, $opt_s ? 'simulate' : 'write';
  66.     push @dev, '--eject' unless $opt_s || $opt_j;
  67.     push @dev, $fname;
  68.     if ($opt_n) { print "cdrdao @dev\n" } else { system 'cdrdao', @dev }
  69. }
  70. unlink $fname unless $opt_o ne "";
  71. __END__
  72.