everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
* [PATCH 0/3] a small pile of miscellany
@ 2024-04-26  7:04 Eric Wong
  2024-04-26  7:04 ` [PATCH 1/3] source/sox: use Process::Status#inspect for diagnostics Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2024-04-26  7:04 UTC (permalink / raw)
  To: dtas-all

I've been using 1 + 2 for a while, but I still intend to figure
out what soxi is hanging on sometimes...

`tshift' for splitfx has been in the back of my mind for years,
but I only just got around to it.

Eric Wong (3):
  source/sox: use Process::Status#inspect for diagnostics
  use CPU rlimit to limit soxi||ffprobe run time
  splitfx: support tshift directive

 Documentation/dtas-splitfx.pod  | 14 ++++++++++++++
 bin/dtas-readahead              |  2 +-
 lib/dtas/source/av_ff_common.rb |  2 +-
 lib/dtas/source/sox.rb          |  5 +++--
 lib/dtas/splitfx.rb             | 20 +++++++++++++++++---
 5 files changed, 36 insertions(+), 7 deletions(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] source/sox: use Process::Status#inspect for diagnostics
  2024-04-26  7:04 [PATCH 0/3] a small pile of miscellany Eric Wong
@ 2024-04-26  7:04 ` Eric Wong
  2024-04-26  7:04 ` [PATCH 2/3] use CPU rlimit to limit soxi||ffprobe run time Eric Wong
  2024-04-26  7:04 ` [PATCH 3/3] splitfx: support tshift directive Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2024-04-26  7:04 UTC (permalink / raw)
  To: dtas-all

.exitstatus alone won't tell you about the signal received.
---
 lib/dtas/source/sox.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb
index 6ca29bc..c03477e 100644
--- a/lib/dtas/source/sox.rb
+++ b/lib/dtas/source/sox.rb
@@ -24,7 +24,7 @@ def soxi_failed(infile, msg)
     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")


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] use CPU rlimit to limit soxi||ffprobe run time
  2024-04-26  7:04 [PATCH 0/3] a small pile of miscellany Eric Wong
  2024-04-26  7:04 ` [PATCH 1/3] source/sox: use Process::Status#inspect for diagnostics Eric Wong
@ 2024-04-26  7:04 ` Eric Wong
  2024-04-26  7:04 ` [PATCH 3/3] splitfx: support tshift directive Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2024-04-26  7:04 UTC (permalink / raw)
  To: dtas-all

soxi or ffprobe may infinite loop on bad files, so be sure to
let these processes timeout properly.
---
 bin/dtas-readahead              | 2 +-
 lib/dtas/source/av_ff_common.rb | 2 +-
 lib/dtas/source/sox.rb          | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

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 @@
 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/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 @@ def av_ff_ok?
 
       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 c03477e..365c7b6 100644
--- a/lib/dtas/source/sox.rb
+++ b/lib/dtas/source/sox.rb
@@ -39,7 +39,8 @@ def initialize(mcache = nil)
   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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] splitfx: support tshift directive
  2024-04-26  7:04 [PATCH 0/3] a small pile of miscellany Eric Wong
  2024-04-26  7:04 ` [PATCH 1/3] source/sox: use Process::Status#inspect for diagnostics Eric Wong
  2024-04-26  7:04 ` [PATCH 2/3] use CPU rlimit to limit soxi||ffprobe run time Eric Wong
@ 2024-04-26  7:04 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2024-04-26  7:04 UTC (permalink / raw)
  To: dtas-all

This directive is useful for cutting sections of audio out in
addition to making it easier to share track offsets between
different recordings of the same source.
---
 Documentation/dtas-splitfx.pod | 14 ++++++++++++++
 lib/dtas/splitfx.rb            | 20 +++++++++++++++++---
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/Documentation/dtas-splitfx.pod b/Documentation/dtas-splitfx.pod
index 6f8d9ed..88179d7 100644
--- a/Documentation/dtas-splitfx.pod
+++ b/Documentation/dtas-splitfx.pod
@@ -173,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/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index 1150ee0..b94f54b 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -66,6 +66,7 @@ def commit(advance_track_samples)
   # $CHANNELS (input)
   # $BITS_PER_SAMPLE (input)
   def initialize
+    @tshift = 0
     @env = {}
     @comments = {}
     @track_start = 1
@@ -290,7 +291,7 @@ def parse_track(argv)
       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
@@ -311,11 +312,24 @@ def parse_track(argv)
 
       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"
@@ -324,7 +338,7 @@ def parse_track(argv)
     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)}"


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-26  7:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-26  7:04 [PATCH 0/3] a small pile of miscellany Eric Wong
2024-04-26  7:04 ` [PATCH 1/3] source/sox: use Process::Status#inspect for diagnostics Eric Wong
2024-04-26  7:04 ` [PATCH 2/3] use CPU rlimit to limit soxi||ffprobe run time Eric Wong
2024-04-26  7:04 ` [PATCH 3/3] splitfx: support tshift directive Eric Wong

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).