internal LocalVoice(IVoiceFrontend client, byte id, IAudioStream audioStream, VoiceInfo voiceInfo, int channelId) { this.info = voiceInfo; this.channelId = channelId; this.opusEncoder = new OpusEncoder((SamplingRate)voiceInfo.SamplingRate, (Channels)voiceInfo.Channels, voiceInfo.Bitrate, OpusApplicationType.Voip, (POpusCodec.Enums.Delay)(voiceInfo.FrameDurationUs * 2 / 1000)); this.frontend = client; this.id = id; this.audioStream = audioStream; this.sourceSamplingRateHz = audioStream.SamplingRate; this.sourceFrameSize = this.info.FrameSize * this.sourceSamplingRateHz / (int)this.opusEncoder.InputSamplingRate; this.frameBuffer = new float[this.info.FrameSize]; if (this.sourceFrameSize == this.info.FrameSize) { this.sourceFrameBuffer = this.frameBuffer; } else { this.sourceSamplingRateHz = audioStream.SamplingRate; this.sourceFrameBuffer = new float[this.sourceFrameSize]; this.frontend.DebugReturn(DebugLevel.WARNING, "[PV] Local voice #" + this.id + " audio source frequency " + this.sourceSamplingRateHz + " and encoder sampling rate " + (int)this.opusEncoder.InputSamplingRate + " do not match. Resampling will occur before encoding."); } this.LevelMeter = new LevelMeter(this.sourceSamplingRateHz, this.info.Channels); //1/2 sec this.VoiceDetector = new VoiceDetector(this.sourceSamplingRateHz, this.info.Channels); // _debug_decoder = new OpusDecoder(this.InputSamplingRate, this.InputChannels); }
/// <summary>Creates VoiceClient instance</summary> internal VoiceClient(IVoiceFrontend frontend) { this.frontend = frontend; }