I’m writing a little program to read a .wav file. According to the wav specs I’ve been looking at:
it looks like the second four bytes are a 4 byte little endian number. I think this means that the least significant byte is the first one, byte number 5, so in otherwords, I read them from left to right. From what I’ve been reading, I think I should multiply them like this:
n=bytearray[5]+(bytearray[6]*256)+(bytearray[7]*256)+(bytearray[8]*16777216)
so byte in
but that comes out to a pretty damn large number, 1,459,618,138 in decimal for a file that is only 90k long. So I think I’m making a mistake here somewhere.
for the other numbers, if I understand the difference between little endian and big endian is right to left vs left to right order of the bytes?
The array is indexed from 0, so the bytes you want are 4, 5, 6 and 7:
(Note that your third multiplier needs to be
65536, not256.)