Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does C++ read the header data of WAV audio files?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how C++ reads the header data of WAV audio files". In daily operation, I believe many people have doubts about how C++ reads the header data of WAV audio files. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how C++ reads the header data of WAV audio files". Next, please follow the editor to study!

The realization method of C++ reading the header data of WAV audio file

Implementation code:

# include # include # include using namespace std;using std::string;using std::fstream; typedef struct WAV_HEADER {char RIFF [4]; / / RIFF Header Magic header unsigned long ChunkSize; / / RIFF ChunkSize char WAVE [4]; / / WAVE Header char fmt [4]; / / FMT header unsigned long Subchunk1Size; / / Size of the fmt chunk unsigned short AudioFormat / / Audio format 1 century PCM string unsigned long Subchunk2Size 6 years MulawMagol 7 4=16-bit stereo unsigned short bitsPerSample; alaw, 257=IBM Mu-Law, 258=IBM A-Law, 259=ADPCM unsigned short NumOfChan; / / Number of channels 1=Mono 2=Sterio unsigned long SamplesPerSec; / / Sampling Frequency in Hz unsigned long bytesPerSec; / / bytes per second unsigned short blockAlign; / / 2=16-bit mono, 4=16-bit stereo unsigned short bitsPerSample; / / Number of bits per sample char Subchunk2ID [4]; / / "data" string unsigned long Subchunk2Size / / Sampled data length} wav_hdr; / / Function prototypes int getFileSize (FILE * inFile); int main (int argc,char * argv []) {wav_hdr wavHeader; FILE * wavFile; int headerSize = sizeof (wav_hdr), filelength = 0; string answer; do {string input; string answer; const char* filePath; cout > input; cin.get (); cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report