当前位置:网站首页>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] understanding and use of indexes
- 四、卷积神经网络(Convolution Neural Networks)
- RTOS 多线程下hardfault问题总结
- The city chain technology platform is realizing the real value Internet reconstruction!
- Matplotlib axvline() and axhline() functions in Matplotlib
- nodejs 使用Express框架demo
- Mapping mode of cache
- Flutter multilingual intl: ^0.17.0 cannot be imported
- 一、单个神经元网络构建
- Openfoam: bottom layer
猜你喜欢

Emergency administrative suspension order issued Juul can continue to sell electronic cigarette products in the United States for the time being

wav文件(波形文件)格式分析与详解

C # startup program loses double quotation marks for parameters passed. How to solve it?

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

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

浅谈Mysql底层索引原理

Close a thread

matplotlib matplotlib中plt.axis()用法

¥3000 | 录「TBtools」视频,交个朋友&拿现金奖!

In Section 5 of bramble pie project practice, Nokia 5110 LCD is used to display Hello World
随机推荐
Trendmicro:apex one server tools folder
声纹技术(一):声纹技术的前世今生
106. 简易聊天室9:使用 Socket 传递音频
CSV parameterization in JMeter
【MYSQL】事务的理解
紧急行政中止令下达 Juul暂时可以继续在美国销售电子烟产品
声纹技术(五):声纹分割聚类技术
Analysis of a video website m3u8 non perceptual encryption
Notes on key words in the original English work biography of jobs (VI) [chapter three]
《乔布斯传》英文原著重点词汇笔记(二)【 chapter one】
How annotation lib and processor lib reference
微服务调用组件Ribbon底层调用流程分析
【OpenCV】—输入输出XML和YAML文件
从别人库里拷贝的游戏如何再自己的库里显示
Explanation of assertions in JMeter
On the underlying index principle of MySQL
3 big questions! Redis cache exceptions and handling scheme summary
城鏈科技平臺,正在實現真正意義上的價值互聯網重構!
获取扫码的客户端是微信还是支付宝
Unity--configurable joint -- a simple tutorial to get you started with configurable joints