Menu β–Ύ β–΄

About WAV file of 1 second 1kHz sine wave

yamamoto2002
Attachments
Math_a.png (296477 bytes)
WAV1.png (907227 bytes)
WAV2.png (360903 bytes)
WAV3.png (387962 bytes)
WaveGene_a.PNG (18550 bytes)

This article explains the WAV file that contains 1 second 1kHz sine wave:

  • How to generate PCM sample sequence of 1kHz and
  • How to organize the WAV file to accommodate 1 second PCM sample sequence.

Sampling of 1kHz sine signal to create discrete-time sample sequence

When 1 second of 1kHz signal is sampled by 44100Hz, 44100 sampled values is produced. (This is obviousπŸ™‚ )

When we look closer to those 44100 samples, first 441 sample values are repeated 100 times. This is caused by periodicity of sine function : sin(x + 2Ο€) = sin(x). This 441 samples contain exact 10 cycles of sine wave.

Most of sampled values are irrational numbers I think.

Exact sampled value of symbolic form
Fig.1

There is actually infinity there in the discrete-time sampled 1kHz sine signal:

  • Most of sample values are irrational numbers. This means, to represent one sample value exactly (for example sample#148 = sqrt(3)/2 ), infinite number of digits are needed. 16bit quantization truncates the value of first 16bit of the number to create finite digit rational number and quantization noise is generated by the truncation.
  • Pure 1kHz signal is, by definition, has infinite length. If it is truncated to finite length (1 second), other frequency components appear on the truncated edge and signal is contaminated. You may hear click noise at the truncated edge.

Quantize sample values to create 16bit/24bit integer sample values

When those values are quantized to 16bit or 24bit integer PCM, sample values becomes something like the following table.

In digital domain, PCM signal is stored/transferred as a list of those integer values. One second of PCM consists of 44100 integer values.

441 sampled and quantized values
Fig.2

First part of the sampled values plotted using Audacity. This is proper expression to depict discrete-time sampled signal.

Audacity screen shot depicting discrete-time sampled values
Fig.3

Following graph is typical audio DAC output analog waveform simulated by Adobe Audition:

Adobe Audition screenshot depicting DAC output analog waveform
Fig.4

You may notice from the graph above, reconstructed analog wave form does not exhibit staircase shape. It is not obvious on Fig.4 but please look closely near the peak of the hill, it is curved and is not straight line! Typical audio DAC uses Whittaker-Shannon interpolation formula to fill gaps between two adjacent sample values to create continuous curve. If DAC uses zero order hold interpolation to fill intervals between two adjacent points, reconstructed analog waveform looks like a staircase.

About WAV file structure

WAV file stored 1 second (truncated) 1kHz sine can be created using WaveGene. Generated WAV file can be read using any Hex editor. I'm using HxD.

WaveGene screenshot
Fig.5

WAV file description slide 1
Fig.6

WAV file description slide 1
Fig.7

WAV file description slide 1
Fig.8

About file offset and what actually contained in a WAV file

WAV file has the start and the end (Unlike S/PDIF or digital radio broadcast stream where there is no start and no end) and WAV file format use it as the means to organize data.

Offset is the count of bytes from start of the file and it usually counts from zero.

On the HxD Editor screenshot of my previous post, 8-digit hexadecimal offset number is added by HxD Editor for human reading convenience.

Actual WAV files do not contain offset values in the file, but it can be calculated by counting data bytes from the file start. On the accompanying table of the slides has also offset columns and I added it for readers to compare easily the table rows with HxD screenshot hexadecimal dump.

Actual WAV file data is something like this (expressed as hexadecimal number sequences, which is shown in HxD Editor screen) :
52 49 46 46 AC 58 01 00 ...

One 1-digit hexadecimal number is actually 4-bit data and it can be expressed as a 4-digit binary number:

hex 0⇔bin 0000, hex 1⇔bin 0001, hex 2⇔bin 0010, hex 3⇔bin 0011
hex 4⇔bin 0100, hex 5⇔bin 0101, hex 6⇔bin 0110, hex 7⇔bin 0111
hex 8⇔bin 1000, hex 9⇔bin 1001, hex A⇔bin 1010, hex B⇔bin 1011
hex C⇔bin 1100, hex D⇔bin 1101, hex E⇔bin 1110, hex F⇔bin 1111

Therefore this WAV file data also can be expressed as a binary digits sequence:
01010010 01001001 01000110 01000110 10101100 01011000 00000001 00000000 ...

On storage media, value 1 may expressed as the hole (of the punched card), magnetized, charged, high resistance values, etc.

About difference of 16-bit sample values of Fig.2 and Fig.8

There is a small difference between Fig.2 and Fig.8 values. Max difference is 1. I think this difference is caused by sine function evaluation algorithm difference of Excel and WaveGene.


Related

Wiki: Home
Wiki: PlayPcmWinEn
Wiki: PlayPcmWinJp