Exemplo n.º 1
0
        public SoundManager()
        {
            loadedSounds      = new List <Sound>();
            streamingThread   = null;
            categoryModifiers = null;

            sourcePools = new SoundSourcePool[2];
            playingChannels[(int)SourcePoolIndex.Default] = new SoundChannel[SOURCE_COUNT];
            playingChannels[(int)SourcePoolIndex.Voice]   = new SoundChannel[16];

            string deviceName = GameMain.Config.AudioOutputDevice;

            if (string.IsNullOrEmpty(deviceName))
            {
                deviceName = Alc.GetString((IntPtr)null, Alc.DefaultDeviceSpecifier);
            }

#if (!OSX)
            var audioDeviceNames = Alc.GetStringList((IntPtr)null, Alc.AllDevicesSpecifier);
            if (audioDeviceNames.Any() && !audioDeviceNames.Any(n => n.Equals(deviceName, StringComparison.OrdinalIgnoreCase)))
            {
                deviceName = audioDeviceNames[0];
            }
#endif
            GameMain.Config.AudioOutputDevice = deviceName;

            InitializeAlcDevice(deviceName);

            ListenerPosition     = Vector3.Zero;
            ListenerTargetVector = new Vector3(0.0f, 0.0f, 1.0f);
            ListenerUpVector     = new Vector3(0.0f, -1.0f, 0.0f);

            CompressionDynamicRangeGain = 1.0f;
        }