everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
* [PATCH 0/4] a pile of misc improvements
@ 2022-01-07  5:35 Eric Wong
  2022-01-07  5:35 ` [PATCH 1/4] archive: support comments, default to none Eric Wong
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Eric Wong @ 2022-01-07  5:35 UTC (permalink / raw)
  To: dtas-all

I should send these out before I accidentally nuke my root FS
on accident, again :x

Eric Wong (4):
  archive: support comments, default to none
  splitfx: use Etc.nprocessors for jobs if unspecified
  dtas-console: set X11 terminal title iff DISPLAY is set
  dtas-console: add 'i' toggle to show comments (metadata)

 bin/dtas-archive |  8 ++++++--
 bin/dtas-console | 32 +++++++++++++++++++++++++++++++-
 bin/dtas-splitfx |  7 ++++++-
 3 files changed, 43 insertions(+), 4 deletions(-)


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

* [PATCH 1/4] archive: support comments, default to none
  2022-01-07  5:35 [PATCH 0/4] a pile of misc improvements Eric Wong
@ 2022-01-07  5:35 ` Eric Wong
  2022-01-07  5:35 ` [PATCH 2/4] splitfx: use Etc.nprocessors for jobs if unspecified Eric Wong
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Eric Wong @ 2022-01-07  5:35 UTC (permalink / raw)
  To: dtas-all

The default "Processed by SoX" comment is pointless, and I often
want to archive + tag something in one step to reduce FS I/O.
---
 bin/dtas-archive | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bin/dtas-archive b/bin/dtas-archive
index dd3b537..c88873e 100755
--- a/bin/dtas-archive
+++ b/bin/dtas-archive
@@ -29,6 +29,7 @@
 stats = false
 keep_going = false
 compression = []
+comment = []
 
 OptionParser.new('', 24, '  ') do |op|
   op.banner = usage
@@ -36,6 +37,7 @@
   op.on('-C', '--compression [FACTOR]', 'compression factor for sox') { |c|
     compression = [ '-C', c ]
   }
+  op.on('--comment=TEXT', String) { |c| comment.push('--comment', c) }
   op.on('-j', '--jobs [JOBS]', Integer) { |j| jobs = j }
   op.on('-S', '--stats', 'save stats on the file') { stats = true }
   op.on('-k', '--keep-going', 'continue after error') { keep_going = true }
@@ -53,6 +55,8 @@
   op.parse!(ARGV)
 end
 
+comment.push('--comment', '') if comment.empty?
+
 dst = ARGV.pop
 src = ARGV.dup
 
@@ -137,7 +141,7 @@
 
       if dry_run || !silent
         names = job.map { |x| Shellwords.escape(x) }
-        cmd = [ 'sox', *names ]
+        cmd = [ 'sox', names[0], *compression, *comment, names[1] ]
         if stats
           cmd << 'stats'
           cmd << "2>#{Shellwords.escape(stats_out)}"
@@ -151,7 +155,7 @@
         end
       end
 
-      cmd = [ 'sox', input, *compression, output ]
+      cmd = [ 'sox', input, *compression, *comment, output ]
       if stats
         cmd << 'stats'
         cmd = [ *cmd, { err: stats_out } ]


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

* [PATCH 2/4] splitfx: use Etc.nprocessors for jobs if unspecified
  2022-01-07  5:35 [PATCH 0/4] a pile of misc improvements Eric Wong
  2022-01-07  5:35 ` [PATCH 1/4] archive: support comments, default to none Eric Wong
@ 2022-01-07  5:35 ` Eric Wong
  2022-01-07  5:35 ` [PATCH 3/4] dtas-console: set X11 terminal title iff DISPLAY is set Eric Wong
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Eric Wong @ 2022-01-07  5:35 UTC (permalink / raw)
  To: dtas-all

We'll take advantage of multicore if available; because even
bums like me have SMP machines these days.
---
 bin/dtas-splitfx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bin/dtas-splitfx b/bin/dtas-splitfx
index 3ee812e..18ea0b4 100755
--- a/bin/dtas-splitfx
+++ b/bin/dtas-splitfx
@@ -8,7 +8,7 @@
 usage = "#$0 [-n|--dry-run][-j [JOBS]][-s|--silent] SPLITFX_FILE.yml [TARGET]"
 overrides = {} # FIXME: not tested
 default_target = "flac"
-opts = { jobs: 1 }
+opts = { jobs: nil }
 OptionParser.new('', 24, '  ') do |op|
   op.banner = usage
   op.on('-n', '--dry-run') { opts[:dryrun] = true }
@@ -37,6 +37,11 @@
   abort '--err-suffix and --sox-pipe are mutually exclusive'
 end
 
+if opts[:jobs].nil?
+  require 'etc'
+  opts[:jobs] = Etc.nprocessors
+end
+
 args = []
 ARGV.each do |arg|
   case arg


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

* [PATCH 3/4] dtas-console: set X11 terminal title iff DISPLAY is set
  2022-01-07  5:35 [PATCH 0/4] a pile of misc improvements Eric Wong
  2022-01-07  5:35 ` [PATCH 1/4] archive: support comments, default to none Eric Wong
  2022-01-07  5:35 ` [PATCH 2/4] splitfx: use Etc.nprocessors for jobs if unspecified Eric Wong
@ 2022-01-07  5:35 ` Eric Wong
  2022-01-08 16:59   ` James Rowe
  2022-01-07  5:35 ` [PATCH 4/4] dtas-console: add 'i' toggle to show comments (metadata) Eric Wong
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Eric Wong @ 2022-01-07  5:35 UTC (permalink / raw)
  To: dtas-all

This allows users running terminals in graphical environments to
navigate to the terminal running dtas-console more easily.
---
 bin/dtas-console | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bin/dtas-console b/bin/dtas-console
index 0c56450..6172863 100755
--- a/bin/dtas-console
+++ b/bin/dtas-console
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-# Copyright (C) 2013-2021 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
 #
@@ -26,6 +26,7 @@
 c = DTAS::UNIXClient.new
 cur = YAML.load(c.req('current'))
 readable = [ se, w, $stdin ]
+set_title = ENV['DISPLAY'] ? $stdout : nil
 
 # current rg mode
 rg_mode = DTAS::RGState::RG_MODE.keys.unshift("off")
@@ -167,6 +168,10 @@ def may_fail(c, req, events)
       # and risk mojibake...
       infile.encode(enc_locale,
                     undef: :replace, invalid: :replace, replace: '?')
+      if set_title
+        dir, base = File.split(infile)
+        set_title.syswrite("\033]0;#{base} dtas-console\07")
+      end
       Curses.setpos(lineno += 1, 0)
       Curses.clrtoeol
       Curses.addstr(infile)


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

* [PATCH 4/4] dtas-console: add 'i' toggle to show comments (metadata)
  2022-01-07  5:35 [PATCH 0/4] a pile of misc improvements Eric Wong
                   ` (2 preceding siblings ...)
  2022-01-07  5:35 ` [PATCH 3/4] dtas-console: set X11 terminal title iff DISPLAY is set Eric Wong
@ 2022-01-07  5:35 ` Eric Wong
  2022-01-07  9:34 ` [PATCH 5/4] splitfx: fix track_zpad with integer arg Eric Wong
  2022-01-07  9:35 ` [PATCH 6/4] doc: drop ordered map from examples Eric Wong
  5 siblings, 0 replies; 11+ messages in thread
From: Eric Wong @ 2022-01-07  5:35 UTC (permalink / raw)
  To: dtas-all

This can be useful in the face of non-descriptive filenames.
---
 bin/dtas-console | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/bin/dtas-console b/bin/dtas-console
index 6172863..0e762bd 100755
--- a/bin/dtas-console
+++ b/bin/dtas-console
@@ -35,6 +35,7 @@
 else
   rg_mode_i = 0
 end
+show_info = false
 
 def update_tfmt(prec, tsec)
   if tsec
@@ -208,6 +209,27 @@ def may_fail(c, req, events)
     Curses.addstr(extra.join(' '))
     pre_mute_vol = cur_vol if cur_vol != 0
 
+    if show_info && current && comments = current['comments']
+      Curses.setpos(lineno += 1, 0)
+      Curses.clrtoeol
+      Curses.addstr('comments:')
+      comments.each do |k,v|
+        v = v.split(/\n+/)
+        k = k.dump if /[[:cntrl:]]/ =~ k
+        if first = v.shift
+          Curses.setpos(lineno += 1, 0)
+          Curses.clrtoeol
+          first = first.dump if /[[:cntrl:]]/ =~ first
+          Curses.addstr("  #{k}: #{first}")
+          v.each do |val|
+            val = val.dump if /[[:cntrl:]]/ =~ val
+            Curses.setpos(lineno += 1, 0)
+            Curses.clrtoeol
+            Curses.addstr("   #{val}")
+          end
+        end
+      end
+    end
     show_events(lineno, screen, events)
 
     Curses.refresh # draw and wait
@@ -277,6 +299,9 @@ def may_fail(c, req, events)
             interval = 1.0 / 10 ** prec_nr
           end
         when 27 # TODO readline/edit mode?
+        when 'i'
+          show_info = !show_info
+          Curses.clear if !show_info
         else
           Curses.setpos(screen.maxy - 1, 0)
           Curses.clrtoeol


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

* [PATCH 5/4] splitfx: fix track_zpad with integer arg
  2022-01-07  5:35 [PATCH 0/4] a pile of misc improvements Eric Wong
                   ` (3 preceding siblings ...)
  2022-01-07  5:35 ` [PATCH 4/4] dtas-console: add 'i' toggle to show comments (metadata) Eric Wong
@ 2022-01-07  9:34 ` Eric Wong
  2022-01-07  9:35 ` [PATCH 6/4] doc: drop ordered map from examples Eric Wong
  5 siblings, 0 replies; 11+ messages in thread
From: Eric Wong @ 2022-01-07  9:34 UTC (permalink / raw)
  To: dtas-all

This is a rarely-needed corner-case, but I just needed to use
this feature.
---
 lib/dtas/splitfx.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index 9e1cfd0..8454d6a 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -113,7 +113,7 @@ def import(hash, overrides = {})
     end
 
     case v = hash["track_zpad"]
-    when Integer then @track_zpad = val
+    when Integer then @track_zpad = v
     else
       _bool(hash, "track_zpad") { |val| @track_zpad = val }
     end


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

* [PATCH 6/4] doc: drop ordered map from examples
  2022-01-07  5:35 [PATCH 0/4] a pile of misc improvements Eric Wong
                   ` (4 preceding siblings ...)
  2022-01-07  9:34 ` [PATCH 5/4] splitfx: fix track_zpad with integer arg Eric Wong
@ 2022-01-07  9:35 ` Eric Wong
  5 siblings, 0 replies; 11+ messages in thread
From: Eric Wong @ 2022-01-07  9:35 UTC (permalink / raw)
  To: dtas-all

"omap" is specific to Ruby and makes interopability with other
languages more difficult.

While it's true environment variables are stored as an ordered
array of C strings (see environ(7)); order doesn't matter in
practice.  Everyone in the real world treats the environment as
an unordered key-value store, and we shall follow.
---
 Documentation/dtas-splitfx.pod | 4 ++--
 examples/splitfx.sample.yml    | 2 +-
 examples/tfx.sample.yml        | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/dtas-splitfx.pod b/Documentation/dtas-splitfx.pod
index f10c6a3..717cfa6 100644
--- a/Documentation/dtas-splitfx.pod
+++ b/Documentation/dtas-splitfx.pod
@@ -90,9 +90,9 @@ moves printing of output to stderr and disables parallel job invocation.
 
 =item infile - string, the pathname of the original audio file
 
-=item env - ordered hash of environment variables to set for all commands
+=item env - hash of environment variables to set for all commands
 
-    env: !omap
+    env:
       FX: gain 3 stats
 
 =item comments - hash of common tags for all audio (e.g. ARTIST, ALBUM, YEAR)
diff --git a/examples/splitfx.sample.yml b/examples/splitfx.sample.yml
index 9c29df2..979ba0d 100644
--- a/examples/splitfx.sample.yml
+++ b/examples/splitfx.sample.yml
@@ -11,7 +11,7 @@ comments:
 # the sox command for dtas-player playback, there is no need to
 # specify this as it is the default:
 # command: exec sox "$INFILE" $SOXFMT - $TRIMFX $RGFX $FX
-env: !omap
+env:
   PATH: $PATH
   # these effects may be used in any command in this file, including targets
   SOX_OPTS: $SOX_OPTS -R
diff --git a/examples/tfx.sample.yml b/examples/tfx.sample.yml
index b8add0b..144129f 100644
--- a/examples/tfx.sample.yml
+++ b/examples/tfx.sample.yml
@@ -4,7 +4,7 @@
 # test_trimfx.rb relies on this.
 ---
 infile: foo.flac
-env: !omap
+env:
   PATH: $PATH
   SOX_OPTS: $SOX_OPTS -R
   I2: second.flac


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

* Re: [PATCH 3/4] dtas-console: set X11 terminal title iff DISPLAY is set
  2022-01-07  5:35 ` [PATCH 3/4] dtas-console: set X11 terminal title iff DISPLAY is set Eric Wong
@ 2022-01-08 16:59   ` James Rowe
  2022-01-11 17:29     ` Eric Wong
  0 siblings, 1 reply; 11+ messages in thread
From: James Rowe @ 2022-01-08 16:59 UTC (permalink / raw)
  To: dtas-all

[-- Attachment #1: Type: text/plain, Size: 264 bytes --]

* Eric Wong (e@80x24.org) wrote:
> +set_title = ENV['DISPLAY'] ? $stdout : nil

  Perhaps consider testing for $WAYLAND_DISPLAY too?

  Use case: If, like me, you're running a wayland compositor without Xwayland
support then $DISPLAY won't be set.

Thanks,

James

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 3/4] dtas-console: set X11 terminal title iff DISPLAY is set
  2022-01-08 16:59   ` James Rowe
@ 2022-01-11 17:29     ` Eric Wong
  2022-01-11 18:14       ` James Rowe
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Wong @ 2022-01-11 17:29 UTC (permalink / raw)
  To: James Rowe; +Cc: dtas-all

James Rowe <jnrowe@gmail.com> wrote:
> * Eric Wong (e@80x24.org) wrote:
> > +set_title = ENV['DISPLAY'] ? $stdout : nil
> 
>   Perhaps consider testing for $WAYLAND_DISPLAY too?
> 
>   Use case: If, like me, you're running a wayland compositor without Xwayland
> support then $DISPLAY won't be set.

Does the following work for you?

[btw, please reply-to-all, since subscription is optional and it avoids
 nongnu.org being a SPOF, thanks]
-------8<------
diff --git a/bin/dtas-console b/bin/dtas-console
index 0e762bd..7a7ed6c 100755
--- a/bin/dtas-console
+++ b/bin/dtas-console
@@ -26,7 +26,7 @@
 c = DTAS::UNIXClient.new
 cur = YAML.load(c.req('current'))
 readable = [ se, w, $stdin ]
-set_title = ENV['DISPLAY'] ? $stdout : nil
+set_title = (ENV['DISPLAY'] || ENV['WAYLAND_DISPLAY']) ? $stdout : nil
 
 # current rg mode
 rg_mode = DTAS::RGState::RG_MODE.keys.unshift("off")


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

* Re: [PATCH 3/4] dtas-console: set X11 terminal title iff DISPLAY is set
  2022-01-11 17:29     ` Eric Wong
@ 2022-01-11 18:14       ` James Rowe
  2022-01-11 18:26         ` Eric Wong
  0 siblings, 1 reply; 11+ messages in thread
From: James Rowe @ 2022-01-11 18:14 UTC (permalink / raw)
  To: Eric Wong; +Cc: dtas-all

* Eric Wong (e@80x24.org) wrote:
> James Rowe <jnrowe@gmail.com> wrote:
> > * Eric Wong (e@80x24.org) wrote:
> > > +set_title = ENV['DISPLAY'] ? $stdout : nil
> > 
> >   Perhaps consider testing for $WAYLAND_DISPLAY too?
> 
> Does the following work for you?

  Yes, thanks.

  FTR I’m running foot¹ on river², but other more common compositors like sway³
also support builds without Xwayland too.

> [btw, please reply-to-all, since subscription is optional and it avoids
>  nongnu.org being a SPOF, thanks]

  Bah, it always takes me a couple of messages to get back in the groove here.
Pinky swear I’ll set up a folder-hook before I send another mail.

Thanks,

James

¹ https://codeberg.org/dnkl/foot
² https://github.com/riverwm/river/
3 http://swaywm.org


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

* Re: [PATCH 3/4] dtas-console: set X11 terminal title iff DISPLAY is set
  2022-01-11 18:14       ` James Rowe
@ 2022-01-11 18:26         ` Eric Wong
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Wong @ 2022-01-11 18:26 UTC (permalink / raw)
  To: James Rowe; +Cc: dtas-all

James Rowe <jnrowe@gmail.com> wrote:
> * Eric Wong (e@80x24.org) wrote:
> > James Rowe <jnrowe@gmail.com> wrote:
> > > * Eric Wong (e@80x24.org) wrote:
> > > > +set_title = ENV['DISPLAY'] ? $stdout : nil
> > > 
> > >   Perhaps consider testing for $WAYLAND_DISPLAY too?
> > 
> > Does the following work for you?
> 
>   Yes, thanks.

Thanks for testing, pushed as commit 7cf055bb98a8be913ff3a2b03ef2ed2528e61db8

> > [btw, please reply-to-all, since subscription is optional and it avoids
> >  nongnu.org being a SPOF, thanks]
> 
>   Bah, it always takes me a couple of messages to get back in the groove here.
> Pinky swear I’ll set up a folder-hook before I send another mail.

No worries.  Also, Mail-Followup-To: isn't necessary for these types of lists.
(same convention for git@vger.kernel.org and various Linux kernel-related
 lists)


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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07  5:35 [PATCH 0/4] a pile of misc improvements Eric Wong
2022-01-07  5:35 ` [PATCH 1/4] archive: support comments, default to none Eric Wong
2022-01-07  5:35 ` [PATCH 2/4] splitfx: use Etc.nprocessors for jobs if unspecified Eric Wong
2022-01-07  5:35 ` [PATCH 3/4] dtas-console: set X11 terminal title iff DISPLAY is set Eric Wong
2022-01-08 16:59   ` James Rowe
2022-01-11 17:29     ` Eric Wong
2022-01-11 18:14       ` James Rowe
2022-01-11 18:26         ` Eric Wong
2022-01-07  5:35 ` [PATCH 4/4] dtas-console: add 'i' toggle to show comments (metadata) Eric Wong
2022-01-07  9:34 ` [PATCH 5/4] splitfx: fix track_zpad with integer arg Eric Wong
2022-01-07  9:35 ` [PATCH 6/4] doc: drop ordered map from examples 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).