Naudio - putting audio stream into values [-1,1]
- by denonth
Hi all I need to put my audio stream into values of [-1,1].
Can someone tell me a good approach. I was reading byte array and float array from stream but I don't know what to do next.
Here is my code:
float[] bytes=new float[stream.Length];
float biggest= 0;
for (int i = 0; i < stream.Length; i++)
{
bytes[i] = (byte)stream.ReadByte();
if (bytes[i] > biggest)
{
biggest=bytes[i];
}
}
and I don't know how to put values into stream. Because byte is only positive values. And I need to have from [-1,1]
for (int i = 0; i < bytes.Count(); i++)
{
bytes[i] = (byte)(bytes[i] * (1 / biggest));
}