This project has moved and is read-only. For the latest updates, please go here.

WAV and OGG player on Mono Framework

Jan 12, 2014 at 1:01 PM

I am trying to create my own simple Game 2D Engine that work with OpenTK and NAudio as the Audio Engine

I was targeting the game engine to run on few platform, at least at Windows, Mac and Linux and I dont need MP3 support, I just need Wave and OGG player

is it any chance to run the apps with NAudio on other platform?
Jan 12, 2014 at 6:00 PM
To play OGG (basically a FLAC stream in an OGG container) you will need the MediaFoundation API which is Windows-only (Vista/7/8). I'm quite sure Mono/Linux doesn't support MediaFoundation (correct me if I'm wrong).

Perhaps Linux has a similar audio library which you can use?
Jan 13, 2014 at 1:57 PM
I would recommend OpenAL for your audio engine. NAudio is really Windows-only.

Depending on which codec(s) you are using in Ogg, you may use one (or more) of the following:

For Vorbis: NVorbis - Fully managed, written by yours truly. ;)
For FLAC: FlacBox - Fully managed, just found it from Google.
For Opus: Opus.NET - P/Invoke wrapper around libogg/libopus
For Speex: NSpeex - Fully managed, just found it from Google.

A web search should provide alternatives if you would rather use them or if you are using a different codec in the Ogg container (unlikely).
Jan 13, 2014 at 2:36 PM
yes, NAudio has lots of wrappers for Windows APIs which simply won't work on Linux.

Some nice finds there ioctlLR - I keep meaning to update the AudioFileReader class so all of these add-ons can easily be plugged in.
Jan 14, 2014 at 2:39 PM
Mark, how about this for the add-on API? :)
Jan 14, 2014 at 2:50 PM
yes, similar to the lines I was thinking of, except I may create a base interface that all the plugins implement, and give them the ability to optionally support reading from a Stream.
Jan 15, 2014 at 2:23 PM
Thanks for your reply!
I manage to use OpenAL
Jan 15, 2014 at 3:19 PM
CXO2: I'm glad it worked out. Good luck with your project.

Mark: OK, a few questions (and my recommendations):
  • Abstract base class or interface? (interface)
  • Use an attribute and pass a Type to AudioFileReader, or put "discovery" info on a property and pass an instance to AudioFileReader? (attribute)
  • .ctor(string) w/ exception for invalid file, bool TryLoad(string), or bool CheckSignature(byte[])? (CheckSignature, but it's harder to implement)
In any case, it would be simple to implement as a set of generic methods in AudioFileReader (i.e., AddCodec<T>() where T : ICodecReader, new()).