Pulse Code Modulation (PCM) Basics

A simple example of sampling a sine wave at different sampling rates, and different number of levels. You can see how increasing the sampling rate and number of levels produces a digital waveform closer to the continuous sine wave. But in practice this comes at the expense of an increased required data rate to send the digital data.

$levels-1) { $c = $levels -1; } if ($c < 0) { $c = 0; } $v = 100.0*($c*2.0/($levels-1)-1); if ($i == 0) { $chartdata = $v; } else { $chartdata = $chartdata . "," . $v; } } echo "Frequency: 1Hz
"; echo "Samples: " . $samples . " per second
"; echo "Levels: " . $levels . "
"; ?> Pulse Code Modulation
Samples:
Levels: