【发布时间】:2011-08-12 19:22:25
【问题描述】:
我在使用 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”或其他。
我从 Form.cs 调用 InitializeSounds,LoadSound 是声音管理器的方法。
Alut.alutLoadMemoryFromFile 导致错误,由于某种原因返回空指针。
剩下的就是简单的代码希望大家能看懂。
我使用 Tao.OpenAL 在 c# 中工作。
【问题讨论】:
-
我使用了 Alut.alutGetError() 并收到错误 519。我现在如何将其转换为某个枚举?我找不到那个错误是什么意思
-
我发现了错误,它是:“打开 ALC 设备时出错”我应该寻找什么来解决这个问题?
-
使用了来自 connect.creativelabs.com/openal/Downloads/Forms/AllItems.aspx 的适用于 Windows 的 OpenAL 安装程序,它为我解决了这个问题
-
你可能已经想通了。但是对于那些在阅读 c# 游戏编程时来到这里的人。看到这个维基。wiki-guide.org/wiki/Windows_Error/?kw=alut%20error%20519