I have a problem with my wave generator. I am trying to create a wav file with sound of a given frequency. The code I'm using is:
$freqOfTone = 21000; $sampleRate = 44100; $samplesCount = 80000; $amplitude = 0.25 * 32768; $w = 2 * pi() * $freqOfTone / $sampleRate; for ($n = 0; $n < $samplesCount; $n++) { $data->samples[1][] = 32768 + (int)($amplitude * sin($n * $w)); }
Unfortunately, the output wave is incorrect, I get several frequencies instead of one: http://i49.tinypic.com/ab1nx0.png
It should look like this: http://i50.tinypic.com/33zbslk.png
Where am I doing something wrong ?: (
source share