コード例 #1
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();
        }
コード例 #2
0
        public void Update()
        {
            if (!_player.HasActiveSession)
            {
                var s = _sessions.TryDequeueSession();
                if (s.HasValue)
                {
                    _player.Play(s.Value);
                }
            }

            UpdatePositionalPlayback();
        }
コード例 #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;
            }

            //Enable or disable positional playback depending upon if it's avilable for this speaker
            UpdatePositionalPlayback();
        }
コード例 #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);
                }
            }

            //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();
        }