Taken from an example with Naudio with a audio-recorder, I am trying to find out how the methods in Naudio works in order to replace a wave-file (that is being opened by a file dialog ->> cf. Question-line 1 below) with a wave-stream (cf. Question-line 2 below).
What I am trying to achieve is to plot a sourceStream-reocorded (buffer-like state) wavestream instead of a already saved wave-file in a winform chart:
private void button2_Click_1(object sender, EventArgs e)
What I am trying to achieve is to plot a sourceStream-reocorded (buffer-like state) wavestream instead of a already saved wave-file in a winform chart:
private void button2_Click_1(object sender, EventArgs e)
{
if (SourceList.SelectedItems.Count == 0) return;
int deviceNumber = SourceList.SelectedItems[0].Index;
sourceStream = new NAudio.Wave.WaveIn();
sourceStream.DeviceNumber = deviceNumber;
sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(deviceNumber).Channels);
NAudio.Wave.WaveInProvider waveIn = new NAudio.Wave.WaveInProvider(sourceStream);
waveOut = new NAudio.Wave.DirectSoundOut();
waveOut.Init(waveIn);
sourceStream.StartRecording();
waveOut.Play();
}
private void button3_Click_1(object sender, EventArgs e)
{
//// The following lines with 4 forward-slashes represents the filedialog from a button5 //// method that fitted Question-line 1:
//// SaveFileDialog save = new SaveFileDialog();
//// save.Filter = "Wave File (*.wav|*.wav;)";
//// if (save.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
//if (waveOut != null)
//{
// waveOut.Stop();
// waveOut.Dispose();
// waveOut = null;
//}
//if (sourceStream != null)
//{
// sourceStream.StopRecording();
// sourceStream.Dispose();
// sourceStream = null;
//}
textBox3.Text = "clicked2er";
Question-line 1:
NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
Question-line 2:
NAudio.Wave.WaveStream wave = new NAudio.Wave.WaveStream(new NAudio.Wave.WaveIn(sourceStream));
chart1.Series.Add("wave");
chart1.Series["wave"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
chart1.Series["waveOut"].ChartArea = "ChartArea1";
}







