开发者

Decode wav file into raw on win32

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 exampl开发者_StackOverflow中文版es 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,


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)


See this.

This is encapsulated in the WAVEFORMATEX structure on Win32.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜