Пример #1
0
        public AudioDevice(string deviceName)
        {
            if (deviceName != null && !AvailableDevices.Contains(deviceName))
            {
                throw new InvalidOperationException(string.Format("AudioDevice \"{0}\" does not exist.", deviceName));
            }

            Context = new OpenTK.Audio.AudioContext(deviceName, 0, 15, true, true, AudioContext.MaxAuxiliarySends.UseDriverDefault);
            CheckAlcError();
            deviceHandle = Alc.GetContextsDevice(Alc.GetCurrentContext());
            CheckAlcError();
            Efx = new EffectsExtension();
            CheckAlcError();

            int[] val = new int[4];
            DeviceName    = Context.CurrentDevice;
            VendorName    = AL.Get(ALGetString.Vendor);
            Renderer      = AL.Get(ALGetString.Renderer);
            DriverVersion = AL.Get(ALGetString.Version);
            int major, minor;

            Alc.GetInteger(deviceHandle, AlcGetInteger.MajorVersion, 1, val);
            major = val[0];
            Alc.GetInteger(deviceHandle, AlcGetInteger.MinorVersion, 1, val);
            minor   = val[0];
            Version = new Version(major, minor);
            Alc.GetInteger(deviceHandle, AlcGetInteger.EfxMajorVersion, 1, val);
            major = val[0];
            Alc.GetInteger(deviceHandle, AlcGetInteger.EfxMinorVersion, 1, val);
            minor      = val[0];
            EfxVersion = new Version(major, minor);
            Alc.GetInteger(deviceHandle, AlcGetInteger.EfxMaxAuxiliarySends, 1, val);
            MaxRoutes  = val[0];
            Extensions = new List <string>(AL.Get(ALGetString.Extensions).Split(' ')).AsReadOnly();

            AL.DistanceModel(ALDistanceModel.ExponentDistance);

            CheckAudioCapabilities(LogLevel.Verbose);
            LogDiagnostics(LogLevel.Verbose);

            Factory  = new AudioFactory(this);
            Listener = new AudioListener(this);
            Listener.Orientation(Vector3.UnitY, Vector3.UnitZ);

            updateTaskCancelation = new CancellationTokenSource();
            updateTask            = Task.Factory.StartNew(Update);
        }
Пример #2
0
        public static bool LoadReverbToFX(TR_AUDIO_FX effectID, EffectsExtension.EfxEaxReverb reverb)
        {
            var effect = FXManager.ALEffect[(int) effectID];

            if(EffectsExtension.IsEffect(effect))
            {
                EffectsExtension.Effect(effect, EfxEffecti.EffectType, (int)EfxEffectType.Reverb);

                EffectsExtension.Effect(effect, EfxEffectf.ReverbDensity, reverb.Density);
                EffectsExtension.Effect(effect, EfxEffectf.ReverbDiffusion, reverb.Diffusion);
                EffectsExtension.Effect(effect, EfxEffectf.ReverbGain, reverb.Gain);
                EffectsExtension.Effect(effect, EfxEffectf.ReverbGainHF, reverb.GainHF);
                EffectsExtension.Effect(effect, EfxEffectf.ReverbDecayTime, reverb.DecayTime);
                EffectsExtension.Effect(effect, EfxEffectf.ReverbDecayHFRatio, reverb.DecayHFRatio);
                EffectsExtension.Effect(effect, EfxEffectf.ReverbReflectionsGain, reverb.ReflectionsGain);
                EffectsExtension.Effect(effect, EfxEffectf.ReverbReflectionsDelay, reverb.ReflectionsDelay);
                EffectsExtension.Effect(effect, EfxEffectf.ReverbLateReverbGain, reverb.LateReverbGain);
                EffectsExtension.Effect(effect, EfxEffectf.ReverbLateReverbDelay, reverb.LateReverbDelay);
                EffectsExtension.Effect(effect, EfxEffectf.ReverbAirAbsorptionGainHF, reverb.AirAbsorptionGainHF);
                EffectsExtension.Effect(effect, EfxEffectf.ReverbRoomRolloffFactor, reverb.RoomRolloffFactor);
                EffectsExtension.Effect(effect, EfxEffecti.ReverbDecayHFLimit, reverb.DecayHFLimit);
            }
            else
            {
                Sys.DebugLog(LOG_FILENAME, "OpenAL error: no effect {0}", effect);
                return false;
            }

            return true;
        }