当前位置:网站首页>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
边栏推荐
- In Section 5 of bramble pie project practice, Nokia 5110 LCD is used to display Hello World
- socket编程——epoll模型
- jmeter中csv参数化
- 3大问题!Redis缓存异常及处理方案总结
- Swiperefreshlayout+recyclerview failed to pull down troubleshooting
- ¥3000 | 录「TBtools」视频,交个朋友&拿现金奖!
- JMeter interface test, associated interface implementation steps (token)
- RTOS 多线程下hardfault问题总结
- 106. 简易聊天室9:使用 Socket 传递音频
- [opencv] - input and output XML and yaml files
猜你喜欢

cazy长安战役八卦迷宫

Unity--configurable joint -- a simple tutorial to get you started with configurable joints

【期末复习笔记】数字逻辑

How to design test cases

微服务调用组件Ribbon底层调用流程分析

3大问题!Redis缓存异常及处理方案总结

C program termination problem clr20r3 solution

C language: find all integers that can divide y and are odd numbers, and put them in the array indicated by B in the order from small to large

紧急行政中止令下达 Juul暂时可以继续在美国销售电子烟产品

4、 Convolution neural networks
随机推荐
Specific usage of sklearn polynomialfeatures
Notes on key words in the original English work biography of jobs (IV) [chapter two]
一、单个神经元网络构建
华泰证券在上面开股票账户安全吗?
城鏈科技平臺,正在實現真正意義上的價值互聯網重構!
声纹技术(五):声纹分割聚类技术
Unknown table 'column of MySQL_ STATISTICS‘ in information_ schema (1109)
How annotation lib and processor lib reference
4、 Convolution neural networks
浅谈Mysql底层索引原理
【无标题】**数据库课设:三天完成学生信息管理系统**
Notes on key words in the original English work biography of jobs (V) [chapter three]
三、自动终止训练
声纹技术(一):声纹技术的前世今生
On which platform is it safe to buy shares and open an account? Ask for sharing
Cazy eight trigrams maze of Chang'an campaign
Trendmicro:apex one server tools folder
首期Techo Day腾讯技术开放日,628等你!
compiling stm32f4xx_ it. c... “.\Objects\BH-F407.axf“ - 42 Error(s), 1 Warning(s).
Notes on key words in the original English work biography of jobs (II) [chapter one]