Example #1
0
        public void SetListenerPosition(WPos position)
        {
            // Move the listener out of the plane so that sounds near the middle of the screen aren't too positional
            AL10.alListener3f(AL10.AL_POSITION, position.X, position.Y, position.Z + 2133);

            var orientation = new[] { 0f, 0f, 1f, 0f, -1f, 0f };

            AL10.alListenerfv(AL10.AL_ORIENTATION, orientation);
            AL10.alListenerf(EFX.AL_METERS_PER_UNIT, .01f);
        }
Example #2
0
        public OpenALDevice()
        {
            string envDevice = Environment.GetEnvironmentVariable("FNA_AUDIO_DEVICE_NAME");

            if (String.IsNullOrEmpty(envDevice))
            {
                /* Be sure ALC won't explode if the variable doesn't exist.
                 * But, fail if the device name is wrong. The user needs to know
                 * if their environment variable was incorrect.
                 * -flibit
                 */
                envDevice = String.Empty;
            }
            alDevice = ALC10.alcOpenDevice(envDevice);
            if (CheckALCError() || alDevice == IntPtr.Zero)
            {
                throw new InvalidOperationException("Could not open audio device!");
            }

            int[] attribute = new int[0];
            alContext = ALC10.alcCreateContext(alDevice, attribute);
            if (CheckALCError() || alContext == IntPtr.Zero)
            {
                Dispose();
                throw new InvalidOperationException("Could not create OpenAL context");
            }

            ALC10.alcMakeContextCurrent(alContext);
            if (CheckALCError())
            {
                Dispose();
                throw new InvalidOperationException("Could not make OpenAL context current");
            }

            float[] ori = new float[]
            {
                0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f
            };
            AL10.alListenerfv(AL10.AL_ORIENTATION, ori);
            AL10.alListener3f(AL10.AL_POSITION, 0.0f, 0.0f, 0.0f);
            AL10.alListener3f(AL10.AL_VELOCITY, 0.0f, 0.0f, 0.0f);
            AL10.alListenerf(AL10.AL_GAIN, 1.0f);

            EFX.alGenFilters(1, out INTERNAL_alFilter);

            // FIXME: Remove for FNA 16.11! -flibit
            if (!AL10.alIsExtensionPresent("AL_SOFT_gain_clamp_ex"))
            {
                FNALoggerEXT.LogWarn("AL_SOFT_gain_clamp_ex not found!");
                FNALoggerEXT.LogWarn("Update your OpenAL Soft library!");
            }
        }
Example #3
0
        public OpenALDevice()
        {
            string envDevice = Environment.GetEnvironmentVariable("FNA_AUDIO_DEVICE_NAME");

            if (String.IsNullOrEmpty(envDevice))
            {
                /* Be sure ALC won't explode if the variable doesn't exist.
                 * But, fail if the device name is wrong. The user needs to know
                 * if their environment variable was incorrect.
                 * -flibit
                 */
                envDevice = String.Empty;
            }
            alDevice = ALC10.alcOpenDevice(envDevice);
            if (CheckALCError() || alDevice == IntPtr.Zero)
            {
                throw new InvalidOperationException("Could not open audio device!");
            }

            int[] attribute = new int[0];
            alContext = ALC10.alcCreateContext(alDevice, attribute);
            if (CheckALCError() || alContext == IntPtr.Zero)
            {
                Dispose();
                throw new InvalidOperationException("Could not create OpenAL context");
            }

            ALC10.alcMakeContextCurrent(alContext);
            if (CheckALCError())
            {
                Dispose();
                throw new InvalidOperationException("Could not make OpenAL context current");
            }

            float[] ori = new float[]
            {
                0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f
            };
            AL10.alListenerfv(AL10.AL_ORIENTATION, ori);
            AL10.alListener3f(AL10.AL_POSITION, 0.0f, 0.0f, 0.0f);
            AL10.alListener3f(AL10.AL_VELOCITY, 0.0f, 0.0f, 0.0f);
            AL10.alListenerf(AL10.AL_GAIN, 1.0f);

            // We do NOT use automatic attenuation! XNA does not do this!
            AL10.alDistanceModel(AL10.AL_NONE);

            EFX.alGenFilters(1, out INTERNAL_alFilter);
        }
Example #4
0
        private OpenALDevice()
        {
            alDevice = ALC10.alcOpenDevice(string.Empty);
            if (CheckALCError("Could not open AL device") || alDevice == IntPtr.Zero)
            {
                throw new Exception("Could not open audio device!");
            }

            int[] attribute = new int[0];
            alContext = ALC10.alcCreateContext(alDevice, attribute);
            if (CheckALCError("Could not create OpenAL context") || alContext == IntPtr.Zero)
            {
                Dispose();
                throw new Exception("Could not create OpenAL context");
            }

            ALC10.alcMakeContextCurrent(alContext);
            if (CheckALCError("Could not make OpenAL context current"))
            {
                Dispose();
                throw new Exception("Could not make OpenAL context current");
            }

            float[] ori = new float[]
            {
                0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f
            };
            AL10.alListenerfv(AL10.AL_ORIENTATION, ori);
            AL10.alListener3f(AL10.AL_POSITION, 0.0f, 0.0f, 0.0f);
            AL10.alListener3f(AL10.AL_VELOCITY, 0.0f, 0.0f, 0.0f);
            AL10.alListenerf(AL10.AL_GAIN, 1.0f);

            // We do NOT use automatic attenuation! XNA does not do this!
            AL10.alDistanceModel(AL10.AL_NONE);

            instancePool        = new List <SoundEffectInstance>();
            dynamicInstancePool = new List <DynamicSoundEffectInstance>();
        }