您好,尝试为立体声.wav文件创建标头编码正确的规范。单声道文件创建工作正常,而编写立体声的尝试似乎会缩短一半。相当确定它在标题部分中。下面展示了两个示例(单声道和立体声)。任何见解都将受到高度赞赏。
Mono标头-此代码很好
FileStream fsOut = new FileStream(oPath, FileMode.Create, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fsOut);
fsOut.Position = 0;
bw.Write(new char[4] { 'R', 'I', 'F', 'F' });
bw.Write(Convert.ToInt32(length));
bw.Write(new char[8] { 'W', 'A', 'V', 'E', 'f', 'm', 't', ' ' });
bw.Write((int)16);
bw.Write((short)1);
bw.Write((short)1);
bw.Write(samplerate);
bw.Write((int)(samplerate * ((BitsPerSample * 1) / 8)));
bw.Write((short)((BitsPerSample * 1) / 8));
bw.Write(BitsPerSample);
bw.Write(new char[4] { 'd', 'a', 't', 'a' });
bw.Write(Convert.ToInt32(DataLength));
立体声-这仅记录了单声道的长度
FileStream fsOut = new FileStream(oPath, FileMode.Create, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fsOut);
fsOut.Position = 0;
bw.Write(new char[4] { 'R', 'I', 'F', 'F' });
bw.Write(Convert.ToInt32(length));
bw.Write(new char[8] { 'W', 'A', 'V', 'E', 'f', 'm', 't', ' ' });
bw.Write((int)16);
bw.Write((short)1);
bw.Write((short)2);
bw.Write(samplerate);
bw.Write((int)(samplerate * ((BitsPerSample * 2) / 8)));
bw.Write((short)((BitsPerSample * 2) / 8));
bw.Write(BitsPerSample);
bw.Write(new char[4] { 'd', 'a', 't', 'a' });
bw.Write(Convert.ToInt32(DataLength));
答案 0 :(得分:0)
所以问题出在我在体内写的正弦波,而不是标题。