ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-CD/eg/playaudio
Revision: 1.3
Committed: Tue Jun 10 20:47:14 2003 UTC (21 years ago) by root
Branch: MAIN
Changes since 1.2: +2 -1 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/usr/bin/perl
2
3 # feeds all AUDIO tracks into sox. might work only
4 # on little-endian machines, so BEWARE!
5
6 $PLAY = "trap '' INT; play -traw -r44100 -c2 -sw - >/dev/null";
7
8 use Convert::CD::Track;
9 use Convert::CD::Cue;
10
11 $SIG{INT} = sub { $int++ };
12
13 print "interrupt to skip song\n";
14
15 for (@ARGV) {
16 print "reading $_\n";
17
18 my $toc = new Convert::CD::Cue path => $_;
19 my $cd = $toc->read;
20
21 open PLAY, "|-", $PLAY
22 or die "@PLAY: $!";
23
24 $| = 1;
25
26 for my $track ($cd->track) {
27 next unless $track->{mode} == MODE_AUDIO;
28 print "playing ", $track->as_string, "\n";
29
30 my $size = $track->size;
31 my $chunk = $track->{datasize};
32
33 for (my $ofs = 0; $ofs < $size && !$int; $ofs += $chunk) {
34 my $data = $track->read ($ofs, $chunk);
35 syswrite PLAY, $data;
36 printf " %5.2f %s / %s\r", 100 * $ofs / $size,
37 $track->to_msf ($ofs), $track->to_msf ($size);
38 }
39
40 $int = 0;
41 }
42 }
43
44