about summary refs log tree commit homepage
path: root/bin/dtas-play-xover-delay
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-08-25 00:07:06 +0000
committerEric Wong <normalperson@yhbt.net>2013-08-25 00:07:06 +0000
commit6c197ba96877164d2e89ee1f1cc74d15a34af6e1 (patch)
tree414c4c6f04663b4687a2128ad98b5b39e33ebc0c /bin/dtas-play-xover-delay
parent4bb0b33402635da9702c255f11dbf3b18e4d28f0 (diff)
downloaddtas-6c197ba96877164d2e89ee1f1cc74d15a34af6e1.tar.gz
dtas-xdelay is shorter and easier-to-type.  The "play" in the name
is also not entirely accurate, as it is capable of using plain
"sox", too.
Diffstat (limited to 'bin/dtas-play-xover-delay')
-rwxr-xr-xbin/dtas-play-xover-delay85
1 files changed, 0 insertions, 85 deletions
diff --git a/bin/dtas-play-xover-delay b/bin/dtas-play-xover-delay
deleted file mode 100755
index d5b6533..0000000
--- a/bin/dtas-play-xover-delay
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/env ruby
-# -*- encoding: binary -*-
-# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net>
-# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
-USAGE = "Usage: #$0 [-x FREQ] [-l] /dev/fd/LO /dev/fd/HI DELAY [DELAY ...]"
-require 'optparse'
-dryrun = false
-xover = '80'
-delay_lo = []
-delay_hi = []
-adj_delay = delay_hi
-out_channels = out_rate = out_type = nil
-
-lowpass = 'lowpass %s lowpass %s'
-highpass = 'highpass %s highpass %s'
-
-op = OptionParser.new('', 24, '  ') do |opts|
-  opts.banner = USAGE
-  opts.on('-x', '--crossover-frequency FREQ') do |freq|
-    xover = freq
-  end
-  opts.on('-l', '--lowpass-delay') { adj_delay = delay_lo }
-  opts.on('-c', '--channels INTEGER') { |val| out_channels = val }
-  opts.on('-r', '--rate RATE') { |val| out_rate = val }
-  opts.on('-t', '--type FILE-TYPE') { |val| out_type = val }
-  opts.on('-n', '--dry-run') { dryrun = true }
-  opts.on('--lowpass FORMAT_STRING') { |s| lowpass = s }
-  opts.on('--highpass FORMAT_STRING') { |s| highpass = s }
-  opts.parse!(ARGV)
-end
-
-dev_fd_lo = ARGV.shift
-dev_fd_hi = ARGV.shift
-if ARGV.delete('-')
-  # we re-add the '-' below
-  out_channels && out_rate && out_type or
-    abort "-c, -r, and -t must all be specified for standard output"
-  cmd = "sox"
-elsif out_channels || out_rate || out_type
-  abort "standard output (`-') must be specified with -c, -r, or -t"
-else
-  cmd = "play"
-end
-soxfmt = ENV["SOXFMT"] or abort "#$0 SOXFMT undefined"
-
-# configure the sox "delay" effect
-delay = ARGV.dup
-delay[0] or abort USAGE
-channels = ENV['CHANNELS'] or abort "#$0 CHANNELS env must be set"
-channels = channels.to_i
-adj_delay.replace(delay.dup)
-until adj_delay.size == channels
-  adj_delay << delay.last
-end
-adj_delay.unshift("delay")
-
-# prepare two inputs:
-delay_lo = delay_lo.join(' ')
-delay_hi = delay_hi.join(' ')
-
-lowpass_args = []
-lowpass.gsub('%s') { |s| lowpass_args << xover; s }
-highpass_args = []
-highpass.gsub('%s') { |s| highpass_args << xover; s }
-
-lo = "|exec sox #{soxfmt} #{dev_fd_lo} -p " \
-     "#{sprintf(lowpass, *lowpass_args)} #{delay_lo}".strip
-hi = "|exec sox #{soxfmt} #{dev_fd_hi} -p " \
-     "#{sprintf(highpass, *highpass_args)} #{delay_hi}".strip
-
-args = [ "-m", "-v1", lo, "-v1", hi ]
-case cmd
-when "sox"
-  args.unshift "sox"
-  args.concat(%W(-t#{out_type} -c#{out_channels} -r#{out_rate} -))
-when "play"
-  args.unshift "play"
-else
-  abort "BUG: bad cmd=#{cmd.inspect}"
-end
-if dryrun
-  p args
-else
-  exec *args, close_others: false
-end