private void Setup() { this.voice = CreateLocalVoiceAudioAndSource(); if (this.voice == LocalVoiceAudioDummy.Dummy) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("Local input source setup and voice stream creation failed. No recording or transmission will be happening. See previous error log messages for more details."); } return; } if (this.ReactOnSystemChanges && !this.subscribedToSystemChanges) { AudioSettings.OnAudioConfigurationChanged += this.OnAudioConfigChanged; this.subscribedToSystemChanges = true; } if (this.VoiceDetector != null) { this.VoiceDetector.Threshold = this.voiceDetectionThreshold; this.VoiceDetector.ActivityDelayMs = this.voiceDetectionDelayMs; this.VoiceDetector.On = this.voiceDetection; } this.voice.InterestGroup = this.InterestGroup; this.voice.DebugEchoMode = DebugEchoMode; this.voice.Encrypt = Encrypt; this.voice.Reliable = this.ReliableMode; this.RequiresRestart = false; this.isRecording = true; SendPhotonVoiceCreatedMessage(); this.voice.TransmitEnabled = this.TransmitEnabled; }
private void RemoveVoice(bool sendUnityMsg) { if (this.subscribedToSystemChanges) { this.UnsubscribeFromSystemChanges(); } this.GetThresholdFromDetector(); this.GetStatusFromDetector(); this.GetActivityDelayFromDetector(); if (this.voice != LocalVoiceAudioDummy.Dummy) { this.interestGroup = this.voice.InterestGroup; if (this.debugEchoMode && this.interestGroup != 0) { this.debugEchoMode = false; } this.voice.RemoveSelf(); this.voice = LocalVoiceAudioDummy.Dummy; } if (this.inputSource != null) { this.inputSource.Dispose(); this.inputSource = null; } if (sendUnityMsg) { this.gameObject.SendMessage("PhotonVoiceRemoved", SendMessageOptions.DontRequireReceiver); } this.isRecording = false; this.RequiresRestart = false; }
float[] GetLocalVoiceBuffer() { PhotonVoiceRecorder pvn = GetComponent <PhotonVoiceRecorder>(); System.Reflection.FieldInfo voiceFieldInfo = typeof(PhotonVoiceRecorder).GetField("voice", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); LocalVoice localVoice = (LocalVoice)voiceFieldInfo.GetValue(pvn); System.Reflection.FieldInfo bufferFieldInfo = typeof(LocalVoice).GetField("sourceFrameBuffer", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); return((float[])bufferFieldInfo.GetValue(localVoice)); }
private void Setup() { WebRtcAudioDsp dsp = gameObject.GetComponent <WebRtcAudioDsp>(); if (dsp != null && dsp.isActiveAndEnabled) { forceShort = true; if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Type Conversion set to Short. Audio samples will be converted if source samples types differ."); } } else if (forceShort) { forceShort = false; if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Type Conversion disabled. Audio samples will not be converted if source samples types differ."); } } this.voice = CreateLocalVoiceAudioAndSource(); if (this.voice == LocalVoiceAudioDummy.Dummy) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("Local input source setup and voice stream creation failed. No recording or transmission will be happening. See previous error log messages for more details."); } return; } if (this.ReactOnSystemChanges && !this.subscribedToSystemChanges) { AudioSettings.OnAudioConfigurationChanged += this.OnAudioConfigChanged; this.subscribedToSystemChanges = true; } if (this.VoiceDetector != null) { this.VoiceDetector.Threshold = this.voiceDetectionThreshold; this.VoiceDetector.ActivityDelayMs = this.voiceDetectionDelayMs; this.VoiceDetector.On = this.voiceDetection; } this.voice.InterestGroup = this.InterestGroup; this.voice.DebugEchoMode = DebugEchoMode; this.voice.Encrypt = Encrypt; this.voice.Reliable = this.ReliableMode; this.RequiresRestart = false; this.isRecording = true; SendPhotonVoiceCreatedMessage(); this.voice.TransmitEnabled = this.TransmitEnabled; }
// Message sent by Recorder private void PhotonVoiceCreated(PhotonVoiceCreatedParams p) { if (!this.enabled) { return; } if (this.recorder != null && this.recorder.SourceType != Recorder.InputSourceType.Microphone) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("WebRtcAudioDsp should be used with Recorder.SourceType == Recorder.InputSourceType.Microphone only."); } this.enabled = false; return; } this.localVoice = p.Voice; if (this.localVoice.Info.Channels != 1) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("Only mono audio signals supported."); } this.enabled = false; return; } if (!(this.localVoice is LocalVoiceAudioShort)) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("Only short audio voice supported."); } this.enabled = false; return; } // can't access the AudioSettings properties in InitAEC if it's called from not main thread this.reverseChannels = channelsMap[AudioSettings.speakerMode]; this.outputSampleRate = AudioSettings.outputSampleRate; this.Init(); LocalVoiceAudioShort v = this.localVoice as LocalVoiceAudioShort; v.AddPostProcessor(this.proc); this.SetOutputListener(); if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Initialized"); } }
private void Setup() { this.voice = CreateLocalVoiceAudioAndSource(); if (this.VoiceDetector != null) { this.VoiceDetector.Threshold = VoiceDetectionThreshold; this.VoiceDetector.ActivityDelayMs = this.VoiceDetectionDelayMs; this.VoiceDetector.On = VoiceDetection; } this.voice.Group = AudioGroup; this.voice.DebugEchoMode = DebugEchoMode; this.voice.Encrypt = Encrypt; this.voice.Reliable = this.ReliableMode; this.RequiresInit = false; this.IsInitialized = true; SendPhotonVoiceCreatedMessage(); this.voice.TransmitEnabled = this.TransmitEnabled; }
// Token: 0x06000065 RID: 101 RVA: 0x00003970 File Offset: 0x00001B70 public void UpdateAudioSource() { if (this.voice != LocalVoiceAudio.Dummy) { this.audioSource.Dispose(); this.voice.RemoveSelf(); base.gameObject.SendMessage("PhotonVoiceRemoved", SendMessageOptions.DontRequireReceiver); bool debugEchoMode = this.DebugEchoMode; this.DebugEchoMode = false; LocalVoice localVoice = this.voice; this.voice = this.createLocalVoiceAudioAndSource(); this.voice.Group = localVoice.Group; this.voice.Transmit = localVoice.Transmit; this.voiceAudio.VoiceDetector.On = this.voiceAudio.VoiceDetector.On; this.voiceAudio.VoiceDetector.Threshold = this.voiceAudio.VoiceDetector.Threshold; this.sendPhotonVoiceCreatedMessage(); this.DebugEchoMode = debugEchoMode; } }
private void Setup() { if (this.ReactOnSystemChanges && !this.subscribedToSystemChanges) { AudioSettings.OnAudioConfigurationChanged += this.OnAudioConfigChanged; this.subscribedToSystemChanges = true; } this.voice = CreateLocalVoiceAudioAndSource(); if (this.VoiceDetector != null) { this.VoiceDetector.Threshold = VoiceDetectionThreshold; this.VoiceDetector.ActivityDelayMs = this.VoiceDetectionDelayMs; this.VoiceDetector.On = VoiceDetection; } this.voice.InterestGroup = this.InterestGroup; this.voice.DebugEchoMode = DebugEchoMode; this.voice.Encrypt = Encrypt; this.voice.Reliable = this.ReliableMode; this.RequiresInit = false; this.IsInitialized = true; SendPhotonVoiceCreatedMessage(); this.voice.TransmitEnabled = this.TransmitEnabled; }
// Message sent by Recorder private void PhotonVoiceCreated(Recorder.PhotonVoiceCreatedParams p) { this.localVoice = p.Voice; if (this.localVoice.Info.Channels != 1) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("Only mono audio signals supported."); } this.enabled = false; return; } if (!(this.localVoice is LocalVoiceAudioShort)) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("Only short audio voice supported (Set Recorder.TypeConvert option)."); } this.enabled = false; return; } // can't access the AudioSettings properties in InitAEC if it's called from not main thread this.reverseChannels = this.channelsMap[AudioSettings.speakerMode]; this.outputSampleRate = AudioSettings.outputSampleRate; this.Init(); LocalVoiceAudioShort v = this.localVoice as LocalVoiceAudioShort; v.AddPostProcessor(this.proc); this.SetOutputListener(); if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Initialized"); } }