private void _updateAudioContext() { _dataWasSent = false; _stretcher?.Dispose(); var speedRatio = (_renderer.RefreshRate / _config.TargetFps); Console.Write(speedRatio); _stretcher = new RubberBandStretcher( _config.SampleRate, 2, RubberBandStretcher.Options.ProcessRealTime, 1 / speedRatio, speedRatio ); _latencyCounter = _stretcher.GetLatency(); if (_resamplerState != IntPtr.Zero) { SampleRate.src_delete(_resamplerState); } if (_config.SampleRate != (int)_currentSystemAvInfo.Timing.SampleRate) { _resampleNeeded = true; _audioResampleRatio = (_config.SampleRate / _currentSystemAvInfo.Timing.SampleRate); _resamplerState = SampleRate.src_new(SampleRate.Quality.SRC_SINC_BEST_QUALITY, 2, out var error); if (error > 0) { Logger.Error("Error initializing resampler: '{0}'", SampleRate.src_strerror(error)); } Logger.Debug("Audio Resample Ratio: {0}", _audioResampleRatio); } else { _resampleNeeded = false; Logger.Debug("Resampling not needed"); } }