diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-10-09 09:03:39 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-09 09:03:39 +0000 |
commit | 4f1a73ed584f0f74d6b32241f02ae871f3415f4a (patch) | |
tree | ce254160081899f9fc081ac193d85aeefe08e3de /bin/dtas-partstats | |
parent | 87b0316f2bad10ce2f8caa1a60065ab9f3592bbf (diff) | |
download | dtas-4f1a73ed584f0f74d6b32241f02ae871f3415f4a.tar.gz |
dtas-partstats divides large audio files into small partitions (10 seconds by default) and runs the "stats" effect of sox(1) against each partition. Currently it emits space-delimited output, but configurable output options (including Sequel/SQLite) support is coming. The intended use of this tool is for quickly finding the loudest portions of a given recording without the need for a graphical viewer. This can be useful for selectively applying (and testing the results of) dynamic range compression filters. Use with sort(1) in a pipeline is recommended in this scenario (but again, Sequel support is coming).
Diffstat (limited to 'bin/dtas-partstats')
-rwxr-xr-x | bin/dtas-partstats | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/dtas-partstats b/bin/dtas-partstats new file mode 100755 index 0000000..e29ec73 --- /dev/null +++ b/bin/dtas-partstats @@ -0,0 +1,39 @@ +#!/usr/bin/env ruby +# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# TODO +# - option parsing: sox effects, stats effect options +# - support piping out to external processes +# - configurable output formatting +# - Sequel/SQLite support +require 'dtas/partstats' +infile = ARGV[0] or abort "usage: #$0 INFILE" +ps = DTAS::PartStats.new(infile) +opts = { + jobs: `nproc 2>/dev/null || echo 2`.to_i +} +stats = ps.run(opts) + +headers = ps.key_idx.to_a +headers = headers.sort_by! { |(n,i)| i }.map! { |(n,_)| n } +width = ps.key_width +print " time " +puts(headers.map do |h| + cols = width[h] + sprintf("% #{(cols * 6)+cols-1}s", h.tr(' ','_')) +end.join(" | ")) + +stats.each do |row| + trim_part = row.shift + print "#{trim_part.hhmmss} " + puts(row.map do |group| + group.map do |f| + case f + when Float + sprintf("% 6.2f", f) + else + sprintf("% 6s", f) + end + end.join(" ") + end.join(" | ")) +end |