bin/dtas-splitfx in dtas-0.11.0 vs bin/dtas-splitfx in dtas-0.12.0

- old
+ new

@@ -4,22 +4,30 @@ 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 } -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 } - op.on('-s', '--quiet', '--silent') { |val| opts[:silent] = true } - op.on('-D', '--no-dither') { |val| opts[:no_dither] = 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') { |val| opts[:rate] = 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| @@ -36,10 +44,11 @@ else args << arg end end +trap(:INT) { exit 130 } file = args.shift or abort usage -target = args.shift || "flac" +target = args.shift || default_target splitfx = DTAS::SplitFX.new splitfx.import(YAML.load(File.read(file)), overrides) splitfx.run(target, opts)