eumcoz's picture

OpenAL Questions


I'm making a 2D game(a Super Mario Brothers game) using the game window class, and I am trying to add in looping background music. I made a function to create the sound.

        public void loadAudio()
            using (AudioReader sound = new AudioReader("smb1.wav"))
                int buffer = AL.GenBuffer();
                int source = AL.GenSource();
                AL.BufferData(buffer, sound.ReadToEnd());
                AL.Source(source, ALSourcei.Buffer, buffer);
                AL.Source(source, ALSourceb.Looping, true);
          //      Console.ReadLine(); 
           //     AL.SourceStop(source); 
            //    AL.DeleteSource(source); 

I am having a problem with this, (AudioReader sound = new AudioReader("smb1.wav")) is throwing the exception

System.NotSupportedException was unhandled
  Message="Could not find a decoder for the specified sound stream."

I did all I can to make sure this was truly a .wav file, including reconverting it to a .wav file. I was wondering if there is a certain encoding that the .wav file needs to be to work. This doesn't happen with every .wav file, just certain files, so I figure if its something in particular about the file(i.e the encoding). Any help would be greatly appreciated.


Comment viewing options

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

This is probably an unsupported encoding. Can you upload one of those wav files?

eumcoz's picture

Ya, i uploaded to, called smb1.wav. Right now the encoding scheme it is in is Microsoft ADPCM 8.000kHz, 4Bit, Mono. What encoding should I be using, or what program can I use to convert my files to the correct encoding.


the Fiddler's picture

Thanks, I will take a look at the file once I get some sleep. The issue is probably that the wave reader doesn't support 4bit samples; it only supports 8bit and 16bit at the moment.

However, I don't think OpenAL supports 4bit samples either, so your best bet is to convert these wavs to 8bits. The trial version of Goldwave should be able to do this (maybe someone knows of a better application?)

Entropy's picture

Audacity is generally a good bet for a free open-source, cross platform sound format converter, and for general editing/tweaking of existing sound files.

The absolute best converter I've used is actually Ableton Live, which is really a fully-fledged music sequencer. When my friend sent me samples for LinkSphere, they came as 32-bit 44.1KHz .aiff files, and the best way to convert them to the required 16-bit 48KHz .wav files was to stick them on an empty score in Ableton and render it with those settings. It completely rebuilds the samples info for you. It's not free though (in fact, it's VERY not-free) and if that was all you were going to use it for, it would be like installing Photoshop as your primary jpeg-viewing app.

eumcoz's picture

I got it working, took a little bit to get the compression right, but It works now. Thanks for all the help.