【发布时间】:2014-03-20 19:44:32
【问题描述】:
我目前正在处理 SR。设计项目是一个 Windows 窗体应用程序,它允许用户插入他们的吉他并实时创建失真,并通过输入和输出播放它,并自动将其标记为 ASCII 选项卡。目前我正在尝试让实时收听部分正常工作,我的失真录音和实现工作得很好,只是在使用 ASIO 时遇到了一些问题。我看过这篇帖子How to record and playback with NAudio using AsioOut,但这对我的问题没有多大帮助,这是我的代码:
private BufferedWaveProvider buffer;
private AsioOut input;
private AsioOut output;
private void listenBtn_Click(object sender, EventArgs e)
{
input = new AsioOut(RecordInCbox.SelectedIndex);
WaveFormat format = new WaveFormat();
buffer = new BufferedWaveProvider(format);
buffer.DiscardOnBufferOverflow = true;
input.InitRecordAndPlayback(buffer, 1, 44100);
input.AudioAvailable += new EventHandler<AsioAudioAvailableEventArgs>(AudioAvailable);
//output = new AsioOut(RecordInCbox.SelectedIndex);
//output.Init(buffer);
input.Play();
//output.Play();
}
public void AudioAvailable(object sender, AsioAudioAvailableEventArgs e)
{
byte[] buf = new byte[e.SamplesPerBuffer];
e.WrittenToOutputBuffers = true;
for (int i = 0; i < e.InputBuffers.Length; i++)
{
Array.Copy(e.InputBuffers, e.OutputBuffers, 1);
Marshal.Copy(e.InputBuffers[i], buf, 0, e.SamplesPerBuffer);
buffer.AddSamples(buf, 0, buf.Length);
}
}
目前它正在获取音频并将其推入缓冲区,但输出不起作用。如果我将录音设置设置为在 windows 上听,我可以让它弹吉他,但我觉得这是不必要的,因为我希望能够执行我的失真并将其作为输出听到。谢谢!
【问题讨论】: