Changeset 27 in flacrip
- Timestamp:
- 10/31/14 21:32:33 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cuesheet2tocdata
r1 r27 2 2 use strict; 3 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 4 use FindBin qw{$RealBin}; 5 use lib "$RealBin/lib"; 7 6 8 # conversion factors 9 use constant FRAMES_PER_SECOND => 75; 10 use constant SECONDS_PER_MINUTE => 60; 7 use Tracks; 11 8 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; 9 my $tracks = Tracks->new; 10 $tracks->read_cue(shift || '-'); 11 print "http://musicbrainz.org/bare/cdlookup.html?toc=" . join("+", $tracks->get_musicbrainz_tocdata) . "\n";
Note: See TracChangeset
for help on using the changeset viewer.