diff options
Diffstat (limited to 'soxdial')
-rwxr-xr-x | soxdial | 44 |
1 files changed, 30 insertions, 14 deletions
@@ -21,7 +21,7 @@ B<soxdial> [I<global-options>] [ [I<dial-options>] [I<dial-string>] ... ] =head1 OPTIONS -Note that option bundling is not supported. Use e.g. B<-p -n>, not B<-pn>. Also, +Note that option bundling is not supported. Use e.g. B<-v -n>, not B<-vn>. Also, spaces are required between options and their arguments. Use e.g. B<-b 16>, not B<-b16>. @@ -54,14 +54,14 @@ not enforced. Set the bits per sample. Default is 8. The only other choice is 16. -=item B<-p>, B<--print-cmd> +=item B<-v>, B<--verbose> -Print the generated B<sox> command on stdout. +Print verbose information, including the generated B<sox> command on stdout =item B<-n>, B<--no-exec> Do not execute the generated B<sox> command. This option also -enables B<-p>. +enables B<-v>. =item B<--help> @@ -170,19 +170,22 @@ $rate = 8000; $output = "-d"; sub letter2number { + my $ret; my $l = uc shift; return $l unless $l =~ /[A-Z]/; for($l) { if(/[A-O]/) { - return int((ord($_) - 65) / 3 + 2) . ""; + $ret = int((ord($_) - 65) / 3 + 2) . ""; } elsif(/[P-S]/) { - return "7"; + $ret = "7"; } elsif(/[T-V]/) { - return "8"; + $ret = "8"; } else { # /[W-Z]/ - return "9"; + $ret = "9"; } } + warn "$SELF: letter2number('$l') => '$ret'\n" if $verbose; + return $ret; } # sox -n -d synth 0.25 sine 697 sine 1209 sine 770 sine 1477 delay 0 0 .35 .35 remix - @@ -209,6 +212,7 @@ sub add_digit { $time += $digittime; $time += $intertime; } + warn "$SELF: added digit '$d', time now $time\n"; } sub make_sox_cmd { @@ -232,6 +236,11 @@ sub make_sox_cmd { } # main() +if(!@ARGV) { + warn "$SELF: no dial strings. Try $SELF --help.\n"; + exit 1; +} + for ($argc = 0; $argc < @ARGV; $argc++) { $_ = $ARGV[$argc]; @@ -244,18 +253,20 @@ for ($argc = 0; $argc < @ARGV; $argc++) { } elsif(/^--?(?:\?|h)/) { exec "perldoc $0"; exit 1; - } elsif(/^--?p(rint)?$/) { - $print_command = 1; + } elsif(/^--?v(erbose)?$/) { + $verbose = 1; } elsif(/^--?n(oexec)?$/) { - $print_command = 1; + $verbose = 1; $noexec = 1; } elsif(/^--?o(?:output)?$/) { $output = $ARGV[++$argc]; + warn "$SELF: output set to '$output'\n" if $verbose; } elsif(/^--?b(?:its)?$/) { $bits = $ARGV[++$argc]; if($bits != 8 && $bits != 16) { die "$SELF: bad -b/--bits, only 8 or 16 is allowed.\n"; } + warn "$SELF: bits set to '$bits'\n" if $verbose; } elsif(/^--?r(?:ate)?$/) { $rate = $ARGV[++$argc]; } elsif(/^--?l(?:ength)?$/) { @@ -263,14 +274,19 @@ for ($argc = 0; $argc < @ARGV; $argc++) { die "$SELF: can't change length after a dial string\n"; } $digittime = $ARGV[++$argc]; + warn "$SELF: digittime set to '$digittime'\n" if $verbose; } elsif(/^--?(?:x|extended)$/) { $extended = 1; - } elsif(/^--?a(?:lphabet)$/) { + warn "$SELF: extended DTMF (ABCD) enabled.\n" if $verbose; + } elsif(/^--?a(?:lphabet)?$/) { $extended = 0; + warn "$SELF: extended DTMF (ABCD) disabled.\n" if $verbose; } elsif(/^--?d(?:elay)?$/) { $intertime = $ARGV[++$argc]; + warn "$SELF: inter-digit delay set to '$intertime'\n" if $verbose; } elsif(/^--?c(?:omma)?$/) { $pausetime = $ARGV[++$argc]; + warn "$SELF: comma delay set to '$pausetime'\n" if $verbose; } elsif(/^--?(?:t|dialtone)$/) { die "$SELF: -t/--dialtone option not yet implemented.\n"; } else { @@ -293,8 +309,8 @@ if(!@freqs1) { my $cmd = make_sox_cmd(); -if($print_command) { - print "$cmd\n"; +if($verbose) { + warn "$SELF: sox command is:\n $cmd\n"; } else { $cmd .= " 2>/dev/null"; } |