dtas.git  about / heads / tags
duct tape audio suite for *nix
blob 839d27340c99d2c596f9667bf410bbfc52457624 1778 bytes (raw)
$ git show v0.16.1:bin/dtas-splitfx	# 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
#!/usr/bin/env ruby
# Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
# frozen_string_literal: true
require 'yaml'
require 'optparse'
require 'dtas/splitfx'
usage = "#$0 [-n|--dry-run][-j [JOBS]][-s|--silent] SPLITFX_FILE.yml [TARGET]"
overrides = {} # FIXME: not tested
default_target = "flac"
opts = { jobs: 1 }
OptionParser.new('', 24, '  ') do |op|
  op.banner = usage
  op.on('-n', '--dry-run') { opts[:dryrun] = true }
  op.on('-j', '--jobs [JOBS]', Integer) { |val| opts[:jobs] = val } # nil==inf
  op.on('-s', '--quiet', '--silent') { opts[:silent] = true }
  op.on('-D', '--no-dither') { opts[:no_dither] = true }
  op.on('-O', '--outdir OUTDIR') { |val| opts[:outdir] = val }
  op.on('-C', '--compression FACTOR') { |val| opts[:compression] = val }
  op.on('-r', '--rate RATE') do |val|
    mult = val.sub!(/k\z/, '') ? 1000 : 1
    opts[:rate] = (val.to_f * mult).to_i
  end
  op.on('-b', '--bits RATE', Integer) { |val| opts[:bits] = val }
  op.on('-t', '--trim POSITION') { |val| opts[:trim] = val.tr(',', ' ') }
  op.on('-p', '--sox-pipe') do
    opts[:sox_pipe] = true
    default_target = 'sox'
  end
  op.parse!(ARGV)
end

args = []
ARGV.each do |arg|
  case arg
  when %r{\A(\w+)=(.*)\z}
    key, val = $1, $2
    # only one that makes sense is infile=another_file
    overrides[key] = YAML.load(val)
  when %r{\A(\w+)\.(\w+)=(.*)\z}
    # comments.ARTIST='blah'
    top, key, val = $1, $2, $3
    hsh = overrides[top] ||= {}
    hsh[key] = val
  else
    args << arg
  end
end

trap(:INT) { exit 130 }
file = args.shift or abort usage
target = args.shift || default_target
splitfx = DTAS::SplitFX.new
splitfx.import(YAML.load(File.read(file)), overrides)
splitfx.run(target, opts)

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