I get some big chunks of audio samples pushed by the sound card.
I want to start from the beginning of the chunk and apply a function on part of the chunk. This function is checking zero-crossing rate.
I thought of copying a part of the chunk to temporary buffer - something like a shifted buffer. And always pushing new sample to the temp buffer. I don't want to miss samples comes from the sound card(so that the previous bytes that have not been checked yet won't run over).
What is the best way to generate such a case?
This is how my event of audio samples from sound card look like:
void myWaveIn_DataAvailable(object sender, WaveInEventArgs e)
{
for (int index = 0; index < e.BytesRecorded; index += 2)//Here I convert in a loop the stream into floating number samples
{
short sample = (short)((e.Buffer[index + 1] << 8) |
e.Buffer[index + 0]);
SamplesBuf.Add = (sample / 32768f);//IEEE 32 floating number
}
//Do some processing on SamplesBuf
}