aboutsummaryrefslogtreecommitdiff
path: root/soxdial
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-04-08 18:38:34 -0400
committerB. Watson <urchlay@slackware.uk>2024-04-08 18:38:34 -0400
commit9c0a13e4137c00a8f70a45e1469ba3f5b8130708 (patch)
tree66254405d1af34d494e801ac0cbe560ed94dfe82 /soxdial
parent8a37020fe8169d175a0e4991f8c2e26205d6e153 (diff)
downloadmisc-scripts-9c0a13e4137c00a8f70a45e1469ba3f5b8130708.tar.gz
soxdial: add --left --right --stereo options.
Diffstat (limited to 'soxdial')
-rwxr-xr-xsoxdial36
1 files changed, 35 insertions, 1 deletions
diff --git a/soxdial b/soxdial
index 0c3967e..e07b752 100755
--- a/soxdial
+++ b/soxdial
@@ -28,6 +28,9 @@ to the layout of a touchtone phone (e.g. A = 2, M = 6, etc). If the
extended touchtone digits A, B, C, and D are needed, they can be
enabled with the B<-x>, B<--extended> option (see below).
+The generated audio is monophonic, though stereo output files can be
+created with the B<-S>, B<-L>, or B<-R> options (see below).
+
=head1 OPTIONS
Note that option bundling is not supported. Use e.g. B<-v -n>, not B<-vn>. Also,
@@ -66,6 +69,22 @@ Set the bits per sample. Default is 8. The only other choice is 16.
as signed. If this option is used, it B<must> occur on the command
line B<before> any dial string.
+=item B<-S>, B<--stereo>
+
+Output stereo audio. The left and right channels will contain the same
+audio. Use this if you're importing the audio into some other piece of
+software that expects stereo input files.
+
+=item B<-L>, B<--left>
+
+Output stereo audio, with the generated tones on the left channel and silence
+on the right channel.
+
+=item B<-R>, B<--right>
+
+Output stereo audio, with the generated tones on the right channel and silence
+on the left channel.
+
=item B<-v>, B<--verbose>
Print verbose information, including the generated B<sox> command, on standard
@@ -358,7 +377,14 @@ sub make_sox_cmd {
$output =~ s,",\\",g;
$output = "\"$output\"";
}
- my $cmd = "sox -traw -b$bits $encoding -r$rate -c1 - $output ";
+ my $ch = $stereo ? "channels 2" : "";
+ my $remix = "";
+ if($left) {
+ $remix = "remix 1 1v0";
+ } elsif($right) {
+ $remix = "remix 1v0 1";
+ }
+ my $cmd = "sox -traw -b$bits $encoding -r$rate -c1 - $output $ch $remix";
my $subcmds = join(" ; ", @sox_subcmds);
return "( " . $subcmds . " ) | " . $cmd;
}
@@ -459,6 +485,14 @@ for ($argc = 0; $argc < @ARGV; $argc++) {
push @sox_subcmds, dialtone_subcmd(parse_sec($ARGV[++$argc]));
} elsif(/^--?s(?:ilence)?$/) {
push @sox_subcmds, silence_subcmd(parse_sec($ARGV[++$argc]));
+ } elsif(/^--?(?:S|stereo)$/) {
+ $stereo = 1;
+ } elsif(/^--?(?:L|left)$/) {
+ $right = 0;
+ $stereo = $left = 1;
+ } elsif(/^--?(?:R|right)$/) {
+ $left = 0;
+ $stereo = $right = 1;
} else {
warn "$SELF: start dial string '$_'\n" if $verbose;
for (split "", $_) {