#!/usr/bin/perl -w

$pi = 3.1415926;
$dither = 0;
$olddither = $dither;

#for ($i=0; $i<16384; $i++) {
for ($i=0; $i<88200; $i++) {
	$dither = (rand(1) - 0.5);
	$thisdither = $dither - $olddither;
	$olddither = $dither;
	$a = sin($i * 2.0 * $pi * 999.7 / 44100.0) * 0.01 + ($thisdither * 0.01);
	#$a = sin($i * 2.0 * $pi * 999.7 / 44100.0) * 0.01 + ((rand(1) - 0.5) * 0.01);
	print((&round($a * 127)/256)."\n");
}

sub round {
        my $x = shift;
        my $y = 0.5 + abs $x;
        my $abs = int $y;
        $abs -= $abs % 2 if $y == $abs;
        ($x <=> 0) * $abs;
}

