I have problem loading a sound with OpenAL:
// in SoundManager.cs
public void LoadSound(string soundId, string path)
{
// Generate a buffer.
int buffer = -1;
Al.alGenBuffers(1, out buffer);
int errorCode = Al.alGetError();
System.Diagnostics.Debug.Assert(errorCode == Al.AL_NO_ERROR);
int format;
float frequency;
int size;
System.Diagnostics.Debug.Assert(File.Exists(path));
IntPtr data = Alut.alutLoadMemoryFromFile(path, out format, out size,
out frequency);
System.Diagnostics.Debug.Assert(data != IntPtr.Zero, "Problem");
// Load wav data into the generated buffer.
Al.alBufferData(buffer, format, data, size, (int)frequency);
// Everything seems ok, add it to the library.
_soundIdentifier.Add(soundId, new SoundSource(buffer, path));
}
// Form.cs
private void InitializeSounds()
{
_soundManager.LoadSound("effect", "soundA.wav");
}
soundIdentifier is a Dictionary, in SoundSource i keep information for a sound, and the first string is a normal name for the sound like "cow", "horse", or whatever.
I call InitializeSounds from Form.cs and LoadSound is method for a sound manager.
Alut.alutLoadMemoryFromFile causes the error, for some reason returns a null pointer.
The rest is simple code hope you can understand.
I work in c# with Tao.OpenAL.