about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--Documentation/dtas-splitfx.pod23
-rwxr-xr-xbin/dtas-readahead2
-rwxr-xr-xbin/dtas-splitfx1
-rw-r--r--lib/dtas/source/av_ff_common.rb2
-rw-r--r--lib/dtas/source/sox.rb5
-rw-r--r--lib/dtas/splitfx.rb24
6 files changed, 48 insertions, 9 deletions
diff --git a/Documentation/dtas-splitfx.pod b/Documentation/dtas-splitfx.pod
index f8de59b..88179d7 100644
--- a/Documentation/dtas-splitfx.pod
+++ b/Documentation/dtas-splitfx.pod
@@ -37,6 +37,12 @@ Print, but do not run the commands to be executed
 
 Silent operation, commands are not printed as executed
 
+=item -S, --stats
+
+Add the sox "stats" effect to the end of the effects chain,
+use this with L</--err-suffix> to get a C<.stats> file with
+every track output
+
 =item -D, --no-dither
 
 Disable automatic setting of the DITHERFX env.  This also passes
@@ -46,7 +52,8 @@ the option to L<sox(1)> via SOX_OPTS.
 
 Write the contents of C<stderr>.  This is useful for capturing
 the per-track output of the L<sox(1)> C<stats> effect when
-combined with parallel C<--jobs>.
+combined with parallel C<--jobs>.  Recommended for use with the
+L</--stats> switch.
 
 =item -O, --outdir OUTDIR
 
@@ -166,6 +173,20 @@ any tracks written to the filesystem, including those using the L</--filter>
 switch.   These environment variables are intended to affect the specified
 L</command> or default L<sox(1)> invocation.
 
+=item tshift TIME
+
+Increment subsequent time stamps for L</t>, L</skip>, and L</stop>
+directives by the specified TIME offset.  TIME can be prefixed by
+C<+=> or C<-=> to adjust the existing C<tshift> value.  Negative
+values can be specified by prefixing with C<-> for a backwards
+time shift.
+
+This directive is useful for working with multiple recordings of the
+same source and cutting a section from the middle of a recording after
+initial tracking is done.
+
+Default: 0
+
 =item skip TIME - skip a segment starting at TIME
 
 "skip" segments are
diff --git a/bin/dtas-readahead b/bin/dtas-readahead
index f2ab514..c61d317 100755
--- a/bin/dtas-readahead
+++ b/bin/dtas-readahead
@@ -25,7 +25,7 @@ w.req_ok('watch')
 c = DTAS::UNIXClient.new
 @max_ra = 30 * 1024 * 1024
 null = DTAS.null
-@redir = { err: null, out: null, in: null }.freeze
+@redir = { err: null, out: null, in: null, rlimit_cpu: [ 1, 2 ] }.freeze
 require 'pp'
 
 def seek_to_cur_pos(cur_pid, fp)
diff --git a/bin/dtas-splitfx b/bin/dtas-splitfx
index d0afc7b..17d915d 100755
--- a/bin/dtas-splitfx
+++ b/bin/dtas-splitfx
@@ -13,6 +13,7 @@ OptionParser.new('', 24, '  ') do |op|
   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('-S', '--stats', 'run stats every track') { opts[:stats] = true }
   op.on('-f', '--filter FILTER') { |val| (opts[:filter] ||= []) << val }
   op.on('-D', '--no-dither') { opts[:no_dither] = true }
   op.on('-O', '--outdir OUTDIR') { |val| opts[:outdir] = val }
diff --git a/lib/dtas/source/av_ff_common.rb b/lib/dtas/source/av_ff_common.rb
index c600c48..7f197e0 100644
--- a/lib/dtas/source/av_ff_common.rb
+++ b/lib/dtas/source/av_ff_common.rb
@@ -92,7 +92,7 @@ module DTAS::Source::AvFfCommon # :nodoc:
 
       err = "".b
       begin
-        s = qx(@env, cmd, err_str: err, no_raise: true)
+        s = qx(@env, cmd, err_str: err, no_raise: true, rlimit_cpu: [ 1, 2 ])
       rescue Errno::ENOENT # avprobe/ffprobe not installed
         return false
       end
diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb
index 6ca29bc..365c7b6 100644
--- a/lib/dtas/source/sox.rb
+++ b/lib/dtas/source/sox.rb
@@ -24,7 +24,7 @@ class DTAS::Source::Sox # :nodoc:
     return if @last_failed == infile
     @last_failed = infile
     case msg
-    when Process::Status then msg = "failed with #{msg.exitstatus}"
+    when Process::Status then msg = "failed with #{msg.inspect}"
     when 0 then msg = 'detected zero samples'
     end
     warn("soxi #{infile}: #{msg}\n")
@@ -39,7 +39,8 @@ class DTAS::Source::Sox # :nodoc:
   def mcache_lookup(infile)
     (@mcache ||= DTAS::Mcache.new).lookup(infile) do |input, dst|
       err = ''.b
-      out = qx(@env.dup, %W(soxi #{input}), err_str: err, no_raise: true)
+      out = qx(@env.dup, %W(soxi #{input}), err_str: err, no_raise: true,
+                rlimit_cpu: [ 1, 2 ])
       return soxi_failed(infile, out) if Process::Status === out
       return soxi_failed(infile, err) if err =~ /soxi FAIL formats:/
       out =~ /^Duration\s*:[^=]*= (\d+) samples /n
diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index bb31ab5..b94f54b 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -10,7 +10,8 @@ require 'tempfile'
 # Unlike the stuff for dtas-player, dtas-splitfx is fairly tied to sox
 # (but we may still pipe to ecasound or anything else)
 class DTAS::SplitFX # :nodoc:
-  CMD = 'sox "$INFILE" $COMMENTS $OUTFMT $OUTDST $TRIMFX $FX $RATEFX $DITHERFX'
+  CMD = 'sox "$INFILE" $COMMENTS $OUTFMT $OUTDST $TRIMFX $FX' \
+        ' $RATEFX $DITHERFX $STATS'
   include DTAS::Process
   attr_reader :infile, :env, :command
 
@@ -65,6 +66,7 @@ class DTAS::SplitFX # :nodoc:
   # $CHANNELS (input)
   # $BITS_PER_SAMPLE (input)
   def initialize
+    @tshift = 0
     @env = {}
     @comments = {}
     @track_start = 1
@@ -204,6 +206,7 @@ class DTAS::SplitFX # :nodoc:
     elsif outfmt.bits && outfmt.bits <= 16
       env["DITHERFX"] = "dither -s"
     end
+    env['STATS'] = 'stats' if opts[:stats]
     comments = Tempfile.new(%W(dtas-splitfx-#{t.comments["TRACKNUMBER"]} .txt))
     t.comments.each do |k,v|
       env[k] = v.to_s
@@ -288,7 +291,7 @@ class DTAS::SplitFX # :nodoc:
       start_time = argv.shift
       title = argv.shift
       t = T.new
-      t.tbeg = @t2s.call(start_time)
+      t.tbeg = @t2s.call(start_time) + @tshift
       t.comments = @comments.dup
       title.valid_encoding? or warn "#{title.inspect} encoding invalid"
       t.comments["TITLE"] = title
@@ -309,11 +312,24 @@ class DTAS::SplitFX # :nodoc:
 
       prev = @tracks.last and prev.commit(t.tbeg)
       @tracks << t
+    when 'tshift'
+      tshift = argv.shift
+      argv.empty? or raise ArgumentError, 'tshift does not take extra args'
+      if tshift.sub!(/\A-=/, '')
+        @tshift = @tshift - @t2s.call(tshift)
+      elsif tshift.sub!(/\A\+=/, '')
+        @tshift = @tshift + @t2s.call(tshift)
+      elsif tshift.sub!(/\A-/, '')
+        @tshift = -@t2s.call(tshift)
+      else
+        tshift.sub!(/\A\+/, '')
+        @tshift = @t2s.call(tshift)
+      end
     when "skip"
       stop_time = argv.shift
       argv.empty? or raise ArgumentError, "skip does not take extra args"
       s = Skip.new
-      s.tbeg = @t2s.call(stop_time)
+      s.tbeg = @t2s.call(stop_time) + @tshift
       # s.comments = {}
       # s.env = {}
       prev = @tracks.last or raise ArgumentError, "no tracks to skip"
@@ -322,7 +338,7 @@ class DTAS::SplitFX # :nodoc:
     when "stop"
       stop_time = argv.shift
       argv.empty? or raise ArgumentError, "stop does not take extra args"
-      samples = @t2s.call(stop_time)
+      samples = @t2s.call(stop_time) + @tshift
       prev = @tracks.last and prev.commit(samples)
     else
       raise ArgumentError, "unknown command: #{xs(cmd)}"