2

我在使用 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");            
        }
  1. soundIdentifier 是一个字典,在 SoundSource 中我保存声音的信息,第一个字符串是声音的正常名称,如“cow”、“horse”或其他。

  2. 我从 Form.cs 调用 InitializeSounds,而 LoadSound 是声音管理器的方法。

  3. Alut.alutLoadMemoryFromFile 导致错误,由于某种原因返回一个空指针。

  4. 剩下的就是简单的代码希望你能看懂。

我使用 Tao.OpenAL 在 c# 中工作。

4

1 回答 1

0

你需要重新安装open al。去这里重新安装。

http://connect.creativelabs.com/openal/Downloads/Forms/AllItems.aspx

于 2012-05-05T02:19:31.437 回答