add-type -path 'C:/Users/xxxxx/Downloads/NAudio-Release/NAudio.dll' $devices = new-object NAudio.CoreAudioApi.MMDeviceEnumerator $defaultDevice = $devices.GetDefaultAudioEndpoint([NAudio.CoreAudioApi.DataFlow]::Render, [NAudio.CoreAudioApi.Role]::Multimedia) $defaultDeviceId = $defaultDevice.ID -replace '{.+}\.{(.+)}$', '$1' $waveIn = new-object NAudio.Wave.WasapiLoopbackCapture $waveOut = new-object NAudio.Wave.DirectSoundOut($defaultDeviceId, 100) $waveInProvider = new-object NAudio.Wave.WaveInProvider($waveIn) $waveProvider16 = new-object NAudio.Wave.WaveFloatTo16Provider($waveInProvider) $monoProvider16 = new-object NAudio.Wave.StereoToMonoProvider16($waveProvider16) $monoProvider16.leftVolume = 1 $monoProvider16.rightVolume = 1 $waveOut.init($monoProvider16) $waveOut.play() $waveIn.startRecording() $waveIn = new-object NAudio.Wave.WasapiLoopbackCapture $waveOut = new-object NAudio.Wave.DirectSoundOut($defaultDeviceId, 100) $waveProvider16 = new-object NAudio.Wave.WaveFloatTo16Provider($waveInProvider) $monoProvider16 = new-object NAudio.Wave.StereoToMonoProvider16($waveProvider16) $monoProvider16.leftVolume = 1 $monoProvider16.rightVolume = 1 $waveOut.init($monoProvider16) $waveOut.play() $waveIn.startRecording() $waveIn.stopRecording() $waveOut.stop() Source: https://habr.com/ru/post/201870/
All Articles