everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
ab0dcd20bc9e84da5bed09103bacf48679d01b62 blob 2646 bytes (raw)

 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
 
# Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require 'yaml'
require 'dtas/splitfx'
require 'thread'
require_relative 'helper'

class TestSplitfx < Testcase
  def test_t2s
    sfx = DTAS::SplitFX.new
    sfx.instance_eval do
      @infmt = DTAS::Format.load("rate"=>44100)
    end
    assert_equal 118554000, sfx.t2s_cdda('44:48.3')
    assert_equal 118554030, sfx.t2s('44:48.3')
  end

  def test_example
    hash = YAML.load(File.read("examples/splitfx.sample.yml"))
    sfx = DTAS::SplitFX.new
    Dir.mktmpdir do |dir|
      Dir.chdir(dir) do
        guitar_pluck("foo.flac")
        sfx.import(hash, {})
        opts = { jobs: nil, silent: true }

        # ensure default FLAC target works
        WAIT_ALL_MTX.synchronize { sfx.run("flac", opts) }
        expect = %w(1.flac 2.flac foo.flac)
        assert_equal expect, Dir["*.flac"].sort

        # compare results with expected output
        res_cmd = "sox 1.flac 2.flac -ts32 -c2 -r44100 result.s32"
        res_pid = Process.spawn(res_cmd)
        exp_cmd = "sox foo.flac -ts32 -c2 -r44100 expect.s32 trim 4"
        exp_pid = Process.spawn(exp_cmd)
        _, s = Process.waitpid2(res_pid)
        assert s.success?, "#{res_cmd}: #{s.inspect}"
        _, s = Process.waitpid2(exp_pid)
        assert s.success?, "#{exp_cmd}: #{s.inspect}"
        cmp = "cmp result.s32 expect.s32"
        assert system(cmp), cmp

        # try Ogg Opus, use opusenc/opusdec for now since that's available
        # in Debian 7.0 (sox.git currently has opusfile support, but that
        # hasn't made it into Debian, yet)
        if `which opusenc 2>/dev/null`.size > 0 &&
           `which opusdec 2>/dev/null`.size > 0
          err = $stderr.dup
          begin
            $stderr.reopen("/dev/null", "a")
            WAIT_ALL_MTX.synchronize { sfx.run("opusenc", opts) }
          ensure
            $stderr.reopen(err)
          end

          # ensure opus lengths match flac ones, we decode using opusdec
          # since sox does not yet have opus support in Debian 7.0
          %w(1 2).each do |nr|
            cmd = "opusdec #{nr}.opus #{nr}.wav 2>/dev/null"
            assert system(cmd), cmd
            assert_equal `soxi -D #{nr}.flac`, `soxi -D #{nr}.wav`
          end

          # ensure 16/44.1kHz FLAC works (CDDA-like)
          File.unlink('1.flac', '2.flac')
          WAIT_ALL_MTX.synchronize { sfx.run("flac-cdda", opts) }
          %w(1 2).each do |nr|
            assert_equal `soxi -D #{nr}.flac`, `soxi -D #{nr}.wav`
          end
        end
      end
    end
  end
end
debug log:

solving ab0dcd2 ...
found ab0dcd2 in https://80x24.org/dtas.git

Code repositories for project(s) associated with this inbox:

	../../../dtas.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).