简体   繁体   中英

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 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,

.wav头文件很简单 (一个教程),一旦找到它们,PCM编码数据可能直接送到ASIO(通过解析头的几个简单字段)

See this .

This is encapsulated in the WAVEFORMATEX structure on Win32.

如果你获取了libsndfile的源代码tarball,你会发现它包含了examples /和programs /目录下的一些示例程序。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM