C# “失踪”;fmt“;波形文件

C# “失踪”;fmt“;波形文件,c#,wave,C#,Wave,我正在跨平台应用程序框架中实现音频,在开始使用wave文件时遇到了一些问题 UInt32 type = rd.ReadUInt32(); UInt32 size = rd.ReadUInt32(); UInt32 waveType = rd.ReadUInt32(); UInt32 fmtType = rd.ReadUInt32(); if (type != MAGIC_RIFF || waveType != MAGIC_WAVE || fmtType != MAGIC_fmt) {

我正在跨平台应用程序框架中实现音频,在开始使用wave文件时遇到了一些问题

UInt32 type = rd.ReadUInt32();
UInt32 size = rd.ReadUInt32();
UInt32 waveType = rd.ReadUInt32();
UInt32 fmtType = rd.ReadUInt32();

if (type != MAGIC_RIFF || waveType != MAGIC_WAVE || fmtType != MAGIC_fmt)
{
    throw new InvalidDataException("Data is not of WAVE format");
}
“fmt”幻数不正确,它实际上是0x4b4e554a。Windows Media Player可以轻松播放这些文件,但我没有找到任何关于这段内容的信息。根据定义,“fmt”块必须出现。

如果我加载另一个文件,“fmt”块就会出现,那么该块实际上包含什么信息呢(不能是数据块,因为它的值为0x61746164

不要求fmt块是头后的第一个块。有一个简单的解决方案,可以跳过fmt块之间的块:

UInt32 fmtType = rd.ReadUInt32();

while (fmtType != MAGIC_fmt)
{
    rd.ReadBytes(rd.ReadInt32());
    fmtType = rd.ReadUInt32();

}