使用 BinaryReader 解析 Wave 文件
在 .NET Assembly mscorlib System.IO 命名空间中,我使用 ReadInt16() 方法循环遍历音频数据字节并将有符号整数值转储到文本文件中。如何解释与一种采样率相关的两个值?也就是说,如果我有一秒的单声道数据,则将有 88200 个字节,因此使用 ReadInt16() 返回 88200 个离散整数。这信息太多了,我应该只有 44100 个整数。那么我是否需要使用不同的方法,或者每次迭代将循环推进 1?
非常感谢......米奇
In .NET Assembly mscorlib System.IO namespace, I am using ReadInt16() method to loop through audio data bytes and dumping signed integer values into a text file. How does one interpret the two values associated with one sample rate? That is if I have one second of mono data there will be 88200 bytes, hence using ReadInt16() returns 88200 discrete integers. This is too much information, I should only have 44100 integers. So do I need to use a different method or perhaps advance the loop by 1 per each iteration.
Many thanks..........Mickey
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
一般来说,当您读取数据数组时,您的代码应该如下所示:
最有可能(我不知道 Wave 文件格式)在您的情况下,您要么需要读取成对的 Int16 值(如果样本在一起),要么单独读取通道(如果数据为一个频道接着另一个频道。
Generally when you read arrays of data your code should look like:
Most likely (I don't know Wave file format) in your case you either need to read pairs of Int16 values (if samples are together) or read channels separately if data for one channel is after another.
您必须阅读 chunkinfos。数据块告诉您必须读取多少字节。 WaveFormat 告诉您每秒有多少平均字节数,以及更多信息。我有一些VB代码...
you must read the chunkinfos. The data-chunk tells you how much bytes you have to read. the WaveFormat tells you ho much Averagebytespersecond you have, and much more. I have some VB-code...
已使用 Sharpdevelop 将 VB 代码转换为 C# ,也许这会有所帮助......
have converted the VB-code with sharpdevelop to C# maybe it helps a little bit...