HermanssoN's picture

Open AL - Invalid Name

I Have some functions to help me deal with sound:

        static Vector3 zero = Vector3.Zero;
        static Vector3 dir = Vector3.UnitZ;
        static Vector3 up = Vector3.UnitY;
        static AudioContext context;
        static String error;
 
        public static void InitAudio()
        {
            context = new AudioContext();
            AL.Listener(ALListener3f.Position, ref zero);
            AL.Listener(ALListenerfv.Orientation, ref dir, ref up);
 
           CheckError();
        }
public static void CheckError()
        {
             error = AL.GetError().ToString();
            if (error != "NoError")
                throw new Exception(error);
        }
        public static void LoadSound(string cleanName, ref Note note)
        {
 
            AudioReader sound = new AudioReader(cleanName);
            int buffer;
            int source;
            buffer = AL.GenBuffer();
            CheckError(); // NO error
            source = AL.GenSource();
            CheckError();// No error
            AL.BufferData(buffer, sound.ReadToEnd());
            CheckError();//No error
            AL.Source( source, ALSourcei.Buffer,buffer);
 
 
            AL.Source(source, ALSource3f.Position, ref zero);
            AL.Source(source, ALSource3f.Velocity, ref dir);
            AL.Source(source, ALSourcef.Gain, 2.0f);
            CheckError(); // NO error
            AL.SourcePlay(buffer);
            CheckError(); //ERROR! Invalid Name
 
 
            AL.DeleteBuffer(buffer);
            AL.DeleteSource(source);
 
        }

I get invalid name when I try to play my sound, took the demo sound "the_ring_that_fell".

I call init and then loads the sound.

The buffer and source have both nice values after AL.GenBuffer(); and AL.GenSource();

Have I forgoten something??