dtas.git  about / heads / tags
duct tape audio suite for *nix
blob b23dae338d560ee4ef8dbca445b7ec34d325491c 783 bytes (raw)
$ git show tfx-pu:lib/dtas/cue_index.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
# Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require_relative '../dtas'

# embedded CUE sheet representation for -player
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

git clone git://80x24.org/dtas.git
git clone https://80x24.org/dtas.git