Wave audio data format

zhaozj2021-02-17  50

Seeing having a format with netizens asking about audio data, I just do this project. The article I collected will post the article.

WAVE file format analysis

Wave files as one of the sound wave file formats used in multimedia, is standard in Riff format. Riff is an abbreviation of English Resource Interchange File Format, and the first four bytes of each Wave file are "riff". Wave files consist of two parts of the file header and data. The file head is divided into two parts: Riff / WAV file identification segment and sound data format description segment. The content and format of the Wave file are attached to the table. There are two common sound files, respectively correspond to mono (11.025 kHz sampling rate, 8bit sampling value) and a two-channel (44.1 kHz sampling rate, and 16bit sampling value). The sample rate refers to the number of times the sound signal is sampled during the unit time during the "model → number" conversion process. Sampling value refers to the integral value of sound analog signals in each sampling cycle. For mono sound files, the sampling data is a short integer (short int 00h-ffh); for a two-channel stereo sound file, each sample data is a 16-bit integer (int), high eight bits and Low eight digits represent the left and right channels. The WAVE file data block contains a sample represented by a pulse coding modulation (PCM) format. The WAVE file is made by the sample organization. In the mono Wave file, channel 0 represents the left channel, and the channel 1 represents the right channel. In the multi-channel WAVE file, the sample is alternate.

WAVE file format description table

Offset address byte digital type internal file header 00h 4 char "riff" logo 04h 4 long int file length 08h 4 char "Wave" logo 0ch 4 char "fmt" flag 10h 4 transition byte (uncertain) 14h 2 int INT The format category (10h is a pCM form sound data) 16h 2 INT channel number, mono 1, double channel is 2 18h 2 int sample rate (number of samples per second), indicating the playback speed of each channel, 1Ch 4 Long INT Waveform Audio Data Transmission rate, its value is a number of data bits per second × per sample number / 8. Playback software utilizes this value to estimate the size of the buffer. 20H 2 INT data block adjustment (according to the word or calculation), its value is a number of channels × data bit value / 8 of each sample. Playback software requires a number of bytes of byte data for multiple values ​​to be handled in order to use their values ​​to adjust the buffer. 22h 2 The number of data digits per sample represents the number of data bits in each sample in each channel. If there are multiple channels, the sample size is the same for each channel. 24h 4 char data tag "Data" 28h 4 long int voice data length

PCM data storage mode:

Sample 1 Sample 2 8-bit mono 0 channel 0 channel 8-bit stereo 0 channel (left) 1 channel (right) 0 channel (left) 1 channel (right) 16-bit mono 0 channel Low byte 0 channel high byte 0 channel low byte 0 channel high byte 16-bit stereo 0 channel (left) low byte 0 channel (left) high byte 1 channel (right) low character 1 channel (right) high byte

Each sample value of the WAVE file is included in an integer i, the length of i is the minimum byte required to accommodate the specified sample length. First, the low-active byte is stored, indicating the bit placed on the sample amplitude on the high significant bit of I, and the remaining position is 0, and the data format of the 8-bit and 16-bit PCM waveform samples is shown below. Sample size data format Maximum smallest 8 bit PCM unsigned int 225 0 16-bit PCM INT 32767 -32767

转载请注明原文地址:https://www.9cbs.com/read-29216.html

New Post(0)