new sync system for visualizer
This commit is contained in:
parent
0fdc65796d
commit
45e3b55d84
@ -133,7 +133,7 @@ public class HorizontalVisualizer implements Disposable {
|
||||
}
|
||||
|
||||
public void updatePositionInfo() {
|
||||
barHeightMultiplier = height*0.03f;
|
||||
barHeightMultiplier = height;
|
||||
int barSpace = 0;
|
||||
angleRot.set(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
|
||||
|
||||
|
@ -10,7 +10,6 @@ import org.lwjgl.openal.AL11;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.lwjgl.audio.OpenALMusic;
|
||||
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.Field;
|
||||
import com.badlogic.gdx.utils.reflect.ReflectionException;
|
||||
@ -24,7 +23,6 @@ public class DesktopVisualizer extends MusicManagerFFT implements Visualizer {
|
||||
private ShortBuffer compareBuffer;
|
||||
private ShortBuffer buffer;
|
||||
private int sourceID;
|
||||
private int readWindowIndex;
|
||||
|
||||
public DesktopVisualizer() {
|
||||
super();
|
||||
@ -46,14 +44,9 @@ public class DesktopVisualizer extends MusicManagerFFT implements Visualizer {
|
||||
public void calcPCMData() {
|
||||
short chanVal;
|
||||
int bufferPosOffset = 0;
|
||||
if (mm.playbackIndexUpdate() != readWindowIndex) {
|
||||
bufferPosOffset = updateBufferPosition();
|
||||
if (bufferPosOffset < 0) {
|
||||
playingBuffer.position(Math.max(playingBuffer.limit()+bufferPosOffset, 0));
|
||||
} else {
|
||||
buffer.position(bufferPosOffset);
|
||||
}
|
||||
}
|
||||
|
||||
for (int sid = 0; sid < getAudioPCM().length && sid < playingBuffer.remaining(); sid++) {
|
||||
getAudioPCM()[sid] = 0;
|
||||
for (int channel = 0; channel < mm.getChannelCount(); channel ++) {
|
||||
@ -63,7 +56,6 @@ public class DesktopVisualizer extends MusicManagerFFT implements Visualizer {
|
||||
}
|
||||
getAudioPCM()[sid] /= Short.MAX_VALUE+1f;
|
||||
}
|
||||
readWindowIndex++;
|
||||
|
||||
|
||||
//Take down original buffer position so we don't need to sync again after...
|
||||
@ -99,7 +91,6 @@ public class DesktopVisualizer extends MusicManagerFFT implements Visualizer {
|
||||
|
||||
private int updateBufferPosition() {
|
||||
int pos = (int) ((alGetSourcef(sourceID, AL11.AL_SAMPLE_OFFSET))-buffer.limit()-mm.getChannelCount()*mm.getReadWindowSize());
|
||||
readWindowIndex = mm.getPlaybackIndexPosition()-1;
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ public class HorizontalVisualizerWidget extends Widget implements Disposable {
|
||||
if (mm != null && initialLoad) {
|
||||
if (timer >= visRefreshRate) {
|
||||
timer = 0;
|
||||
vis.calcPCMData();
|
||||
vis.calculate();
|
||||
vis.calcPCMData();
|
||||
} else {
|
||||
timer += delta;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user