From 9c0a13e4137c00a8f70a45e1469ba3f5b8130708 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 8 Apr 2024 18:38:34 -0400 Subject: soxdial: add --left --right --stereo options. --- soxdial | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) 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 occur on the command line B 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 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 "", $_) { -- cgit v1.2.3