everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
* [PATCH 0/3] some splitfx-related enhancements
@ 2022-01-24 11:35 Eric Wong
  2022-01-24 11:35 ` [PATCH 1/3] splitfx: support per-track environment variables Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2022-01-24 11:35 UTC (permalink / raw)
  To: dtas-all

1 and 2 make splitfx nicer-to-use, and 3/3 makes repeated splitfx
invocations interact better with dtas-player

Eric Wong (3):
  splitfx: support per-track environment variables
  splitfx: add --filter option to limit match to comments
  player: expire sox metadata cache on file st_ctime changes

 bin/dtas-splitfx    |  1 +
 lib/dtas/mcache.rb  | 13 ++++++++++++-
 lib/dtas/splitfx.rb |  9 +++++++++
 test/test_mcache.rb | 20 +++++++++++++++-----
 4 files changed, 37 insertions(+), 6 deletions(-)


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

* [PATCH 1/3] splitfx: support per-track environment variables
  2022-01-24 11:35 [PATCH 0/3] some splitfx-related enhancements Eric Wong
@ 2022-01-24 11:35 ` Eric Wong
  2022-01-24 11:35 ` [PATCH 2/3] splitfx: add --filter option to limit match to comments Eric Wong
  2022-01-24 11:35 ` [PATCH 3/3] player: expire sox metadata cache on file st_ctime changes Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2022-01-24 11:35 UTC (permalink / raw)
  To: dtas-all

This allows setting the `FX' env on a per-track basis, since
some recordings may have massive dynamic shifts which aren't
desirable for casual listening or broadcast playback.
---
 lib/dtas/splitfx.rb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index 8454d6a..1ce2007 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -299,6 +299,7 @@ def parse_track(argv)
           t.fade_in = $1.split(/\s+/)
         when %r{\Afade_out=(.+)\z} # $1 = "t 4" or just "4"
           t.fade_out = $1.split(/\s+/)
+        when %r{\Aenv\.([^=]+)=(.+)\z} then t.env[$1] = -$2
         when %r{\A\.(\w+)=(.+)\z} then t.comments[$1] = $2
         else
           raise ArgumentError, "unrecognized arg(s): #{xs(argv)}"


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

* [PATCH 2/3] splitfx: add --filter option to limit match to comments
  2022-01-24 11:35 [PATCH 0/3] some splitfx-related enhancements Eric Wong
  2022-01-24 11:35 ` [PATCH 1/3] splitfx: support per-track environment variables Eric Wong
@ 2022-01-24 11:35 ` Eric Wong
  2022-01-24 11:35 ` [PATCH 3/3] player: expire sox metadata cache on file st_ctime changes Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2022-01-24 11:35 UTC (permalink / raw)
  To: dtas-all

This can allow filtering for tracks with a given comment
declared via the ".#{COMMENT}" mechanism or the track title.
If no prefix is given (before the '='), then all comment
values are matched.
---
 bin/dtas-splitfx    | 1 +
 lib/dtas/splitfx.rb | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/bin/dtas-splitfx b/bin/dtas-splitfx
index 6ce6521..d0afc7b 100755
--- a/bin/dtas-splitfx
+++ b/bin/dtas-splitfx
@@ -13,6 +13,7 @@
   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('-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 }
   op.on('-C', '--compression FACTOR') { |val| opts[:compression] = val }
diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index 1ce2007..696b9ce 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -360,6 +360,14 @@ def run(target, opts = {})
 
     fails = []
     tracks = @tracks.dup
+    (opts[:filter] || []).each do |re|
+      field, val = re.split(/=/, 2)
+      if val
+        tracks.delete_if { |t| (t.comments[field] || '') !~ /#{val}/ }
+      else
+        tracks.delete_if { |t| t.comments.values.grep(/#{re}/).empty? }
+      end
+    end
     pids = {}
     jobs = opts[:jobs] || tracks.size # jobs == nil => everything at once
     if opts[:sox_pipe]


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

* [PATCH 3/3] player: expire sox metadata cache on file st_ctime changes
  2022-01-24 11:35 [PATCH 0/3] some splitfx-related enhancements Eric Wong
  2022-01-24 11:35 ` [PATCH 1/3] splitfx: support per-track environment variables Eric Wong
  2022-01-24 11:35 ` [PATCH 2/3] splitfx: add --filter option to limit match to comments Eric Wong
@ 2022-01-24 11:35 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2022-01-24 11:35 UTC (permalink / raw)
  To: dtas-all

We still need the TTL to deal with fuse.sshfs and maybe other weird
FSes which don't return the st_ctime properly.
---
 lib/dtas/mcache.rb  | 13 ++++++++++++-
 test/test_mcache.rb | 20 +++++++++++++++-----
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/lib/dtas/mcache.rb b/lib/dtas/mcache.rb
index 4f1e9e8..e0a39af 100644
--- a/lib/dtas/mcache.rb
+++ b/lib/dtas/mcache.rb
@@ -13,14 +13,25 @@ def initialize(shift = 8, ttl = 60)
 
   def lookup(infile)
     bucket = infile.hash & @mask
+    st = nil
     if cur = @tbl[bucket]
       if cur[:infile] == infile && (DTAS.now - cur[:btime]) < @ttl
-        return cur
+        begin
+          st = File.stat(infile)
+          return cur if cur[:ctime] == st.ctime
+        rescue
+        end
       end
     end
     return unless block_given?
     @tbl[bucket] = begin
       cur = cur ? cur.clear : {}
+      begin
+        st ||= File.stat(infile)
+        cur[:ctime] = st.ctime
+      rescue
+        return
+      end
       if ret = yield(infile, cur)
         ret[:infile] = infile.frozen? ? infile : -(infile.dup)
         ret[:btime] = DTAS.now
diff --git a/test/test_mcache.rb b/test/test_mcache.rb
index 2bf0e98..983a69e 100644
--- a/test/test_mcache.rb
+++ b/test/test_mcache.rb
@@ -1,19 +1,29 @@
-# Copyright (C) 2016-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require './test/helper'
 require 'dtas/mcache'
+require 'tempfile'
 
 class TestMcache < Testcase
   def test_mcache
+    tmp = Tempfile.new(%W(tmp .sox))
+    fn = tmp.path
+    cmd = %W(sox -r 44100 -b 16 -c 2 -n #{fn} trim 0 1)
+    system(*cmd) or skip
     mc = DTAS::Mcache.new
     exist = nil
-    mc.lookup('hello') { |infile, hash| exist = hash }
+    mc.lookup(fn) { |infile, hash|
+      hash[:ctime] = File.stat(infile).ctime
+      exist = hash
+    }
     assert_kind_of Hash, exist
-    assert_equal 'hello', exist[:infile]
+    assert_equal fn, exist[:infile]
     assert_operator exist[:btime], :<=, DTAS.now
-    assert_same exist, mc.lookup('hello')
+    assert_same exist, mc.lookup(fn)
     assert_nil mc.lookup('HELLO')
-    assert_same exist, mc.lookup('hello'), 'no change after miss'
+    assert_same exist, mc.lookup(fn), 'no change after miss'
+  ensure
+    tmp.close!
   end
 end


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

end of thread, other threads:[~2022-01-24 11:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 11:35 [PATCH 0/3] some splitfx-related enhancements Eric Wong
2022-01-24 11:35 ` [PATCH 1/3] splitfx: support per-track environment variables Eric Wong
2022-01-24 11:35 ` [PATCH 2/3] splitfx: add --filter option to limit match to comments Eric Wong
2022-01-24 11:35 ` [PATCH 3/3] player: expire sox metadata cache on file st_ctime changes Eric Wong

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

	http://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).