everything related to duct tape audio suite (dtas)
 help / color / mirror / Atom feed
* [PATCH] dtas-splitfx: support --trim argument
@ 2015-05-17  2:20 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-05-17  2:20 UTC (permalink / raw)
  To: dtas-all; +Cc: Eric Wong

It can often be useful to expose only part of a track for quick
inspection.  This lets us do that.
---
 Documentation/dtas-splitfx.txt | 8 ++++++++
 bin/dtas-splitfx               | 1 +
 lib/dtas/splitfx.rb            | 9 +++++++++
 3 files changed, 18 insertions(+)

diff --git a/Documentation/dtas-splitfx.txt b/Documentation/dtas-splitfx.txt
index 049371f..2a599ea 100644
--- a/Documentation/dtas-splitfx.txt
+++ b/Documentation/dtas-splitfx.txt
@@ -51,6 +51,14 @@ to use ecasound(1), too.
 -b, \--bits BITS
 :    Override the output bit depth in the specified TARGET
 
+-t, \--trim POSITION
+:    Passes a POSITION argument to the sox "trim" effect to allow
+     limiting output to only process a portion of the original.
+     This bypasses the "tracks" section and of the YAML file and
+     outputs the result as a single file with the TRACKNUMBER
+     of "000".  For ease-of-typing, commas in this command-line
+     argument are automatically expanded to spaces when passed to sox.
+
 # FILE FORMAT
 
 * infile - string, the pathname of the original audio file
diff --git a/bin/dtas-splitfx b/bin/dtas-splitfx
index a764cb3..d28cc5d 100755
--- a/bin/dtas-splitfx
+++ b/bin/dtas-splitfx
@@ -18,6 +18,7 @@ OptionParser.new('', 24, '  ') do |op|
   op.on('-C', '--compression FACTOR') { |val| opts[:compression] = val }
   op.on('-r', '--rate RATE') { |val| opts[:rate] = val }
   op.on('-b', '--bits RATE', Integer) { |val| opts[:bits] = val }
+  op.on('-t', '--trim POSITION') { |val| opts[:trim] = val.tr(',', ' ') }
   op.parse!(ARGV)
 end
 
diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index e4997cc..b657179 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -16,6 +16,14 @@ class DTAS::SplitFX # :nodoc:
   include DTAS::XS
   attr_reader :infile, :env
 
+  class UTrim
+    attr_reader :env, :comments
+    def initialize(trim_arg, env, comments)
+      @env = env.merge("TRIMFX" => "trim #{trim_arg}")
+      @comments = comments.merge('TRACKNUMBER' => '000')
+    end
+  end
+
   class Skip < Struct.new(:tbeg) # :nodoc:
     def commit(_)
       # noop
@@ -353,6 +361,7 @@ class DTAS::SplitFX # :nodoc:
     @compression = opts[:compression]
     @rate = opts[:rate]
     @bits = opts[:bits]
+    trim = opts[:trim] and @tracks = [ UTrim.new(trim, @env, @comments) ]
 
     fails = []
     tracks = @tracks.dup
-- 
EW



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-05-17  2:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-17  2:20 [PATCH] dtas-splitfx: support --trim argument Eric Wong

everything related to duct tape audio suite (dtas)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://80x24.org/dtas-all
	git clone --mirror http://ou63pmih66umazou.onion/dtas-all

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 dtas-all dtas-all/ https://80x24.org/dtas-all \
		dtas-all@nongnu.org
	public-inbox-index dtas-all

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.audio.dtas
	nntp://ou63pmih66umazou.onion/inbox.comp.audio.dtas
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	dtas.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git