Load .OGG files on XNA (or silverlight) #dotnet #xna
Currently I'm trying to reduce to the maxium a set of resources for a XNA port. Embedding image and sound files as XNA Content, the size of the files ends being much greater than their equivalent png, jpg or ogg.
I discovered that XNA allows to load gif, png and jpg files directly:
Image = Texture2D.FromStream(GraphicsDevice, TitleContainer.OpenStream("image.jpg"));
After that I saw the SoundEffect equivalent. SoundEffect.FromStream requires the input file to be a WAV file. A few weeks ago I started a port of the Jorbis library (that is based on libvorbis/libogg) to managed .NET.
I have performed a few changes in order to make it very easy to use on XNA:
SoundEffect = SoundEffect.FromStream(new OggToWavStream(TitleContainer.OpenStream("file.ogg")));
You can use on your XNA projects just including the NVorbis project. You can grab the source code here:
Project doesn't have any dependency and it is a portable library. In order to be able to open it (portable libraries) on VisualStudio you need the following plugin: