In honor of the US government's new National Do Not Call Registry, I give you a script to generate those three little tones that telemarketing computers hate to hear...

Special Information Tones to the rescue!

#!/usr/bin/perl -w use strict; use Audio::Wav; my $sample_rate = 8000; my $bits_sample = 8; my $num_channels = 1; my $pi = 4 * atan2 1, 1; my $max_no = ( 2 ** $bits_sample ) / 2; my @tones = map { 2 * $pi * $_ } (985.2, 1370.6, 1776.7); # in Hz my @dur = map { $sample_rate / 1000 * $_ } (380, 274, 380); # in ms my $details = { 'bits_sample' => $bits_sample, 'sample_rate' => $sample_rate, 'channels' => $num_channels, }; my $wav = new Audio::Wav; my $write = $wav->write( 'sit.wav', $details ); for ( 0 .. 2 ) { for my $pos ( 0 .. $dur[$_] ) { $write->write( $max_no * sin( $pos / $sample_rate * $tones[$_] ) ) +; } } $write->finish();


In reply to Do Not Call! by Mr. Muskrat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.