Algorithm to convert byte array to sample array
843802Jul 14 2009 — edited Jul 17 2009Hey everyone, for the program I am making I need to make a graph that shows the correlation between samples and their amplitudes. I need to make it possible to take any audio file and use the byte array you get from its AudioInputStream to get an array of samples with the correct amplitude for each sample. It needs to work for ANY file in g711 format so the code should take into account whether or not the file is bigEndian, the number of channels, bytes per sample, etc.
The problem is that I don't even know how to do that if I'm not programming. Does anyone know a website that tells how you are supposed to figure out the amplitude of a sample if you have all the info about the file and the byte array? Or could someone just explain it to me if its not that hard? I have no idea how to do any of this.
For example, say I have a file that I know has a sample rate of 8000, 2 bytes per sample, 1 channel, 93952 frames, and 187904 bytes. I know how to get all the bytes in an array, but I have no idea what to do from there. I know I need to test if it is bigEndian but I don't know what to do if it is or if it is not. I am completely and totally stumped, I really need help.