Projects, portfolio, and personal work of Joe Pelz

PCM Encoder

Get the secret PCM Decoder ring free by mailing in 10 box tops

One of my courses at BCIT was Data Communications, which focussed mainly on the bottom 3 layers of the TCP/IP stack. One of the things we covered was converting between digital and analog signals. PCM stands for Pulse Code Modulation and covers the conversion from analog to digital.

As we talked about simple waves, composite waves, sampling rates, bit rates, and quantization, I realized that this was the perfect case for an interactive tool that would explore the relation between them all. The majority of the program was built over a weekend, and all in all it was one of the smoothest projects I’ve ever developed, with no significant bugs or issues.

  1. The first pane shows your frequency domain plot. These control your input to the encoder. Click in a blank space to add a new frequency, and click on an existing bar to change it’s frequency, amplitude, or phase.
  2. The second pane shows the input wave form. Click it to toggle between simple waves overlaid, and a composite wave signal.
  3. The third pane shows sampling frequency during PCM. The slider above lets you choose the number of samples per second. Nyquist’s law indicate’s the minimum sampling rate be 2x the highest frequency in the input. Your standard mp3 uses 44,100 samples per second.
  4. The fourth panel shows the quantized wave, based on the samples above. The quantization steps are calculated from the number of bits per sample. Your standard mp3 uses 16 bits per sample, or 2^16 = 65536 quantization levels.
  5. The final panel shows the reconstructed signal. It takes the quantized form above and smooths the stair-stepping to approximate the original input.

Download the jar file here

Download the source code here