slightly better buffer system
This commit is contained in:
parent
62dc7381c6
commit
abf3028cfb
@ -89,7 +89,14 @@ public class DesktopVisualizer extends MusicManagerFFT implements Visualizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void bufferChanged() {
|
private void bufferChanged() {
|
||||||
playingBuffer.clear();
|
//set position to beginning to prepare for overwrite
|
||||||
|
playingBuffer.position(0);
|
||||||
|
//if the backing playing buffer is full, we have two sections: A and B. A is the one before B, and is read from due to playback latency and offset. B is merely a buffer.
|
||||||
|
if (playingBuffer.limit() == playingBuffer.capacity()) {
|
||||||
|
//put the second portion into the first...
|
||||||
|
playingBuffer.put(playingBuffer.array(), buffer.capacity(), buffer.capacity());
|
||||||
|
}
|
||||||
|
//put the new buffer in the second portion.
|
||||||
playingBuffer.put(compareBuffer);
|
playingBuffer.put(compareBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +125,7 @@ public class DesktopVisualizer extends MusicManagerFFT implements Visualizer {
|
|||||||
}
|
}
|
||||||
int originalPos = buffer.position();
|
int originalPos = buffer.position();
|
||||||
|
|
||||||
playingBuffer = ShortBuffer.allocate(buffer.capacity());
|
playingBuffer = ShortBuffer.allocate(buffer.capacity()*2);
|
||||||
buffer.rewind();
|
buffer.rewind();
|
||||||
playingBuffer.put(buffer);
|
playingBuffer.put(buffer);
|
||||||
playingBuffer.flip();
|
playingBuffer.flip();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user