added comments

This commit is contained in:
Harrison Deng 2018-01-11 00:14:57 -06:00
parent 193f972d01
commit 4d6cbaa652

View File

@ -5,7 +5,6 @@ import static org.lwjgl.openal.AL10.*;
import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL11;
import com.badlogic.gdx.Gdx;
@ -106,30 +105,36 @@ public class Visualizer extends Widget implements Disposable {
}
vis.getAudioPCM()[sid] /= Short.MAX_VALUE+1f;
}
readWindowIndex++;
//Take down original buffer position so we don't need to sync again after...
int originalPos = buffer.position();
//Begin comparison
buffer.rewind();
compareBuffer.rewind();
if (compareBuffer.compareTo(buffer) != 0) {
prevBuffer.clear();
prevBuffer.put(compareBuffer);
System.out.println("Buffer switched: " + prevBuffer.get(5) + "-" + buffer.get(5) + "-" + compareBuffer.get(5));
} else {
bufferChanged();
}
//Begin copying current buffer to the comparison buffer
compareBuffer.clear();
compareBuffer.put(buffer);
compareBuffer.flip();
//Reset buffer to proper position.
buffer.position(originalPos);
readWindowIndex++;
}
private void bufferChanged() {
prevBuffer.clear();
prevBuffer.put(compareBuffer);
}
private int updateBufferPosition() {
int pos = (int) ((alGetSourcef(sourceID, AL11.AL_SAMPLE_OFFSET))-mm.getReadWindowSize()*mm.getChannelCount());
try {
readWindowIndex = mm.getPlaybackIndexPosition();
readWindowIndex = mm.getPlaybackIndexPosition()-1;
buffer.position(pos);
} catch (IllegalArgumentException iae) {
buffer.position(0);