Stevo14's picture

Wave Loader

I've knocked-up a little wave loader in response to a request here. I hope it works OK as it still needs some work and testing.

-Supports 8 or 16 bit sound files in either mono or stereo.
-Takes care of buffering the data to OpenAL through the function "WaveSound.WriteToBuffer(uint bid);"
-Also provides access to the raw byte data if it is needed.

-Only supports PCM (who wants compression in a wave file anyway?).
-Hack-ish file-header reader (aka. can't handle any other chunks besides 'fmt ' and 'data').
-Probably many other things that I haven't thought of.

I have attached a folder containing the source code and the binaries. You will have to provide the latest version of OpenTK (from SVN) and your own wave files.
This demo itself requires Alut.dll (It uses Alut.Init() and Alut.Exit()) but the WaveLoader class has no such requirement.

WaveLoader.tar_.gz5.83 KB


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Many thanks, this means we can drop alut in the upcoming release. The code looks fine, I'll be testing and integrating into OpenTK shortly.

Inertia's picture

Indeed, thanks for the support :) I believe uncompressed PCM .wav is all we need, for compressed audio there is .ogg support.

The texture loaders follow the same philosophy for now, but if there is major demand (or even contributions for more file formats) this can be expanded at a later point.

Stevo14's picture

Sure, no problem. It was quite a pleasure to write and was also a good exercise for my programming skills. :)

Just a quick question, If Alut is being dropped, then will I be forced to use Alc for context creation or will this higher level functionality be somewhere else?

the Fiddler's picture

Alut will be replaced by an AudioContext class, much like Wgl/Glx are covered by GLContext. The current plan is to hide Alc completely - it is broken in so many ways that it's best if the complexity is hidden inside OpenTK.

Inertia's picture

To be a little more verbose:

Functions require alut.dll to be present. This is not a problem on Windows, but on Linux you have to download the FreeAlut, OpenAL and DirectX SDK source and build the library on your own. This dependency is also the reason why OpenTK gets a custom .wav loader, rather than relying on the alut one.

The Windows driver is quite mature due to it being the mainstream consumer OS. Linux is a bit behind, i.e. unstable with surround (as in more than 2 speaker output) and other problems. The AudioContext class is hiding the workarounds, so the OpenTK users don't have to deal with every single one of them.

Ogg support
Similar problem as with Alut. We don't want to add additional dependencies to OpenTK, ideally it would only require openglXX.dll and/or openalXX.dll (and the .Net framework - or the Linux/MacOS versions of those 3) on the system to run your OpenTK app.