200行代码实现PCM格式的WAV文件的读写,使用标准C++库实现,不依赖于其他库。
// Write WAv文件
Wave_header header(1, 48000, 16);
uint32_t length = header.fmt_data->sample_per_sec * 10 * header.fmt_data->bits_per_sample / 8;
uint8_t *data = new uint8_t[length];
CWaveFile::write("e:\\test1.wav", header, data, length);
// read
//CWaveFile wave;
//wave.read("e:\\test1.wav");
2019-12-21 19:29:47
7KB
wav
1