The concept of sound

Normal sound is an analog signal, that is, a continuously changing signal. The graph is similar to the graph of trigonometric functions. Something like this:

But, as we all know. Computers transmit zeros and ones, so it’s clear that this continuous data has nothing to do with 01. So, you need to call it the 01 data, which is the digital signal.

Analog-to-digital conversion

Analog-to-digital conversion, that is, the conversion of analog signals into digital signals. All of this is achieved through an A/D converter (ADC).

The specific principles of ADC will not be analyzed too much. Let’s focus on the sampling problem.

Sampling is oneDifferential and integral calculusThe idea is to take the derivative of the x-coordinate (which of course doesn’t actually go to infinity) and sample the y-value. The diagram below:

The smaller the abscissa range, the more sampled data you get, and the higher the sound quality. After infinite sampling, you have an analog signal. But in practice, it’s not infinite, because the data sample is so large that it’s difficult to transmit.

It’s usually given an interval, how many times per second, which is the sampling rate.

 

Basic concepts of sampling

  • Sample size: How many bits are used to store a sample. The common one is 16bit(two bytes). The larger the sample size, the larger the peak value, and the more clearly compared to the analog signal diagram, that is, the intensity of the sound.
  • Sample rate: The number of samples per second. The higher the sampling rate, the smaller the difference between digital and analog signals and the smaller the sound loss. Usually 8K is enough for a phone call. 48K is basically a normal sound.
  • Number of sound channels: mono channel, double channel, multi-channel.

     

PCM and WAV

PCM. Pulse Code Modulation is one of the encoding methods of digital communication. The main process is to sample the analog signal such as voice and image every certain time to discretize it, and at the same time to round the sampling value according to the hierarchical unit, and at the same time to represent the amplitude of the sampling pulse by a set of binary code.

Speaking human, is a set of binary data, that is, the original data after the conversion of modulus.

WAV, PCM is just a set of data, it has no format. Encapsulate the PCM and put it into a container, the container is waV.

  • How to calculate the bit rate of an original PCM audio stream?Sampling rateSample size * Number of channels*

For example, sample rate 44.1khz, sample size 16bit, two-channel PCM encoded WAV file, its bit rate: 44.1k162 = 1411.2KB /s