Using the OpusFile library with Microsoft Visual Studio for Windows

jwatte's picture

The "opus" codec performs pretty well across a wide range of bit rates. When doing voice chat over the internet, or streaming music, or even including compressed music for a soundtrack for a game or other application, it is a pretty reasonable choice. Especially since it's free, as in beer!

However, the team that builds this codec knows more about codecs than about software support. The RFC in question is not a specification at all -- it makes frequent references to the reference source code, rather than actually specifying the working of the codec, which means that it's not possible to make a clean-room re-implementation from the RFC.

And, the team doesn't know how to make a Windows SDK that helps Windows developers. The "win32" library they provide is built using GCC on mingw32, and provides .a libraries, that do not work with Visual Studio at all. It also is missing a number of header files that are referenced by the header files that are included, so even if you had the proper .lib file, you can't include and use it. And the only build support that is included is "configure and make" which, again, doesn't work so well on non-UNIX systems like Windows.

So, I sat down, and generated a .lib file for the libopusfile-0.dll library, so that I could actually link against it for my project. I also tracked down some version of each of the header files that were missing (and updated the opusfile.h header to not assume ogg and opus headers are installed in the system search path.) I'm not sure that I got all the calling conventions and headers 100% correct -- version differences may cause certain files or structures to not match between Visual Studio and GCC. However, I have built a simple player, using the functions op_open_callbacks(), op_pcm_total(), op_head(), op_pcm_seek(), and op_read_float() functions, so if your needs are met by those functions only, and you're building for win32 (x86,) you're probably in luck.

Download it and give it a try. But if you try something and it crashes, then that's too bad -- this comes with no guarantee! If you don't like how it is, please file a but on the xiph.org bugtraq about how the OpusFile Windows SDK should actually support Windows and Visual Studio!

https://trac.xiph.org/newticket?component=Opus

Download the archive below. Unzip and put into your project as you see fit. Make sure the .DLL files are copied to the folder where your EXE is for it to find them. Link against the LIB and include the "opusfile.h" header.

AttachmentSize
visual-studio-compatile-opusfile-0.6-win32.zip1.88 MB