From 571d07e99bc0051ad51e1f5947a0ad28eefb557f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 30 Sep 2013 03:26:00 +0000 Subject: player: support seeking based on embedded cuesheet (FLAC) 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. --- test/test_source_sox.rb | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test/test_source_sox.rb') diff --git a/test/test_source_sox.rb b/test/test_source_sox.rb index 367f4df..36605a5 100644 --- a/test/test_source_sox.rb +++ b/test/test_source_sox.rb @@ -111,4 +111,47 @@ class TestSource < Testcase tmp.unlink end end + + def test_flac_cuesheet_cdda + return if `which metaflac`.strip.size == 0 + tmp = Tempfile.new(%W(tmp .flac)) + x(%W(sox -n -r44100 -b16 -c2 #{tmp.path} synth 5 pluck vol -1dB)) + cue = Tempfile.new(%W(tmp .cue)) + cue.puts %Q(FILE "ignored.flac" FLAC) + cue.puts " TRACK 01 AUDIO" + cue.puts " INDEX 01 00:00:00" + cue.puts " TRACK 02 AUDIO" + cue.puts " INDEX 01 00:01:40" + cue.puts " TRACK 03 AUDIO" + cue.puts " INDEX 01 00:03:00" + cue.flush + x(%W(metaflac --import-cuesheet-from=#{cue.path} #{tmp.path})) + source = DTAS::Source::Sox.new.try(tmp.path) + offsets = source.cuebreakpoints.map(&:offset) + assert_equal %w(00:00 00:01.0.533333 00:03), offsets + source.cuebreakpoints.all?(&:track?) + end + + def test_flac_cuesheet_48 + return if `which metaflac`.strip.size == 0 + ver = `flac --version`.split(/ /)[1].strip + ver.to_f >= 1.3 or return # flac 1.3.0 fixed non-44.1k rate support + + tmp = Tempfile.new(%W(tmp .flac)) + x(%W(sox -n -r48000 -c2 -b24 #{tmp.path} synth 5 pluck vol -1dB)) + cue = Tempfile.new(%W(tmp .cue)) + cue.puts %Q(FILE "ignored.flac" FLAC) + cue.puts " TRACK 01 AUDIO" + cue.puts " INDEX 01 00:00:00" + cue.puts " TRACK 02 AUDIO" + cue.puts " INDEX 01 00:01:00" + cue.puts " TRACK 03 AUDIO" + cue.puts " INDEX 01 00:03:00" + cue.flush + x(%W(metaflac --import-cuesheet-from=#{cue.path} #{tmp.path})) + source = DTAS::Source::Sox.new.try(tmp.path) + offsets = source.cuebreakpoints.map(&:offset) + assert_equal %w(0s 48000s 144000s), offsets + source.cuebreakpoints.all?(&:track?) + end end -- cgit v1.2.3-24-ge0c7