private void PhotonVoiceCreated(PhotonVoiceCreatedParams photonVoiceCreatedParams) { VoiceInfo voiceInfo = photonVoiceCreatedParams.Voice.Info; int bitsPerSample = 32; if (photonVoiceCreatedParams.Voice is LocalVoiceAudioShort) { bitsPerSample = 16; } string filePath = this.GetFilePath(); this.wavWriter = new WaveWriter(filePath, new WaveFormat(voiceInfo.SamplingRate, bitsPerSample, voiceInfo.Channels)); if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Outgoing stream, output file path: {0}", filePath); } if (photonVoiceCreatedParams.Voice is LocalVoiceAudioFloat) { LocalVoiceAudioFloat localVoiceAudioFloat = photonVoiceCreatedParams.Voice as LocalVoiceAudioFloat; localVoiceAudioFloat.AddPreProcessor(new OutgoingStreamSaverFloat(this.wavWriter)); } else if (photonVoiceCreatedParams.Voice is LocalVoiceAudioShort) { LocalVoiceAudioShort localVoiceAudioShort = photonVoiceCreatedParams.Voice as LocalVoiceAudioShort; localVoiceAudioShort.AddPreProcessor(new OutgoingStreamSaverShort(this.wavWriter)); } }
// 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"); } }
// Message sent by Recorder private void PhotonVoiceCreated(PhotonVoiceCreatedParams p) { if (p.Voice is LocalVoiceAudioFloat) { LocalVoiceAudioFloat v = p.Voice as LocalVoiceAudioFloat; this.floatProcessor = new MicAmplifierFloat(this.AmplificationFactor, this.BoostValue); v.AddPostProcessor(this.floatProcessor); } else if (p.Voice is LocalVoiceAudioShort) { LocalVoiceAudioShort v = p.Voice as LocalVoiceAudioShort; this.shortProcessor = new MicAmplifierShort((short)this.AmplificationFactor, (short)this.BoostValue); //this.shortProcessor = new SimpleAmplifierShortProcessor((short)(this.AmplificationFactor* short.MaxValue), (short)(this.boostValue * short.MaxValue)); v.AddPostProcessor(this.shortProcessor); } else if (this.Logger.IsErrorEnabled) { this.Logger.LogError("LocalVoice object has unexpected value/type: {0}", p.Voice == null ? "null" : p.Voice.GetType().ToString()); } }
// 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"); } }