private void ProcessData(byte[] buffer, int bytesRecorded) { for (int index = 0; index < bytesRecorded; index += 2) { activeWindow.AddSample(buffer, index); if (activeWindow.Done) { windows.Add(activeWindow); activeWindow = new Window(); } } }
/// <summary> /// Read audio-file and return measurements /// </summary> /// <returns> Measurements of audio-file </returns> public Measurements[] measureInput(string fileName) { activeWindow = new Window(); windows = new List<Window>(); if (fileName.EndsWith(".mp3")) { using (Mp3FileReader reader = new Mp3FileReader(fileName)) { ProcessFile(reader); } } else if (fileName.EndsWith(".wav")) { using (WaveFileReader reader = new WaveFileReader(fileName)) { ProcessFile(reader); } } return GetFileMeasurements(); }
public void ProcessNewData(byte[] buffer, int bytesRecorded) { for (int index = 0; index < bytesRecorded; index += 2) { activeWindow.AddSample(buffer, index); if (activeWindow.Done) { windows.Add(activeWindow); waveChart.Series[0].Points.Clear(); for (int i = 0; i < activeWindow.blocks[0].intensities.Length; i++) { waveChart.Series[0].Points.AddXY(i * GlobalVariables.FrequencyOffset, activeWindow.blocks[0].intensities[i]); } activeWindow = new Window(); } } }
private void startRecordingButton_Click(object sender, EventArgs e) { //arrayPointer = 0; waveIn = new WaveIn(); waveIn.WaveFormat = new WaveFormat(sampleRate, 2); waveIn.DataAvailable += new EventHandler<WaveInEventArgs>(NewDataAvailable); activeWindow = new Window(); windows = new List<Window>(); try { waveIn.StartRecording(); stopRecordingButton.Enabled = true; startRecordingButton.Enabled = false; } catch { MessageBox.Show("No recording device found!"); } }