aboutsummaryrefslogtreecommitdiff
path: root/soxdial
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-04-08 18:56:08 -0400
committerB. Watson <urchlay@slackware.uk>2024-04-11 16:52:47 -0400
commitc93d500bddf1ce86ba7df1599277d2921287950b (patch)
tree7da23c0c334c3e51e519571bdd30df3cee89ec28 /soxdial
parentee9ebe0fe7f6494dbafa862364e4e3056db81679 (diff)
downloadsoxdial-c93d500bddf1ce86ba7df1599277d2921287950b.tar.gz
soxdial: add --random option.
Diffstat (limited to 'soxdial')
-rwxr-xr-xsoxdial32
1 files changed, 26 insertions, 6 deletions
diff --git a/soxdial b/soxdial
index e07b752..6bd23d1 100755
--- a/soxdial
+++ b/soxdial
@@ -69,6 +69,13 @@ 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<-X>, B<--random>
+
+Randomize the timing. Digit length (B<-l>), inter-digit timing
+(B<-d>), and the comma (B<-c>) will vary from 1x to 2x the amount
+specified. This does a pretty good impression of a human dialling a
+number manually.
+
=item B<-S>, B<--stereo>
Output stereo audio. The left and right channels will contain the same
@@ -125,17 +132,17 @@ dial strings, until the same option is seen again.
=item B<-l>, B<--length> [ I<sec> | I<millisec>B<ms> ]
Sets the time each digit's tones are played. Default is 0.25
-or 250ms.
+or 250ms. Can be randomized with B<-X>, B<--random>.
=item B<-d> I<sec>, B<--delay> [ I<sec> | I<millisec>B<ms> ]
Sets the delay between consecutive digits. Default is 0.1
-or 100ms.
+or 100ms. Can be randomized with B<-X>, B<--random>.
=item B<-c> I<sec>, B<--comma> [ I<sec> | I<millisec>B<ms> ]
Sets the delay added by commas in the dial strings. Default is 0.5
-or 500ms.
+or 500ms. Can be randomized with B<-X>, B<--random>.
=item B<-x>, B<--extended>
@@ -268,6 +275,15 @@ sub letter2number {
return $ret;
}
+sub randomize {
+ my $time = shift;
+ return $time unless $random;
+
+ my $newtime = $time * (rand() + 1);
+ warn "$SELF: randomized $time to $newtime.\n" if $verbose;
+ return $newtime;
+}
+
# sox -n -d synth 0.25 sine 697 sine 1209 sine 770 sine 1477 delay 0 0 .35 .35 remix -
# ...plays DTMF 1 and 6, for 0.25 sec each, with a 0.10 sec delay between them.
@@ -279,7 +295,7 @@ sub add_digit {
push @freqs2, 0;
push @delays, $time;
- $time += $pausetime;
+ $time += randomize($pausetime);
} else {
#print "time $time\n";
#print "freq1 " . ($freqs{$d}->[0]) . "\n";
@@ -287,10 +303,11 @@ sub add_digit {
push @freqs1, ($freqs{$d}->[0]);
push @freqs2, ($freqs{$d}->[1]);
+
push @delays, $time;
- $time += $digittime;
- $time += $intertime;
+ $time += randomize($digittime);
+ $time += randomize($intertime);
}
warn "$SELF: added digit '$d', time now $time\n" if $verbose;
}
@@ -493,6 +510,9 @@ for ($argc = 0; $argc < @ARGV; $argc++) {
} elsif(/^--?(?:R|right)$/) {
$left = 0;
$stereo = $right = 1;
+ } elsif(/^--?(?:X|random)$/) {
+ # sorry I had to use -X for this, -R was already taken.
+ $random = 1;
} else {
warn "$SELF: start dial string '$_'\n" if $verbose;
for (split "", $_) {