#!/usr/bin/perl -w # Rename this to fm-28.pl to get it to run on Windows (after # installing Perl) $rate= 44100; $mf= 28/$rate; # Modulation frequency $lfmid= 207/$rate; # Carrier centre $lfwid= 100/$rate; # Carrier width $lfph= 0; # Phase for frequency $lph= 0; # Phase for signal $rfmid= 193/$rate; # Carrier centre $rfwid= 100/$rate; # Carrier width $rfph= 0; # Phase for frequency $rph= 0; # Phase for signal $twopi= 4 * atan2(1,0); sub u32 { return pack "V", $_[0]; } die unless open OUT, ">out.wav"; $cnt= $rate * 10; $len= $cnt * 4; print OUT "RIFF" . u32($len + 36) . "WAVE" . "fmt " . u32(16) . u32(0x00020001) . u32(44100) . u32(44100*4) . u32(0x0004 + 0x10000*(4*4)) . "data" . u32($len); while ($cnt-- > 0) { $lfph += $mf; $lph += $lfmid + $lfwid * sin($lfph * $twopi); $ll= sin($lph * $twopi); $rfph += $mf; $rph += $rfmid + $rfwid * sin($rfph * $twopi); $rr= sin($rph * $twopi); print OUT pack("vv", $ll * 16834, $rr * 16384); } close OUT;