Beispiel #1
0
        public void Play(MusicAudioSource musicSource)
        {
            currentLength = Length;
            source        = musicSource;
            source.SetVolume(1f, Settings.MusicVolume * Settings.MasterVolume);

            // Queue first buffers
            for (int i = 0; i < MusicAudioBufferRotator.BufferCount - 1; i++)
            {
                source.QueueBuffer(nextBuffer());
            }
        }
Beispiel #2
0
        public AudioDevice()
        {
            device = ALC.OpenDevice(string.Empty);

            if (device.Equals(ALDevice.Null))
            {
                return;
            }

            context = ALC.CreateContext(device, new ALContextAttributes());
            ALC.MakeContextCurrent(context);

            var error = AL.GetError();

            if (error != ALError.NoError)
            {
                throw new FailingSoundDeviceException($"Failed to open audio device. Error code: {error}.");
            }

            MusicSource        = new MusicAudioSource();
            IntenseMusicSource = new MusicAudioSource();

            MiscSources = new GameAudioSource[miscSourceCount];
            for (int i = 0; i < miscSourceCount; i++)
            {
                MiscSources[i] = new GameAudioSource();
            }

            GameSources = new GameAudioSource[gameSourceCount];
            for (int i = 0; i < gameSourceCount; i++)
            {
                GameSources[i] = new GameAudioSource();
            }

            initialized = true;
        }
Beispiel #3
0
 public void Stop()
 {
     source?.Stop();
     source = null;
 }