gpt4 book ai didi

c# - NAudio : Read Wav File As Double Array

转载 作者:行者123 更新时间:2023-11-30 20:22:04 27 4
gpt4 key购买 nike

假设我的 WAV 文件包含 16 位 PCM,我如何将 wav 文件读取为双数组:

 using (WaveFileReader reader = new WaveFileReader("myfile.wav"))
{
Assert.AreEqual(16, reader.WaveFormat.BitsPerSample, "Only works with 16 bit audio");
byte[] bytesBuffer = new byte[reader.Length];
int read = reader.Read(bytesBuffer, 0, buffer.Length);
// HOW TO GET AS double ARRAY
}

最佳答案

只需在WaveFileReader 上使用ToSampleProvider 扩展方法,Read 方法将采用float[] 将样本转换为 float 。或者使用 AudioFileReader 而不是 WaveFileReader 并且您可以再次访问填充 float[]Read 方法版本>

关于c# - NAudio : Read Wav File As Double Array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32569795/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com