diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-09-30 03:26:00 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-09-30 03:38:39 +0000 |
commit | 571d07e99bc0051ad51e1f5947a0ad28eefb557f (patch) | |
tree | 60fd5e17a10c884ded34c41e6748e493b5ed0311 /lib/dtas/source | |
parent | 1a0a4247b8031ec85536f547d2a66fa031586723 (diff) | |
download | dtas-571d07e99bc0051ad51e1f5947a0ad28eefb557f.tar.gz |
This adds the ability to seek internally within FLAC file based on the internal CUE sheet. Other formats may be supported in the future, but FLAC is the only one I know of which supports embedded cue sheets. Note: flac 1.3.0 is recommended for users of non-CDDA-compatible formats. See updates to dtas-player_protocol(7) for details.
Diffstat (limited to 'lib/dtas/source')
-rw-r--r-- | lib/dtas/source/file.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/dtas/source/file.rb b/lib/dtas/source/file.rb index 3dadc67..8657b0c 100644 --- a/lib/dtas/source/file.rb +++ b/lib/dtas/source/file.rb @@ -5,6 +5,7 @@ require_relative '../source' require_relative '../command' require_relative '../format' require_relative '../process' +require_relative '../cue_index' module DTAS::Source::File # :nodoc: attr_reader :infile @@ -33,6 +34,7 @@ module DTAS::Source::File # :nodoc: @offset = offset @comments = nil @samples = nil + @cuebp = nil @rg = nil end @@ -90,4 +92,31 @@ module DTAS::Source::File # :nodoc: defaults = source_defaults # see dtas/source/{av,sox}.rb to_source_cat.delete_if { |k,v| v == defaults[k] } end + + def cuebreakpoints + rv = @cuebp and return rv + rv = [] + begin + str = qx(@env, %W(metaflac --export-cuesheet-to=- #@infile)) + rescue + return rv + end + str.scan(/^ INDEX (\d+) (\S+)/) do |m| + index = m[0] + time = m[1].dup + case time + when /\A\d+\z/ + time << "s" # sample count (flac 1.3.0) + else # HH:MM:SS:FF + # FF/75 CDDA frames per second, convert to fractional seconds + time.sub!(/:(\d+)\z/, "") + frames = $1.to_f + if frames > 0 + time = sprintf("#{time}.%0.6g", frames / 75.0) + end + end + rv << DTAS::CueIndex.new(index, time) + end + @cuebp = rv + end end |