diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/ScrollText.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/ScrollText.java index 8fc6f20..c446899 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/ScrollText.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/ScrollText.java @@ -102,9 +102,29 @@ public class ScrollText extends Widget { } } + + public void scroll(float delta) { + if (text1Offset >= -text1Width) { + text1Offset -= 60*delta; + + + if ((text1Offset < - Math.abs((text1Width - clipBounds.getWidth())) - 50) || text2Offset != clipBounds.getWidth()) { + text2Offset -= 60*delta; + if (text2Offset <= -text2Width) { + text2Offset = clipBounds.getWidth(); + } + } + + } else { + text2Offset -= 60*delta; + if (text2Offset < - Math.abs((text2Width - clipBounds.getWidth())) - 50) { + text1Offset = clipBounds.getWidth(); + } + } + } + @Override public void act(float delta) { - setSize(getWidth(), textHeight + 4); clipBounds.setSize(getWidth()-2, getHeight()*1.5f); if (dupFirstText) { if (text1Width > clipBounds.getWidth()) { @@ -130,26 +150,6 @@ public class ScrollText extends Widget { super.act(delta); } - public void scroll(float delta) { - if (text1Offset >= -text1Width) { - text1Offset -= 60*delta; - - - if ((text1Offset < - Math.abs((text1Width - clipBounds.getWidth())) - 50) || text2Offset != clipBounds.getWidth()) { - text2Offset -= 60*delta; - if (text2Offset <= -text2Width) { - text2Offset = clipBounds.getWidth(); - } - } - - } else { - text2Offset -= 60*delta; - if (text2Offset < - Math.abs((text2Width - clipBounds.getWidth())) - 50) { - text1Offset = clipBounds.getWidth(); - } - } - } - @Override public void draw(Batch batch, float parentAlpha) { if (background != null) { diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java b/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java index cf43d31..2bee332 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java @@ -17,7 +17,6 @@ public class DesktopLauncher { config.samples = 2; config.width = 512; config.height = 512; - System.setProperty("org.lwjgl.opengl.Window.undecorated", "true"); core = new RhythmBullet(); core.setup(new SplashScreen(), new DesktopAssetPack(), screenConfig); new LwjglApplication(core, config); diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/audio/PCMObtainer.java b/desktop/src/zero1hd/rhythmbullet/desktop/audio/PCMObtainer.java index 5202f2c..341f72b 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/audio/PCMObtainer.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/audio/PCMObtainer.java @@ -32,7 +32,7 @@ public class PCMObtainer implements Observer, PCMSystem { private float[] frequencyBins = new float[windowSize / 2]; private FloatFFT_1D fft = new FloatFFT_1D(windowSize); private ShortBuffer playingBuffer; - private ShortBuffer compareBuffer; + private ShortBuffer intermediateBuffer; private ShortBuffer buffer; private int sourceID; private int channelCount; @@ -50,7 +50,7 @@ public class PCMObtainer implements Observer, PCMSystem { bufferField.setAccessible(true); buffer = ((ByteBuffer) bufferField.get(null)).asShortBuffer().asReadOnlyBuffer(); playingBuffer = ShortBuffer.allocate(buffer.capacity()); - compareBuffer = ShortBuffer.allocate(buffer.capacity()); + intermediateBuffer = ShortBuffer.allocate(buffer.capacity()); } catch (IllegalArgumentException | SecurityException | ReflectionException e) { Gdx.app.debug("Visualizer reflection", "Failed attempt at retrieving tempBuffer field.", e); Gdx.app.exit(); @@ -79,13 +79,13 @@ public class PCMObtainer implements Observer, PCMSystem { // Begin comparison buffer.rewind(); - if (compareBuffer.compareTo(buffer) != 0) { + if (intermediateBuffer.compareTo(buffer) != 0) { bufferChanged(); // Begin copying current buffer to the comparison buffer - compareBuffer.clear(); - compareBuffer.put(buffer); - compareBuffer.flip(); + intermediateBuffer.clear(); + intermediateBuffer.put(buffer); + intermediateBuffer.flip(); } // Reset buffer to proper position. @@ -94,7 +94,7 @@ public class PCMObtainer implements Observer, PCMSystem { private void bufferChanged() { playingBuffer.position(0); - playingBuffer.put(compareBuffer); + playingBuffer.put(intermediateBuffer); synchronizeBufferWithPlayback(); } @@ -158,7 +158,6 @@ public class PCMObtainer implements Observer, PCMSystem { private volatile boolean run = true; private long timeOfLastRead; private long waitTime; - private boolean read = true; @Override public void run() { while (run) { @@ -167,12 +166,11 @@ public class PCMObtainer implements Observer, PCMSystem { timeOfLastRead = TimeUtils.millis(); //calculate current pcm data and notify that there is new data - if (read) { - calcPCMData(); - fft.realForward(PCM); - updated = true; - windowsRead++; - } + calcPCMData(); + fft.realForward(PCM); + updated = true; + windowsRead++; + //contemplate synchronization try { currentPlaybackWindow = MathUtils.round((mc.getCurrentPosition() * sampleRate) / windowSize); @@ -182,9 +180,8 @@ public class PCMObtainer implements Observer, PCMSystem { } } if (windowsRead != currentPlaybackWindow) { - read = synchronizeBufferWithPlayback(); + synchronizeBufferWithPlayback(); } - //wait for a bit before reading again depending on the speed at which the system does playback. waitTime = Math.max(0, millisPerWindow - TimeUtils.timeSinceMillis(timeOfLastRead)); try { @@ -203,6 +200,7 @@ public class PCMObtainer implements Observer, PCMSystem { } } } + Gdx.app.debug(thread.getName(), "stopped"); } public void start() { @@ -218,7 +216,6 @@ public class PCMObtainer implements Observer, PCMSystem { } public void stop() { - Gdx.app.debug("PCMObtainer", "stopping " + thread.getName()); run = false; } } diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/MusicControls.java b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/MusicControls.java index f8a248f..0642e14 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/MusicControls.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/MusicControls.java @@ -84,6 +84,6 @@ public class MusicControls extends HorizontalGroup { addActor(shuffle); space(15); - invalidate(); + setSize(getMinWidth(), getMinHeight()); } } diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MainPage.java b/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MainPage.java index 7ee3c43..0333c93 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MainPage.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MainPage.java @@ -88,12 +88,12 @@ public class MainPage extends Page implements Observer { menuTable.add(quitButton).fillX(); musicControls = new MusicControls(skin, mc); - musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()-20f); + musicControls.setPosition((getWidth()-musicControls.getWidth() - 15f), 15f); addActor(musicControls); scrollText = new ScrollText("...", "...", skin, false, true); scrollText.setWidth(0.5f*getWidth()); - scrollText.setPosition(15, getHeight() - scrollText.getHeight()-25f); + scrollText.setPosition(15, getHeight() - scrollText.getHeight()-30f); addActor(scrollText); }