同时从两个输入设备录制音频并保存到波形文件中?

我正在尝试同时在两个不同的设备上录制音频,并且文件的输出应保存在波形文件中


使用 NAudio 我尝试解决问题,如下所示,但我仍然没有得到它


WaveInEvent waveSource1 = new WaveInEvent();

waveSource1.DeviceNumber = DeviceID1;

waveSource1.WaveFormat = new WaveFormat(44100, 2);

waveSource1.DataAvailable += new EventHandler<WaveInEventArgs>(waveSource_DataAvailable);

string tempFile1 = (@"C:\Users\Nirmalkumar\Desktop\speech1.wav");

waveFile1 = new WaveFileWriter(tempFile1, waveSource1.WaveFormat);

waveSource.StartRecording();

waveSource1.StartRecording();

Console.Beep();

int milliseconds = 5000;

Thread.Sleep(milliseconds);


waveSource.StopRecording();

waveSource1.StopRecording();

这是第一个波源


WaveInEvent waveSource = new WaveInEvent();

    waveSource.DeviceNumber = DeviceID;

    waveSource.WaveFormat = new WaveFormat(44100, 16, 2);

    waveSource.DataAvailable += new EventHandler<WaveInEventArgs>(waveSource_DataAvailable);

    string tempFile = (@"C:\Users\Nirmalkumar\Desktop\speech.wav");

    waveFile = new WaveFileWriter(tempFile, waveSource.WaveFormat);


static void waveSource_DataAvailable(object sender, WaveInEventArgs e)

{

    waveFile.Write(e.Buffer, 0, e.BytesRecorded);


}


白衣非少年
浏览 124回答 1
1回答

吃鸡游戏

我正在尝试同时在两个不同的设备上录制音频,并且文件的输出应保存在波形文件中使用 NAudio 我尝试解决问题,如下所示,但我仍然没有得到它WaveInEvent waveSource1 = new WaveInEvent();waveSource1.DeviceNumber = DeviceID1;waveSource1.WaveFormat = new WaveFormat(44100, 2);waveSource1.DataAvailable += new EventHandler<WaveInEventArgs>(waveSource_DataAvailable);string tempFile1 = (@"C:\Users\Nirmalkumar\Desktop\speech1.wav");waveFile1 = new WaveFileWriter(tempFile1, waveSource1.WaveFormat);waveSource.StartRecording();waveSource1.StartRecording();Console.Beep();int milliseconds = 5000;Thread.Sleep(milliseconds);waveSource.StopRecording();waveSource1.StopRecording();这是第一个波源WaveInEvent waveSource = new WaveInEvent();&nbsp; &nbsp; waveSource.DeviceNumber = DeviceID;&nbsp; &nbsp; waveSource.WaveFormat = new WaveFormat(44100, 16, 2);&nbsp; &nbsp; waveSource.DataAvailable += new EventHandler<WaveInEventArgs>(waveSource_DataAvailable);&nbsp; &nbsp; string tempFile = (@"C:\Users\Nirmalkumar\Desktop\speech.wav");&nbsp; &nbsp; waveFile = new WaveFileWriter(tempFile, waveSource.WaveFormat);static void waveSource_DataAvailable(object sender, WaveInEventArgs e){&nbsp; &nbsp; waveFile.Write(e.Buffer, 0, e.BytesRecorded);}
打开App,查看更多内容
随时随地看视频慕课网APP