当前位置:网站首页>Format analysis and explanation of wav file
Format analysis and explanation of wav file
2022-06-25 09:04:00 【u013250861】
WAV File is in PC It is very common on the platform 、 The most classic multimedia audio file , As early as 1991 year 8 The moon appears in Windows 3.1 On the operating system , The file extension is WAV, yes WaveFom Abbreviation , Also known as waveform file , It can directly store sound waveform , The restored waveform curve is very realistic .
WAV File format abbreviation WAV Format is a digital audio format that stores sound waveforms , It's Microsoft and IBM Jointly designed , After many revisions , Can be used for Windows,Macintosh,Linix And many other operating systems , Details are as follows .
One 、 Basic knowledge of waveform file
1、 Stored procedure of waveform file
The sound from the sound source is converted into a continuously changing electrical signal through the microphone , After zooming in 、 After anti aliasing filtering , Sample at a fixed frequency , Each sample is the amplitude value of electrical signal detected in a sampling period ; Next, it is quantized from an analog electrical signal into an integral value represented by a binary number ; Finally encoded and stored as audio stream data .
Some applications save storage space , Before storage , And compress the sampling data first .
2、WAV Coding of documents
The coding includes two aspects , One is to store data in a certain format , The second is to compress data with certain algorithm .
WAV The format has no hard rules for the encoding of audio stream , Supports uncompressed PCM(Puls Code Modulation) Pulse code modulation format , It also supports Microsoft adaptive sub pulse code modulation of compression type Microsoft ADPCM(Adaptive Differential Puls Code Modulation)、 The International Telegraph Union (International Telegraph Union) The voice compression standard ITUG.711 a-law、ITU G.711-law、IMA ADPCM、ITU G.723 ADPCM (Yamaha)、GSM 6.10、ITU G.721 ADPCM Coding and other compression algorithms .MP3 Coding can also be used in WAV in , Just install the corresponding Decode, You can play WAV Medium MP3 music .
The parsing code is as follows :
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
struct WAV_Format {
uint32_t ChunkID; /* "RIFF" */
uint32_t ChunkSize; /* 36 + Subchunk2Size */
uint32_t Format; /* "WAVE" */
/* sub-chunk "fmt" */
uint32_t Subchunk1ID; /* "fmt " */
uint32_t Subchunk1Size; /* 16 for PCM */
uint16_t AudioFormat; /* PCM = 1*/
uint16_t NumChannels; /* Mono = 1, Stereo = 2, etc. */
uint32_t SampleRate; /* 8000, 44100, etc. */
uint32_t ByteRate; /* = SampleRate * NumChannels * BitsPerSample/8 */
uint16_t BlockAlign; /* = NumChannels * BitsPerSample/8 */
uint16_t BitsPerSample; /* 8bits, 16bits, etc. */
/* sub-chunk "data" */
uint32_t Subchunk2ID; /* "data" */
uint32_t Subchunk2Size; /* data size */
};
int main(void)
{
FILE *fp = NULL;
struct WAV_Format wav;
fp = fopen("test.wav", "rb");
if (!fp) {
printf("can't open audio file\n");
exit(1);
}
fread(&wav, 1, sizeof(struct WAV_Format), fp);
printf("ChunkID \t%x\n", wav.ChunkID);
printf("ChunkSize \t%d\n", wav.ChunkSize);
printf("Format \t\t%x\n", wav.Format);
printf("Subchunk1ID \t%x\n", wav.Subchunk1ID);
printf("Subchunk1Size \t%d\n", wav.Subchunk1Size);
printf("AudioFormat \t%d\n", wav.AudioFormat);
printf("NumChannels \t%d\n", wav.NumChannels);
printf("SampleRate \t%d\n", wav.SampleRate);
printf("ByteRate \t%d\n", wav.ByteRate);
printf("BlockAlign \t%d\n", wav.BlockAlign);
printf("BitsPerSample \t%d\n", wav.BitsPerSample);
printf("Subchunk2ID \t%x\n", wav.Subchunk2ID);
printf("Subchunk2Size \t%d\n", wav.Subchunk2Size);
fclose(fp);
return 0;
}
ByteRate The calculation method is SampleRate * NumChannels * BitsPerSample/8, So what this formula calculates is 1 Second audio data size , Unit is Byte, With 44100、16bit、2 Channel, for example , Then the calculated value is 176400, According to the total audio data size , It can be concluded that the calculation formula of playing time is Subchunk2Size / ByteRate.
surface 1
Block identification (4Bytes) |
---|
Block length (4Bytes) |
data |
Reference material :
wav File format analysis and detailed explanation
wav Audio file format analysis
边栏推荐
- mysql之Unknown table ‘COLUMN_STATISTICS‘ in information_schema (1109)
- 2、 Training fashion_ MNIST dataset
- Notes on key words in the original English work biography of jobs (VI) [chapter three]
- 行业春寒回暖,持续承压的酒店企业于何处破局?
- 【期末复习笔记】数字逻辑
- 声纹技术(七):声纹技术的未来
- 十大券商开户风险大吗,安全靠谱吗?
- Le labyrinthe des huit diagrammes de la bataille de cazy Chang'an
- 5、 Project practice --- identifying man and horse
- 3、 Automatically terminate training
猜你喜欢
The city chain technology platform is realizing the real value Internet reconstruction!
[untitled] * * database course design: complete the student information management system in three days**
cazy长安战役八卦迷宫
Oracle one line function Encyclopedia
五、项目实战---识别人和马
atguigu----17-生命周期
jmeter中csv参数化
Emergency administrative suspension order issued Juul can continue to sell electronic cigarette products in the United States for the time being
紧急行政中止令下达 Juul暂时可以继续在美国销售电子烟产品
Benefits and types of cloud network technology
随机推荐
Object.defineProperty也能监听数组变化?
Make a skylearn high-dimensional dataset_ Circles and make_ moons
IC研发常用英文术语缩写
自定义注解之编译时注解(RetentionPolicy.CLASS)
Level 6 easy to mix words
5、 Project practice --- identifying man and horse
Notes on key words in the original English work biography of jobs (III) [chapter one]
[opencv] - Discrete Fourier transform
atguigu----18-组件
Chinese solution cannot be entered after webgl is published
annotation lib 和 processor lib如何引用
【OpenCV】—输入输出XML和YAML文件
jmeter中csv参数化
【无标题】**数据库课设:三天完成学生信息管理系统**
matplotlib matplotlib中plt.grid()
Where are the hotel enterprises that have been under pressure since the industry has warmed up in spring?
高速缓冲存储器Cache的映射方式
Cazy eight trigrams maze of Chang'an campaign
Socket programming -- poll model
【MYSQL】事务的理解