Ejemplo n.º 1
0
        private void UpdatePositionalPlayback()
        {
            var session = _player.Session;

            if (session.HasValue)
            {
                //Unconditionally copy across the playback options into the cache once a frame.
                _cachedPlaybackOptions = session.Value.PlaybackOptions;

                if (((IVoicePlaybackInternal)this).AllowPositionalPlayback && _cachedPlaybackOptions.IsPositional)
                {
                    if (_savedSpatialBlend.HasValue)
                    {
                        Log.Debug("Changing to positional playback for {0}", PlayerName);
                        AudioSource.spatialBlend = _savedSpatialBlend.Value;
                        _savedSpatialBlend       = null;
                    }
                }
                else
                {
                    if (!_savedSpatialBlend.HasValue)
                    {
                        Log.Debug("Changing to non-positional playback for {0}", PlayerName);
                        _savedSpatialBlend       = AudioSource.spatialBlend;
                        AudioSource.spatialBlend = 0;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Update()
        {
            if (!_player.HasActiveSession)
            {
                // We're not playing anything at the moment. Try to get a session to play.
                var s = _sessions.TryDequeueSession();
                if (s.HasValue)
                {
                    _cachedPlaybackOptions = s.Value.PlaybackOptions;
                    _player.Play(s.Value);
                    AudioSource.Play();
                }
                else
                {
                    // No session was available to start playing. Stop the audio source playing to preserve
                    // limited "real voices" in the Unity audio mixer.
                    if (AudioSource.isPlaying)
                    {
                        AudioSource.Stop();
                    }
                }
            }

            //Sanity check that the AudioSource has not been muted. Doing this will stop the playback pipeline from running, causing encoded audio to backup as it waits for playback.
            if (AudioSource.mute)
            {
                Log.Warn("Voice AudioSource was muted, unmuting source. " +
                         "To mute a specific Dissonance player see: https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#islocallymuted-bool");
                AudioSource.mute = false;
            }

            //Enable or disable positional playback depending upon if it's avilable for this speaker
            UpdatePositionalPlayback();
        }
Ejemplo n.º 3
0
        public void Update()
        {
            if (!_player.HasActiveSession)
            {
                //We're not playing anything, so play the next session (if there is one ready)
                var s = _sessions.TryDequeueSession();
                if (s.HasValue)
                {
                    _cachedPlaybackOptions = s.Value.PlaybackOptions;
                    _player.Play(s.Value);
                }
            }
            else
            {
                //We're playing something, adjust playback speed according to the player
                AudioSource.pitch = _player.CorrectedPlaybackSpeed;
            }

            //Sanity check that the AudioSource has not been muted. Doing this will stop the playback pipeline from running, causing encoded audio to backup as it waits for playback.
            if (AudioSource.mute)
            {
                Log.Warn("Voice AudioSource was muted, unmuting source. To mute a specific Dissonance player see: https://dissonance.readthedocs.io/en/latest/Reference/Other/VoicePlayerState/#islocallymuted-bool");
                AudioSource.mute = false;
            }

            //Enable or disable positional playback depending upon if it's avilable for this speaker
            UpdatePositionalPlayback();
        }
Ejemplo n.º 4
0
        public void Update()
        {
            if (!_player.HasActiveSession)
            {
                //We're not playing anything, so play the next session (if there is one ready)
                var s = _sessions.TryDequeueSession();
                if (s.HasValue)
                {
                    _cachedPlaybackOptions = s.Value.PlaybackOptions;
                    _player.Play(s.Value);
                }
            }
            else
            {
                //We're playing something, adjust playback speed according to the player
                AudioSource.pitch = _player.CorrectedPlaybackSpeed;
            }

            //Enable or disable positional playback depending upon if it's avilable for this speaker
            UpdatePositionalPlayback();
        }