I am working on PCM as a beginner, and I am using Naudio library. So I was wondering that does the storage of PCM data depends on Little Endian and Big Endian or if not the storage depends then does the memory addressing depends on this Big and Little Endian, because a PCM data got Least significant byte and ofcourse most significant byte and as I know that Little Endian and Big Endian got different way of storing those bytes into memory therefore reading the data from disk into memory may produce wrong values until I reverse the array and then convert it into short
value.
Just to make you understand what I am talking about, here is a short example:
A very short PCM data, of just 4 Bytes:
Address Value
1000 90
1001 AB
1002 12
1003 CD
This is the storage in a in big endian. and the following is the storage in little Endian
Address Value
1000 CD
1001 12
1002 AB
1003 90
so does this reversing of bytes happen when you read PCM using Naudio? because I check if the BitConverter is Little Endian or not, according to that I reverse my array of bytes, kind of like this:
Int16 Left_Sample = BitConverter.ToInt16(Buffer, i);
Int16 Right_Sample = BitConverter.ToInt16(Buffer, i + 2);
Int16 Final_Sample = (Int16)(0.5f * ((float)Left_Sample + (float)Right_Sample));
byte[] Final_Byte = BitConverter.GetBytes(Final_Sample);
if (BitConverter.IsLittleEndian){ Array.Reverse(Final_Byte); }
So in summary:
Q: Does the Big and Little Endian affects the byte storage?
Q: Do I need to use if(BitConverter.IsLittleEndian)
statement to reverse the array?