在 win32 上将 wav 文件解码为 raw
如何将 Windows 上包含 PCM 数据的 wav 文件 (RIFF) 解码为 win32 上的原始样本(以便我可以将其提供给 ASIO)?
我没有时间重新发明轮子。如果有一个库可以一次性完成整个“将 wav 文件播放到 ASIO 中”的任务,那就太好了。不过,ASIO 很简单,并且在线上有很多适用于 Windows 的示例。如果我有 wav 文件作为原始 PCM 数据来提供给它就好了!
我尝试过使用 libsndfile,但是没有任何关于如何在 Windows 上使用它的示例,并且它无法在 Windows 上编译。 (他们交叉编译它并目前发布了一个二进制文件。)
必须有一种方法可以使用 MS API 来做到这一点......它是什么?
如果它能将其转换为 16 位 44.1 kHz 音频,这样我就可以将其提供给 ASIO,那就太好了,但我可以将这两个位连接在一起,如果有人能给我一个关于如何解码 wav 文件的提示的话Windows 上的原始样本,
How can I decode a wav file (RIFF) containing PCM data on Windows into raw samples (so that I can feed it to ASIO) on win32?
I don't have time to reinvent the wheel. If there's a library out there that does the whole "play a wav file into ASIO" thing at once, that would be nice. ASIO is simple enough, though, and has many examples for Windows online. If only I had the wav file as raw PCM data to feed to it!
I've tried to use libsndfile, but there aren't any examples of how to use it on Windows out there, and it will not compile on Windows. (They cross-compile it and release a binary currently.)
There HAS to be a way to do this using the MS API... what is it?
It would be nice if it converted it to 16 bit 44.1 kHz audio so that I can feed it to ASIO, but I can deal with hooking the two bits together, if only someone can give me a hint as to how to decode a wav file into raw samples on Windows,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
.wav 头文件是非常简单(教程),并且一旦找到它们(通过解析标头的几个简单字段),PCM 编码数据可能会直接馈送到 ASIO
The .wav header-file is dead simple (a tutorial), and the PCM encoded data can probably be fed directly to ASIO once you locate them (by parsing a few simple fields of the header)
查看此内容。
这封装在 Win32 上的 WAVEFORMATEX 结构中。
See this.
This is encapsulated in the WAVEFORMATEX structure on Win32.
如果您获取 libsndfile 的源代码 tarball,您会发现它在示例/和程序/目录中包含许多示例程序。
If you grab the source code tarball for libsndfile you will find it contains a number of example programs on the examples/ and programs/ directories.
它们不是 Windows API 的一部分,但由于我没有太多直接使用它的经验,所以我只会告诉您一些我知道/已经使用过的工具,它们可以满足您的需求。
Python 有
aifc
模块。如果您不想使用 Python 并且可以从代码中调用外部程序,那么 FFmpeg 是另一个选择。编辑:由于您似乎是为了工作而这样做,您可能想看看 http:// ffmpeg.org/legal.html 如果您考虑使用 FFmpeg(您可能不会考虑,因为其他人已经提供了 WinAPI 相关信息),因为 FFmpeg 使用 LGPL 或 GPL 版本,具体取决于您使用什么选项/如何配置它。
They aren't parts of the Windows API, but since I don't have much experience working directly with it I'll just tell you about a couple tools I know of/have used that will do what you want.
Python has the
aifc
module. FFmpeg is another option if you don't want to use Python and are fine with calling external programs from your code.EDIT: as you seem to be doing this for work, you'll probably want to take a look at http://ffmpeg.org/legal.html if you think about using FFmpeg (which you probably won't since other people have been giving WinAPI-related info), since FFmpeg uses either a version of the LGPL or the GPL depending on what options you use/how you configure it.