什么在工作-保存文件
什么不是:-音频文件是空白的(作为一个长度,但没有可听到的声音,也就是声音是空白的)编辑(为了清晰):文件的权重不是0。
已经用winmm.dll实现了一个解决方案,但却在寻找比16位质量更好的东西。已经对NAudio dll使用了libmp3lame包装器,所以使用NAudio是可行的选择。
public void Start()
{
if(this.isInitialized)
{
string outputFilePath = "...";
this.capture = new NAudio.Wave.WasapiLoopbackCapture();
this.writer = new NAudio.Wave.WaveFileWriter(outputFilePath, this.capture.WaveFormat);
this.capture.DataAvailable += (s, a) =>
{
this.writer.Write(a.Buffer, 0, a.BytesRecorded);
};
this.capture.RecordingStopped += (s, a) =>
{
this.writer.Dispose();
this.writer = null;
this.capture.Dispose();
};
this.capture.StartRecording();
}
}
public void StopAndSave()
{
if(this.isInitialized)
{
this.capture.StopRecording();
}
}预期:以WAV音频文件格式记录音频
this.isInitialized检查路径和文件命名约定。因为保存到预期位置的文件没有添加代码。此代码部分正按预期工作。
注意-使用NAudio 1.8.5 -目标系统是Win10 x64 pro
发布于 2019-01-23 13:03:54
您正在使用WasapiLoopbackCapture,它试图捕获正在计算机上播放的音频。如果您想要捕获输入设备(如麦克风),则应该使用WasapiCapture。
https://stackoverflow.com/questions/54029039
复制相似问题