diff options
author | Eric Wong <e@80x24.org> | 2015-05-19 09:14:23 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-05-19 09:16:16 +0000 |
commit | c02f0b8182b35df1a318418bbd0036c00be93b5c (patch) | |
tree | cf24d9e3c47ee3e3dfbe2ae697fa92b3c9f53079 /lib/dtas/source | |
parent | 7b47191aa4c88b3daa4c980013f0047cb7ae7f6d (diff) | |
download | dtas-c02f0b8182b35df1a318418bbd0036c00be93b5c.tar.gz |
Since writing nested shell commands inside YAML is subject to all sorts of strange quoting rules, encourage users to rely on external scripts which the YAML file refers to instead. These scripts can be written in any reasonable scripting language capable of executing other commands. This allows transparently monitoring things such as `my-script.rb' in the below example when playing my-splitfx.yml via dtas-player: --------------------- my-splitfx.yml ----------------------- infile: input.flac command: $INDIR/my-script.rb "$INFILE" ... --------------------- my-script.rb -------------------------- #!/usr/bin/ruby require 'shellwords' infile = ARGV.shift ch = %W(sox #{infile} -p).concat((ENV['TRIMFX'] || '').shellsplit) fx = %W(highpass 25 gain 9) l = ch.dup.concat(%W(remix 1v1)).concat(fx).concat(%w(contrast 30)) r = ch.dup.concat(%W(remix 2v1)).concat(fx).concat(%w(contrast 0)) cmd = %W(sox -M |#{l.shelljoin} |#{r.shelljoin}) cmd.concat((ENV['SOXFMT'] || '-p').shellsplit) cmd.concat(%w(- stats)) warn cmd.inspect exec *cmd
Diffstat (limited to 'lib/dtas/source')
-rw-r--r-- | lib/dtas/source/splitfx.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/dtas/source/splitfx.rb b/lib/dtas/source/splitfx.rb index b7b9b86..02c3a9d 100644 --- a/lib/dtas/source/splitfx.rb +++ b/lib/dtas/source/splitfx.rb @@ -17,6 +17,7 @@ class DTAS::Source::SplitFX < DTAS::Source::Sox # :nodoc: def initialize(sox = DTAS::Source::Sox.new) command_init(SPLITFX_DEFAULTS) + @watch_extra = [] @sox = sox end @@ -65,6 +66,19 @@ class DTAS::Source::SplitFX < DTAS::Source::Sox # :nodoc: e = @env.merge!(player_format.to_env) @sfx.infile_env(e, @sox.infile) + # watch any scripts or files the command in the YAML file refers to + if c = @sfx.command + @sfx.expand_cmd(e, c).each do |f| + File.readable?(f) and @watch_extra << f + end + end + + # allow users to specify explicit depdendencies to watch for edit + case extra = @ymlhash['deps'] + when Array, String + @watch_extra.concat(Array(extra)) + end + # make sure these are visible to the "current" command... e["TRIMFX"] = trimfx e["RGFX"] = rg_state.effect(self) || nil |