about summary refs log tree commit homepage
path: root/bin/dtas-splitfx
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-09-07 12:18:45 +0000
committerEric Wong <normalperson@yhbt.net>2013-09-07 12:21:07 +0000
commit8ebf63afe8c9af13868376e7618c840517618076 (patch)
treed6c6b8a73f67b1e9463c682bb53c39dfa21ff68b /bin/dtas-splitfx
parent5fe09ee3e080a2592e89d28f4157879d871485e9 (diff)
downloaddtas-8ebf63afe8c9af13868376e7618c840517618076.tar.gz
This is lacking tests and documentation, but it works from
a old trivial sample I had from a recording I previously
split using plain POSIX shell

splitfx is like make(1) for splitting and minor audio
editing.  It also allows any number of effects.
Diffstat (limited to 'bin/dtas-splitfx')
-rwxr-xr-xbin/dtas-splitfx39
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/dtas-splitfx b/bin/dtas-splitfx
new file mode 100755
index 0000000..2d66c0d
--- /dev/null
+++ b/bin/dtas-splitfx
@@ -0,0 +1,39 @@
+#!/usr/bin/env ruby
+# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
+# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
+require 'yaml'
+require 'optparse'
+require 'dtas/splitfx'
+usage = "#$0 [-n|--dry-run][-j [JOBS]] SPLITFX_FILE.yml [TARGET]"
+overrides = {} # FIXME: not tested
+dryrun = false
+jobs = 1
+op = OptionParser.new('', 24, '  ') do |opts|
+  opts.banner = usage
+  opts.on('-n', '--dry-run') { dryrun = true }
+  opts.on('-j', '--jobs [JOBS]', Integer) { |val| jobs = val }
+  opts.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
+
+file = args.shift or abort usage
+target = args.shift || "flac"
+splitfx = DTAS::SplitFX.new
+splitfx.import(YAML.load(File.read(file)), overrides)
+splitfx.run(target, jobs, dryrun)