Go PCM data format

Source: Internet
Author: User

 

1. Introduction to Audio

Often see this description: 44100HZ 16bit stereo or 22050HZ 8bit mono and so on.

44100HZ 16bit Stereo: 44,100 samples per second, 16-bit (2-byte) recording of sampled data, two-channel (stereo);

22050HZ 8bit Mono: 22,050 samples per second, sampled data 8 bits (1 bytes) recorded, mono;

Of course, there can be 16bit mono or 8bit stereo, and so on.

The sampling rate is the number of times the sound signal is sampled in units of time during the "modulo → number" conversion process. The sampled value refers to the integral value of the sound analog signal during each sampling period.

For mono sound files, the sampled data is a eight-bit short integer (00H-FFH);

For two-channel stereo sound files, each sample data is a 16-bit integer (int), a high eight-bit (left channel) and a low eight-bit (right channel) represent two channels respectively.

The recognition range of the frequency is 20hz-20000hz, if the sound can be made 20,000 samples per second, the playback is sufficient to meet the needs of the human ear. So 22050 of the sampling frequency is commonly used, 44100 is already CD quality, more than 48000 of the sample to the human ear has no meaning. This is the same as the movie 24 frames per second picture of the truth.

The amplitude is recorded for each sampled data, and the sample precision depends on the size of the storage space:

1 bytes (i.e. 8bit) can only record 256 numbers, that is, the amplitude can only be divided into 256 levels;

2 bytes (that is, 16bit) can be fine to 65,536 numbers, which is the CD standard;

4 bytes (i.e. 32bit) can subdivide the amplitude to 4,294,967,296 levels, it is not necessary.

If it's a two-channel (stereo), the sample is double, and the file is about the same size.

This allows us to estimate the playback length of a WAV file based on the size, sampling frequency, and sample size of a WAV file.

For example, "Windows XP startup. wav" File length is 424,644 bytes, it is "22050hz/16bit/Stereo" format (this can be seen from its "properties--"),

Then its transmission rate per second (bit rate, also called bitrate, sampling rate) is 22050*16*2 = 705600 (bit/s), converted into byte units is 705600/8 = 88200 (Bytes/sec),
Playback time: 424644 (total bytes)/88200 (bytes per second) ≈4.8145578 (seconds).

However, this is not accurate enough, packaging the standard PCM format WAVE file (*.wav) with at least 42 bytes of header information, should be removed when calculating the playback time,
So there are: (424644-42)/(22050*16*2/8) ≈4.8140816 (seconds). This is more accurate.

There is also a concept about sound files: "Bit speed", also known as bit rate, sampling rate, such as the above file bit speed is 705.6kbps or 705600bps, where B is bit, PS is the meaning of each second;

Compressed audio files are often represented by bit speed, such as the MP3 of CD quality: 128kbps/44100hz.

2. PCM Data format

PCM (Pulse code modulation) is also known as pulse code modulation. The sound data in the PCM is not compressed, and if it is a mono file, the sampled data is sequentially stored in chronological order. (its basic organizational unit is byte (8bit) or Word (16bit))

In general, a frame of PCM is composed of 2048 samples (http://discussion.forum.nokia.com/forum/showthread.php?129458-, please ask the PCM format audio stream, The size of each read-in or output block must be fixed to 4096B &s=e79e9dd1707157281e3725a163844c49).

If it is a two-channel file, the sampled data is deposited in chronological order. :


Each sample value of the PCM is contained in an integer I, the length of which is the minimum number of bytes required to accommodate the specified sample length.

The data format for the 8-bit and 16-bit PCM waveform samples is shown below, first storing the low-efficient byte, which indicates that the sample amplitude is placed on the high-effective bit of I, and the remaining position is 0.

Sample size data format minimum maximum value

8-bit PCM unsigned int 0 225

16-bit PCM int-32767 32767

Transferred from: http://blog.csdn.net/ownwell/article/details/8114121

(GO) PCM data format

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.