#!/usr/bin/perl -w # (c) Alex McLean 2005 # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. use strict; my $output = $ARGV[0] || '/tmp/output.wav'; my $sample_rate = 44100; my $channels = 1; my $bits_sample = 16; my $seconds = 8; my $gap_seconds = .1; my $gap = ($sample_rate * $gap_seconds); my $section_seconds = 1; my $section = ($sample_rate * $section_seconds); use Audio::Wav; my $wav = new Audio::Wav; my $write = $wav->write($output, { bits_sample => $bits_sample, sample_rate => $sample_rate, channels => $channels } ); make(); sub make { my $max_hz0 = 1810; my $min_hz0 = 1400; my $diff_hz0 = $max_hz0 - $min_hz0; my $hz1 = 20; my $length = $seconds * $sample_rate; my $max_no = ( 2 ** $bits_sample ) / 2; my $playing = 0; my $last; my $vol = 1; for my $pos ( 0 .. $length ) { my $time = $pos / $sample_rate; my $point = $pos / $length; my $val; if (($pos % $section) > $gap) { $val = 0; } elsif ($vol > 0) { $val = rand(1); } my $samp = $val * $max_no; $write->write($samp * 0.5); } } $write->finish();