aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-04-12 16:25:13 -0400
committerB. Watson <urchlay@slackware.uk>2024-04-12 16:25:13 -0400
commit50c4513911aa12cb21d4c49a5f9f2050595ee8f2 (patch)
tree9927668a10a940cfba1ba6f5b8362a1accd80f84
parenta731107f4a3c8dc8b544555f137017f0dcdc5a02 (diff)
downloadsoxdial-50c4513911aa12cb21d4c49a5f9f2050595ee8f2.tar.gz
soxdial: add --sox option and SOX environment variable.
-rwxr-xr-xsoxdial48
1 files changed, 41 insertions, 7 deletions
diff --git a/soxdial b/soxdial
index fae3dda..b41d47d 100755
--- a/soxdial
+++ b/soxdial
@@ -127,6 +127,16 @@ error.
Do not execute the generated B<sox> command. This option also
enables B<-v>.
+=item B<--sox> I<sox-executable>
+
+Explicitly set the location of the sox binary. Useful if it's in a
+nonstandard location. If this doesn't contain any slashes, B<PATH> is
+used to search for it. If it does contain slashes, it's used as a full
+path (e.g. B<--sox /usr/local/audiostuff/sox/bin/sox>.
+
+This option does the same thing as the B<SOX> environment variable,
+but it will override the environment.
+
=back
=head2 Dial Options
@@ -256,6 +266,24 @@ The alternate names for B<0> (B<10>), B<st3> (B<11>), and B<st2>
(B<12>) are not supported, since there's no way to tell an 11 from
two 1's.
+=head1 ENVIRONMENT
+
+=over 4
+
+=item B<PATH>
+
+By default, B<sox> is searched for in B<PATH>.
+
+=item B<SOX>
+
+Sets the path to the B<sox> executable. Same as the B<--sox> option, q.v.
+
+=item B<AUDIODRIVER>, B<AUDIODEV>, B<SOX_OPTS>, etc.
+
+These options affect B<sox>; see the B<sox>(1) man page for details.
+
+=back
+
=head1 NOTES
B<1.> B<soxdial> works by iterating over the words on the command
@@ -434,7 +462,7 @@ sub make_sox_subcmd {
return ":" unless @freqs1;
my $length = shift || $digittime;
- my $cmd = "sox -n -b$bits $encoding -r$rate -c1 -traw - --norm=-3 ";
+ my $cmd = "$SOX -n -b$bits $encoding -r$rate -c1 -traw - --norm=-3 ";
my $synth = " synth $length ";
my $delay = "delay ";
@@ -460,7 +488,7 @@ sub silence_subcmd {
return;
}
warn "$SELF: adding $s sec silence.\n" if $verbose;
- return "sox -n -b$bits $encoding -r$rate -c1 -traw - trim 0 $s";
+ return "$SOX -n -b$bits $encoding -r$rate -c1 -traw - trim 0 $s";
}
sub dialtone_subcmd {
@@ -470,7 +498,7 @@ sub dialtone_subcmd {
return;
}
warn "$SELF: adding $sec sec of dial tone, type '$dialtone_type'.\n" if $verbose;
- my $cmd = "sox -n -b$bits $encoding -r$rate -c1 -traw - synth $sec ";
+ my $cmd = "$SOX -n -b$bits $encoding -r$rate -c1 -traw - synth $sec ";
for($dialtone_type) {
/^us$/ && do { $cmd .= "sine 350 sine 440" };
/^uk$/ && do { $cmd .= "sine 350 sine 450" };
@@ -515,7 +543,7 @@ sub make_sox_cmd {
$remix = "remix 1v0 1";
}
- my $cmd = "sox -traw -b$bits $encoding -r$rate -c1 - $output $ch $remix";
+ my $cmd = "$SOX -traw -b$bits $encoding -r$rate -c1 - $output $ch $remix";
my $subcmds = join(" ; ", @sox_subcmds);
return "( " . $subcmds . " ) | " . $cmd;
}
@@ -550,6 +578,8 @@ sub check_stereo {
}
# main()
+$SOX = $ENV{SOX} || "sox";
+
for(@ARGV) {
if(/--?(?:V|version)$/) {
print "$SELF $VERSION\n";
@@ -563,8 +593,8 @@ for(@ARGV) {
}
}
-if(system("sox --version > /dev/null 2>&1") != 0) {
- die "$SELF: can't execute sox, is it installed?\n";
+if(system("$SOX --version > /dev/null 2>&1") != 0) {
+ die "$SELF: can't execute $SOX, is it installed?\n";
}
if(!@ARGV) {
@@ -602,7 +632,11 @@ for(@ARGV) {
for ($argc = 0; $argc < @ARGV; $argc++) {
$_ = $ARGV[$argc];
- if(/^--?v(?:erbose)?$/) {
+ if(/^--?sox$/) {
+ $SOX = $ARGV[++$argc];
+ die "$SELF: missing argument for --sox.\n" unless defined $SOX;
+ warn "$SELF: sox executable set to '$SOX'\n" if $verbose;
+ } elsif(/^--?v(?:erbose)?$/) {
$verbose = 1;
} elsif(/^--?n(?:oexec)?$/) {
$verbose = 1;