2

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");            
        }
  1. 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.

  2. I call InitializeSounds from Form.cs and LoadSound is method for a sound manager.

  3. Alut.alutLoadMemoryFromFile causes the error, for some reason returns a null pointer.

  4. The rest is simple code hope you can understand.

I work in c# with Tao.OpenAL.

genpfault
  • 51,148
  • 11
  • 85
  • 139
pokoko222
  • 21
  • 3
  • I used Alut.alutGetError() and I get error 519. How do I now convert that to some enum? I cant find what that error means – pokoko222 Aug 12 '11 at 20:16
  • I figured out the error, it is : "There was an error opening the ALC device" What should I look for to fix this? – pokoko222 Aug 12 '11 at 20:31
  • You may have already figured this out. But for those coming here while reading c# game programming. see this wiki.http://wiki-guide.org/wiki/Windows_Error/?kw=alut%20error%20519 – aBetterGamer May 05 '12 at 02:13
  • used the OpenAL Installer for Windows from http://connect.creativelabs.com/openal/Downloads/Forms/AllItems.aspx and it fixed this for me –  Mar 15 '12 at 14:09

1 Answers1

0

You need to re-install open al. Go here to re-install.

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

aBetterGamer
  • 5,119
  • 2
  • 18
  • 19