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 /test/test_source_sox.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 'test/test_source_sox.rb')
-rw-r--r-- | test/test_source_sox.rb | 43 |
1 files changed, 43 insertions, 0 deletions
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 |