visualizer should now be stable (with proper new buffer system)
This commit is contained in:
parent
874ef52bb9
commit
0fdc65796d
@ -10,6 +10,7 @@ import org.lwjgl.openal.AL11;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.backends.lwjgl.audio.OpenALMusic;
|
import com.badlogic.gdx.backends.lwjgl.audio.OpenALMusic;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||||
import com.badlogic.gdx.utils.reflect.Field;
|
import com.badlogic.gdx.utils.reflect.Field;
|
||||||
import com.badlogic.gdx.utils.reflect.ReflectionException;
|
import com.badlogic.gdx.utils.reflect.ReflectionException;
|
||||||
@ -47,22 +48,18 @@ public class DesktopVisualizer extends MusicManagerFFT implements Visualizer {
|
|||||||
int bufferPosOffset = 0;
|
int bufferPosOffset = 0;
|
||||||
if (mm.playbackIndexUpdate() != readWindowIndex) {
|
if (mm.playbackIndexUpdate() != readWindowIndex) {
|
||||||
bufferPosOffset = updateBufferPosition();
|
bufferPosOffset = updateBufferPosition();
|
||||||
if (bufferPosOffset < 0 && playingBuffer.limit()+bufferPosOffset > 0) {
|
if (bufferPosOffset < 0) {
|
||||||
playingBuffer.position(playingBuffer.limit()+bufferPosOffset);
|
playingBuffer.position(Math.max(playingBuffer.limit()+bufferPosOffset, 0));
|
||||||
|
} else {
|
||||||
|
buffer.position(bufferPosOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int sid = 0; sid < getAudioPCM().length && sid < playingBuffer.remaining(); sid++) {
|
||||||
for (int sid = 0; sid < getAudioPCM().length && sid < buffer.remaining(); sid++) {
|
getAudioPCM()[sid] = 0;
|
||||||
for (int channel = 0; channel < mm.getChannelCount(); channel ++) {
|
for (int channel = 0; channel < mm.getChannelCount(); channel ++) {
|
||||||
if (playingBuffer.position() < playingBuffer.limit()) {
|
|
||||||
if (getAudioPCM()[sid] < (chanVal = playingBuffer.get())) {
|
if (getAudioPCM()[sid] < (chanVal = playingBuffer.get())) {
|
||||||
getAudioPCM()[sid] = chanVal;
|
getAudioPCM()[sid] = chanVal;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (getAudioPCM()[sid] < (chanVal = buffer.get())) {
|
|
||||||
getAudioPCM()[sid] = chanVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
getAudioPCM()[sid] /= Short.MAX_VALUE+1f;
|
getAudioPCM()[sid] /= Short.MAX_VALUE+1f;
|
||||||
}
|
}
|
||||||
@ -96,7 +93,7 @@ public class DesktopVisualizer extends MusicManagerFFT implements Visualizer {
|
|||||||
//put the second portion into the first...
|
//put the second portion into the first...
|
||||||
playingBuffer.put(playingBuffer.array(), buffer.capacity(), buffer.capacity());
|
playingBuffer.put(playingBuffer.array(), buffer.capacity(), buffer.capacity());
|
||||||
}
|
}
|
||||||
//put the new buffer in the second portion.
|
//put the new buffer into the remaining portion.
|
||||||
playingBuffer.put(compareBuffer);
|
playingBuffer.put(compareBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user