minor file location refactor, openAL sourceID reflected correctly now

This commit is contained in:
Harrison Deng 2018-08-09 01:08:33 -05:00
parent 0d2b48f0c2
commit 4a7f4962e2
4 changed files with 13 additions and 11 deletions

View File

@ -5,5 +5,4 @@ public interface PCMSystem {
float[] getFrequencyBins();
int getWindowSize();
}

View File

@ -1,4 +1,4 @@
package zero1hd.rhythmbullet.desktop.audio.visualizer;
package zero1hd.rhythmbullet.desktop.audio;
import static org.lwjgl.openal.AL10.alGetSourcef;
@ -112,13 +112,7 @@ public class PCMObtainer implements Observer, Disposable, PCMSystem {
private void setMusic() {
Gdx.app.debug("PCMObtainer", "music set.");
try {
Field sourceIDField = ClassReflection.getDeclaredField(OpenALMusic.class, "sourceID");
sourceIDField.setAccessible(true);
sourceID = (int) sourceIDField.get(mc.getCurrentMusic());
} catch (ReflectionException e) {
e.printStackTrace();
}
sourceID = -1;
channelCount = mc.getCurrentMusicHeader().getChannelCount();
sampleRate = mc.getCurrentMusicHeader().getSampleRate();
@ -215,6 +209,15 @@ public class PCMObtainer implements Observer, Disposable, PCMSystem {
if (arg == mc.states.LOADED) {
setMusic();
} else if (arg == mc.states.PLAYING) {
if (sourceID == -1) {
try {
Field sourceIDField = ClassReflection.getDeclaredField(OpenALMusic.class, "sourceID");
sourceIDField.setAccessible(true);
sourceID = (int) sourceIDField.get(mc.getCurrentMusic());
} catch (ReflectionException e) {
e.printStackTrace();
}
}
streamReadThread.start();
}
}

View File

@ -12,7 +12,7 @@ import com.badlogic.gdx.utils.viewport.ExtendViewport;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.MusicController;
import zero1hd.rhythmbullet.audio.visualizer.CircularVisualizer;
import zero1hd.rhythmbullet.desktop.audio.visualizer.PCMObtainer;
import zero1hd.rhythmbullet.desktop.audio.PCMObtainer;
import zero1hd.rhythmbullet.game.GameController;
public class GameScreen extends ScreenAdapter {

View File

@ -19,7 +19,7 @@ import com.badlogic.gdx.utils.Align;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.MusicController;
import zero1hd.rhythmbullet.audio.visualizer.DoubleHorizontalVisualizer;
import zero1hd.rhythmbullet.desktop.audio.visualizer.PCMObtainer;
import zero1hd.rhythmbullet.desktop.audio.PCMObtainer;
import zero1hd.rhythmbullet.desktop.graphics.ui.components.MusicControls;
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;