diff options
author | B. Watson <urchlay@slackware.uk> | 2024-04-08 18:56:08 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-04-08 18:56:08 -0400 |
commit | f92698cc6887feb44d024e592157f112867cf2b8 (patch) | |
tree | 20eceb3a54e3e63c946bc5893ab605ee0d9c7ce4 /soxdial | |
parent | 9c0a13e4137c00a8f70a45e1469ba3f5b8130708 (diff) | |
download | misc-scripts-f92698cc6887feb44d024e592157f112867cf2b8.tar.gz |
soxdial: add --random option.
Diffstat (limited to 'soxdial')
-rwxr-xr-x | soxdial | 32 |
1 files changed, 26 insertions, 6 deletions
@@ -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 "", $_) { |