录制某个应用程序的声音

我想知道有没有办法记录某个应用程序的声音? 我搜索了一段时间,但没有找到一些有用的信息。 所以现在我正在使用NAudio库来录制WASAPI环回和麦克风声音,将它们混合在一起并使用以下代码保存到mp3文件:

Silence = new WaveOut(); Silence.Init(new SignalGenerator() { Gain = 0 }); Silence.Play(); SoundOut = new WasapiLoopbackCapture(); SoundOut.DataAvailable += SoundOut_DataAvailable; SoundOut.StartRecording(); SoundOutBuffer = new BufferedWaveProvider(SoundOut.WaveFormat); SoundIn = new WaveIn(); SoundIn.WaveFormat = SoundOut.WaveFormat; SoundIn.DataAvailable += SoundIn_DataAvailable; SoundIn.StartRecording(); SoundInBuffer = new BufferedWaveProvider(SoundIn.WaveFormat); List Sources = new List { SoundOutBuffer.ToSampleProvider(), SoundInBuffer.ToSampleProvider() }; Mixer = new MixingSampleProvider(Sources); Sampler = new SampleToWaveProvider16(Mixer); MP3Writer = new LameMP3FileWriter("File.mp3", Mixer.WaveFormat, 128); 

此外,我发现CSCore库看起来像NAudio有一些额外的function,但完全缺乏文档。 可能是CSCore有我需要的function吗?

没有“合法”API可用于记录应用程序输出,旨在完全解决相关任务。

有两种黑客风格的方法来实现目标:

  1. 要从环回设备进行记录,数据将是来自所有应用程序的混合输出,而不仅仅是特定的数据
  2. 挂钩应用程序中的音频API,以拦截应用程序请求以将数据发送到音频输出设备,并作为“中间主要”记录它或以其他方式复制到别处

第一个是相对简单的,另一个是针对API和应用程序的黑客攻击,并且很难做到长话短说。

也可以看看:

  • 录制应用程序的音频输出