I'm trying to understand every single line of the following code , but my knowledge prevents me from being successful.
It's actually a piece of code taken form a java tutorial regarding the plotting of an audio signal (waveform)
In a nutshell what the code does is basically: if audio data sample size is equal to 16 and encoding type is BigEndian do this... Well.. the problem is that I'd like to be able to catch the meaning of every single code statement.. Can anyone help me ? Many thanks in advance... The original code is here: http://www.koders.com/java/fid3508156A13C80A263E7CE65C4C9D6F5D8651AF5D.aspx?s=%22David+Anderson%22 (class SamplingGraph )
The code I'd like to understand is the following:
if (format.getSampleSizeInBits() == 16) {
int nlengthInSamples = audioBytes.size() / 2;
audioData = new int[nlengthInSamples];
if (format.isBigEndian()) {
for (int i = 0; i < nlengthInSamples; i++) {
/* First byte is MSB (high order) */
int MSB = (int) audioBytes.get(2 * i);
/* Second byte is LSB (low order) */
int LSB = (int) audioBytes.get(2 * i + 1);
audioData[i] = MSB << 8 | (255 & LSB);
}
Especially how would you translate in words the following code:
audioData[i] = MSB << 8 | (255 & LSB);
...thanks again Mat