# Audio file waveform

The calculator displays the waveform of the input audio file fragment.

Use this calculator to view an audio file waveform. The waveform is the shape of an audio signal as a function of time. The calculator accepts wave audio files in PCM format (raw or a/mu-law encoded) and displays its waveform as a vector graph. The calculator can display multi-channel (stereo, quadro, etc.) audio waveforms.

### Waveform draw algorithm

PCM audio data is stored as a sequence of signal amplitude samples recorded at regular intervals. One second of the low-quality 8kHz audio consists of 8000 amplitude samples. To display every point of this fragment as is, you need at least an 8000-pixel wide display. I believe that such a screen resolution is still rare in 2021. Therefore, we need an algorithm to reduce the visual representation of the waveform.

The calculator uses the root mean square (RMS) algorithm to represent a sample set as a single line on the waveform graph. Brief description of the drawing algorithm:

- Determine the number of graph width points P (change by settings switch in the calculator)
- Determine the number of samples per point S=T/P, where T - total number of samples
- For every point, calculate RMS:

where s(n) - is the n-th sample of a given point - For every point, draw a vertical line from -R to R

### PCM file format nuances

Audio amplitude samples are stored either as float or integer values in PCM format. The calculator converts the integer amplitudes to float ones in range (-1...1) to represent the signal waveform on the graph uniformly. PCM format can store two types of integer data. If the integer sample size is less or equal to 8 bits (one byte), it is stored as an unsigned value. Otherwise (more than 8 bit), it's two's complement signed. The calculator transforms 8-bit integer data to float in this way: (s(n)-128)/128. The greater integer data (16, 24, or 32-bits long) is converted to float as s(n)/|int_min|. |int_min| equals to 32768; 8388608 or 2147483648 for 16, 24 or 32-bit integer respectively.

## Comments