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/cue_index.rb | |
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/cue_index.rb')
-rw-r--r-- | lib/dtas/cue_index.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/dtas/cue_index.rb b/lib/dtas/cue_index.rb new file mode 100644 index 0000000..09c3709 --- /dev/null +++ b/lib/dtas/cue_index.rb @@ -0,0 +1,39 @@ +# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +require_relative '../dtas' +class DTAS::CueIndex + attr_reader :offset + attr_reader :index + + def initialize(index, offset) + @index = index.to_i + + # must be compatible with the sox "trim" effect + @offset = offset # "#{INTEGER}s" (samples) or HH:MM:SS:FRAC + end + + def to_hash + { "index" => @index, "offset" => @offset } + end + + def offset_samples(format) + case @offset + when /\A(\d+)s\z/ + $1.to_i + else + format.hhmmss_to_samples(@offset) + end + end + + def pregap? + @index == 0 + end + + def track? + @index == 1 + end + + def subindex? + @index > 1 + end +end |