added comments
This commit is contained in:
parent
193f972d01
commit
4d6cbaa652
@ -5,7 +5,6 @@ import static org.lwjgl.openal.AL10.*;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
|
|
||||||
import org.lwjgl.BufferUtils;
|
|
||||||
import org.lwjgl.openal.AL11;
|
import org.lwjgl.openal.AL11;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
@ -106,30 +105,36 @@ public class Visualizer extends Widget implements Disposable {
|
|||||||
}
|
}
|
||||||
vis.getAudioPCM()[sid] /= Short.MAX_VALUE+1f;
|
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();
|
int originalPos = buffer.position();
|
||||||
|
|
||||||
|
//Begin comparison
|
||||||
buffer.rewind();
|
buffer.rewind();
|
||||||
compareBuffer.rewind();
|
|
||||||
if (compareBuffer.compareTo(buffer) != 0) {
|
if (compareBuffer.compareTo(buffer) != 0) {
|
||||||
prevBuffer.clear();
|
bufferChanged();
|
||||||
prevBuffer.put(compareBuffer);
|
|
||||||
System.out.println("Buffer switched: " + prevBuffer.get(5) + "-" + buffer.get(5) + "-" + compareBuffer.get(5));
|
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Begin copying current buffer to the comparison buffer
|
||||||
compareBuffer.clear();
|
compareBuffer.clear();
|
||||||
compareBuffer.put(buffer);
|
compareBuffer.put(buffer);
|
||||||
compareBuffer.flip();
|
compareBuffer.flip();
|
||||||
|
|
||||||
|
//Reset buffer to proper position.
|
||||||
buffer.position(originalPos);
|
buffer.position(originalPos);
|
||||||
readWindowIndex++;
|
}
|
||||||
|
|
||||||
|
private void bufferChanged() {
|
||||||
|
prevBuffer.clear();
|
||||||
|
prevBuffer.put(compareBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int updateBufferPosition() {
|
private int updateBufferPosition() {
|
||||||
int pos = (int) ((alGetSourcef(sourceID, AL11.AL_SAMPLE_OFFSET))-mm.getReadWindowSize()*mm.getChannelCount());
|
int pos = (int) ((alGetSourcef(sourceID, AL11.AL_SAMPLE_OFFSET))-mm.getReadWindowSize()*mm.getChannelCount());
|
||||||
try {
|
try {
|
||||||
readWindowIndex = mm.getPlaybackIndexPosition();
|
readWindowIndex = mm.getPlaybackIndexPosition()-1;
|
||||||
buffer.position(pos);
|
buffer.position(pos);
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
buffer.position(0);
|
buffer.position(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user