我有问题加载声音与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是一个字典,在SoundSource中我保留了声音的信息,第一个字符串是声音的正常名称,如"cow","horse"或其他。
我调用InitializeSounds from Form.cs和LoadSound是一个声音管理器的方法。
Alut。alutLoadMemoryFromFile导致错误,由于某种原因返回空指针。
我用c#和Tao.OpenAL一起工作。
你需要重新安装open al.到这里重新安装。
http://connect.creativelabs.com/openal/Downloads/Forms/AllItems.aspx