* [PATCH] splitfx: allow -p/--sox-pipe option
@ 2015-05-24 8:22 6% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-05-24 8:22 UTC (permalink / raw)
To: dtas-all; +Cc: Eric Wong
This allows splitfx YAML files to operate more seamlessly with
external commands such as play(1) especially when combined with
the -t/--trim option.
---
Documentation/dtas-splitfx.txt | 5 +++++
bin/dtas-splitfx | 9 +++++++--
lib/dtas/splitfx.rb | 19 +++++++++++++------
3 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/Documentation/dtas-splitfx.txt b/Documentation/dtas-splitfx.txt
index 2a599ea..c077137 100644
--- a/Documentation/dtas-splitfx.txt
+++ b/Documentation/dtas-splitfx.txt
@@ -59,6 +59,11 @@ to use ecasound(1), too.
of "000". For ease-of-typing, commas in this command-line
argument are automatically expanded to spaces when passed to sox.
+-p, \--sox-pipe
+: Used in place of an output target to specify outputting audio data in
+ the native "sox" format to another sox(1) or play(1) command. This
+ moves printing of output to stderr and disables parallel job invocation.
+
# FILE FORMAT
* infile - string, the pathname of the original audio file
diff --git a/bin/dtas-splitfx b/bin/dtas-splitfx
index d363ab9..fc8cc69 100755
--- a/bin/dtas-splitfx
+++ b/bin/dtas-splitfx
@@ -6,8 +6,8 @@ require 'optparse'
require 'dtas/splitfx'
usage = "#$0 [-n|--dry-run][-j [JOBS]][-s|--silent] SPLITFX_FILE.yml [TARGET]"
overrides = {} # FIXME: not tested
+default_target = "flac"
opts = { jobs: 1 }
-jobs = 1
OptionParser.new('', 24, ' ') do |op|
op.banner = usage
op.on('-n', '--dry-run') { opts[:dryrun] = true }
@@ -19,6 +19,10 @@ OptionParser.new('', 24, ' ') do |op|
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.on('-p', '--sox-pipe') do
+ opts[:sox_pipe] = true
+ default_target = 'sox'
+ end
op.parse!(ARGV)
end
@@ -39,8 +43,9 @@ ARGV.each do |arg|
end
end
+trap(:INT) { exit 130 }
file = args.shift or abort usage
-target = args.shift || "flac"
+target = args.shift || default_target
splitfx = DTAS::SplitFX.new
splitfx.import(YAML.load(File.read(file)), overrides)
splitfx.run(target, opts)
diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index adc6c77..97e6153 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -10,8 +10,7 @@ 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 "$OUTDIR$TRACKNUMBER.$SUFFIX" '\
- '$TRIMFX $FX $RATEFX $DITHERFX'
+ CMD = 'sox "$INFILE" $COMMENTS $OUTFMT $OUTDST $TRIMFX $FX $RATEFX $DITHERFX'
include DTAS::Process
include DTAS::XS
attr_reader :infile, :env, :command
@@ -155,8 +154,6 @@ class DTAS::SplitFX # :nodoc:
def generic_target(target = "flac")
outfmt = @infmt.dup
outfmt.type = target
- outfmt.bits = @bits if @bits
- outfmt.rate = @rate if @rate
{ "command" => CMD, "format" => outfmt }
end
@@ -174,6 +171,9 @@ class DTAS::SplitFX # :nodoc:
outfmt.type = "flac"
end
+ outfmt.bits = @bits if @bits
+ outfmt.rate = @rate if @rate
+
# player commands will use SOXFMT by default, so we must output that
# as a self-describing format to the actual encoding instances
player_cmd = @command
@@ -211,6 +211,7 @@ class DTAS::SplitFX # :nodoc:
env["OUTFMT"] = xs(outarg)
env["SUFFIX"] = suffix
env["OUTDIR"] = @outdir ? "#@outdir/".squeeze('/') : ''
+ env["OUTDST"] = opts[:sox_pipe] ? "-p" : "$OUTDIR$TRACKNUMBER.$SUFFIX"
env.merge!(t.env)
command = target["command"]
@@ -237,7 +238,7 @@ class DTAS::SplitFX # :nodoc:
show_cmd = expand_cmd(env, command)
end
- puts(show_cmd.join(' ')) unless opts[:silent]
+ @out.puts(show_cmd.join(' ')) unless opts[:silent]
command = 'true' if opts[:dryrun] # still gotta fork
# pgroup: false so Ctrl-C on command-line will immediately stop everything
@@ -353,6 +354,12 @@ class DTAS::SplitFX # :nodoc:
tracks = @tracks.dup
pids = {}
jobs = opts[:jobs] || tracks.size # jobs == nil => everything at once
+ if opts[:sox_pipe]
+ jobs = 1
+ @out = $stderr
+ else
+ @out = $stdout
+ end
jobs.times.each do
t = tracks.shift or break
pid, tmp = splitfx_spawn(target, t, opts)
@@ -367,7 +374,7 @@ class DTAS::SplitFX # :nodoc:
pid, tmp = splitfx_spawn(target, t, opts)
pids[pid] = [ t, tmp ]
end
- puts "DONE #{done[0].inspect}" if $DEBUG
+ @out.puts "DONE #{done[0].inspect}" if $DEBUG
done[1].close!
else
fails << [ t, status ]
--
EW
^ permalink raw reply related [relevance 6%]
* [ANN] dtas 0.12.0 - duct tape audio suite for *nix
@ 2015-12-14 4:03 7% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-12-14 4:03 UTC (permalink / raw)
To: ruby-talk; +Cc: dtas-all
Free Software command-line tools for audio playback, mastering, and
whatever else related to audio. dtas follows the worse-is-better
philosophy and acts as duct tape to combine existing command-line tools
for flexibility and ease-of-development. dtas is currently implemented
in Ruby (and some embedded shell), but may use other languages in the
future.
Changes: dtas 0.12.0 - many player updates
Notable additions for dtas-player music listeners.
dtas-ctl queue cat - display the internal queue
dtas-tl shuffle [true|false] - toggle tracklist shuffle
dtas-tl edit - open tracklist in an editor
see dtas-tl(1) manpage for more details on this:
http://dtas.80x24.org/dtas-tl.txt
The player tracklist now uses sequential track IDs instead of Ruby
object IDs, so it should be easier to use existing commands such as
"dtas-tl goto" and "dtas-tl remove"
For people using dtas-player for applying real-time effects to
splitfx YAML files, dtas-player can now watch for changes in scripts
specified in the "command" field of the splitfx YAML file.
Previously, dtas-player could only read the splitfx YAML file
itself. This requires GNU/Linux and the sleepy_penguin RubyGem
installed.
dtas-splitfx also learned some switches to allow easier
interoperability with other processing tools:
-p/--sox-pipe - identical to the sox(1) option
-t/--trim - only expose part of the track, useful when
combined with the above -p switch
See http://dtas.80x24.org/dtas-splitfx.txt for more details.
There's also some work-in-progress stuff that's not well documented
at the moment. As with anything pre-1.0, expect the possibility
of incompatible changes.
Since I'm not good at designing protocols, I've also started working
on mpd compatibility layer to allow using the normal music playback
stuff with more clients (some of the clients I actually like, unlike
the seemingly GUI-only landscape of MPRIS :P).
Of course, dtas-player itself has most the capabilities of a
Unix shell; and those capabilities will certainly not be available
to mpd or MPRIS clients.
64 changes since dtas 0.11.0
INSTALL: update documentation for 0.11.0 release
splitfx: fix lossy output with player command is in use
splitfx: fix non-generic, user-specified targets
use monotonic clock on Ruby 2.1+
dtas-splitfx: no arguments for quiet and --no-dither
dtas-splitfx: support --trim argument
process: implement array expansion to preserve spaces
splitfx: show correct command for output
splitfx: remove support for encoding opus
dtas-console: bind "o" to display time in absolute seconds
splitfx: avoid double-truncation with user command
source/splitfx: allow watching extra external scripts
splitfx: drop unnecessary variable
splitfx: documentation for subclasses
splitfx: simplify output display
dtas-splitfx: comment describing -j (nothing) as infinite
dtas-*edit: fix inotify watch invocations
splitfx: allow -p/--sox-pipe option
splitfx: ensure rate is an integer
splitfx: set OUTFMT correctly for subenv if command is set
favor recv and recv_nonblock over recvmsg variants
parse_time: pass through numeric types
parse_freq: trivial new module for parsing frequencies
use a common /dev/null
player: add "queue cat" command
dtas-readahead: new script for -player users on Linux
dtas-readahead: avoid polling on pause
dtas-cueedit: escape path to temporary file
dtas-readahead: make executable
gemspec: use SPDX-compatible license
README: add link to NNTP and Atom feeds
player: cleanup command dispatch
dtas-archive: allow specifying SoX compression factor
gemspec: duplicate frozen string for older Rubygems
allow building the gem without pandoc
introduce dtas-mlib for music library functions
dtas-mlib: add dump support for debugging
tracklist: use lower number unique track IDs
tracklist: do not mutate @list when serializing
tracklist: avoid needlessly building a hash for track IDs
tracklist: shuffle support
tracklist: support limiting maximum tracklist size
player: refactor and document tracklist interface
player: tl (repeat|shuffle|max) and trim swap values
tracklist: fixup idempotent "tl shuffle false"
switch to exception-free non-blocking I/O
add .gitattributes for Ruby method detection
mlib: remove non-existent entries
mlib: add stats support
mlib: no kwargs for 1.9.3 compatibility
mlib: add find/search functionality based on mpd
mlib: split out the output format from the library
mlib: remove kwargs harder
player: reduce I/O priority of connected clients
mlib: SYSTEM_DEFAULT handlers for SIGINT and SIGPIPE
player: support "tl clear" internally
test_unixserver: remove test for element limit
player: dump state file asynchronously when requested
parse_time: enable frozen_string_literal
unix_accepted: enable checking for readability after emit
tracklist: swap functionality
player: show "tracklist" hash with summary info with "current"
dtas-tl: learn an "edit" sub command
doc: document additions to tracklist handling
* homepage: http://dtas.80x24.org/README
* http://dtas.80x24.org/INSTALL
* http://dtas.80x24.org/dtas-player.txt
* http://dtas.80x24.org/NEWS
* git clone git://80x24.org/dtas
* dtas-all@nongnu.org (plain-text only, no HTML mail, please)
* mailing list archives http://80x24.org/dtas-all/
--
EW
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-12-14 4:03 7% [ANN] dtas 0.12.0 - duct tape audio suite for *nix Eric Wong
2015-05-24 8:22 6% [PATCH] splitfx: allow -p/--sox-pipe option 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).