Last change
on this file since 2 was
1,
checked in by peter, 13 years ago
|
initial import of current flacrip files into the trunk
|
-
Property svn:executable set to
*
|
File size:
1.3 KB
|
Rev | Line | |
---|
[1] | 1 | #!/usr/bin/perl -w |
---|
| 2 | use strict; |
---|
| 3 | |
---|
| 4 | # XXX: does this every vary? |
---|
| 5 | # or is the lead-in always 88200 samples (88200 / 588 = 150)? |
---|
| 6 | use constant SECTOR_OFFSET => 150; # the lead-in, in frames |
---|
| 7 | |
---|
| 8 | # conversion factors |
---|
| 9 | use constant FRAMES_PER_SECOND => 75; |
---|
| 10 | use constant SECONDS_PER_MINUTE => 60; |
---|
| 11 | |
---|
| 12 | # see also http://flac.sourceforge.net/format.html#cuesheet_track |
---|
| 13 | # 588 samples/frame = 44100 samples/sec / 75 frames/sec |
---|
| 14 | use constant SAMPLES_PER_FRAME => 588; |
---|
| 15 | |
---|
| 16 | my @sectors; |
---|
| 17 | my $total_sectors; |
---|
| 18 | while (<>) { |
---|
| 19 | if (/INDEX 01/) { |
---|
| 20 | my ($m,$s,$f) = /INDEX 01 (\d\d):(\d\d):(\d\d)/; |
---|
| 21 | push @sectors, ($m * SECONDS_PER_MINUTE * FRAMES_PER_SECOND) + ($s * FRAMES_PER_SECOND) + $f + SECTOR_OFFSET; |
---|
| 22 | } elsif (/lead-out/) { |
---|
| 23 | my ($total_samples) = /lead-out \d+ (\d+)/; |
---|
| 24 | $total_sectors = ($total_samples / SAMPLES_PER_FRAME) + SECTOR_OFFSET; |
---|
| 25 | } |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | # this is a CD TOC suitable for submitting to MusicBrainz as a CD Stub |
---|
| 29 | # http://musicbrainz.org/doc/XML_Web_Service#Submitting_a_CDStub |
---|
| 30 | my @toc_data = ( |
---|
| 31 | 1, # first track number |
---|
| 32 | scalar(@sectors), # last track number |
---|
| 33 | $total_sectors, # last frame (sector?) |
---|
| 34 | @sectors, # start frame for each track |
---|
| 35 | ); |
---|
| 36 | |
---|
| 37 | my $url = q{http://musicbrainz.org/bare/cdlookup.html?toc=} . join('+', @toc_data); |
---|
| 38 | |
---|
| 39 | print "$url\n"; |
---|
| 40 | #print join(' ', @toc_data) . "\n"; |
---|
| 41 | #print "$_\n" foreach @toc_data; |
---|
Note: See
TracBrowser
for help on using the repository browser.