visualizer bars properly rendered; removed overlapping play calls; +
minor fixes and changes
This commit is contained in:
parent
83d09ab2b9
commit
56d0ac2f51
@ -45,7 +45,7 @@ public class MusicController extends Observable implements OnCompletionListener,
|
|||||||
*/
|
*/
|
||||||
public void play() {
|
public void play() {
|
||||||
if (music != null) {
|
if (music != null) {
|
||||||
Gdx.app.debug("MusicListController", "Playing from MLC.");
|
Gdx.app.debug("MusicController", "Playing from MLC.");
|
||||||
music.play();
|
music.play();
|
||||||
music.setVolume(prefs.getFloat("music vol", 1f));
|
music.setVolume(prefs.getFloat("music vol", 1f));
|
||||||
notifyObservers(states.PLAYING);
|
notifyObservers(states.PLAYING);
|
||||||
@ -193,9 +193,6 @@ public class MusicController extends Observable implements OnCompletionListener,
|
|||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
if (o == musicList) {
|
if (o == musicList) {
|
||||||
loadMusic();
|
loadMusic();
|
||||||
if (autoPlay) {
|
|
||||||
play();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ package zero1hd.rhythmbullet.audio;
|
|||||||
|
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
|
|
||||||
|
import javax.activity.InvalidActivityException;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
@ -69,13 +71,19 @@ public class MusicList extends Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AudioProcessor newAudioProcessorFromIndex(int index) {
|
public AudioProcessor newAudioProcessorFromIndex(int index) {
|
||||||
if (!searched) Gdx.app.debug("SongList", "Warning, this list hasn't even searched yet...");
|
if (!searched) {
|
||||||
|
Gdx.app.debug("MusicList", "Warning, this list has not completed it's search...");
|
||||||
|
Thread.dumpStack();
|
||||||
|
}
|
||||||
return newAudioProcessor(musicList.get(index));
|
return newAudioProcessor(musicList.get(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public FileHandle getSongFileHandleFromIndex(int index) {
|
public FileHandle getSongFileHandleFromIndex(int index) {
|
||||||
if (!searched) Gdx.app.debug("SongList", "Warning, this list hasn't even searched yet...");
|
if (!searched) {
|
||||||
|
Gdx.app.debug("MusicList", "Warning, this list has not completed it's search...");
|
||||||
|
Thread.dumpStack();
|
||||||
|
}
|
||||||
return musicList.get(index);
|
return musicList.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +123,11 @@ public class MusicList extends Observable {
|
|||||||
if (work) {
|
if (work) {
|
||||||
musicList = obtainedAudioFiles;
|
musicList = obtainedAudioFiles;
|
||||||
musicList.add(Gdx.files.internal("music/Alan Walker - Spectre.mp3"));
|
musicList.add(Gdx.files.internal("music/Alan Walker - Spectre.mp3"));
|
||||||
notifyObservers();
|
if (work) {
|
||||||
searched = true;
|
searched = true;
|
||||||
|
Gdx.app.debug("MusicList", "recursive async search completed.");
|
||||||
|
notifyObservers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,15 +69,20 @@ public class DoubleHorizontalVisualizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
|
batch.end();
|
||||||
shapeRenderer.begin(ShapeType.Filled);
|
shapeRenderer.begin(ShapeType.Filled);
|
||||||
shapeRenderer.rect(x, y-2, width, y);
|
shapeRenderer.setColor(1f, 1f, 1f, 1f);
|
||||||
shapeRenderer.rect(x, y+height, width, y+height+2);
|
shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
|
||||||
int beginX = x + spaceBetweenBars/2, beginY = y;
|
shapeRenderer.setTransformMatrix(batch.getTransformMatrix());
|
||||||
|
shapeRenderer.rect(x, y, width, 2);
|
||||||
|
shapeRenderer.rect(x, y+height-2, width, 2);
|
||||||
|
int beginX = x + spaceBetweenBars/2, beginY = y;
|
||||||
for (int bar = 0; bar < barCount; bar++) {
|
for (int bar = 0; bar < barCount; bar++) {
|
||||||
shapeRenderer.rect(beginX + spaceBetweenBars*bar, beginY+height, beginX+barWidth, beginY+barHeights[bar]+height);
|
shapeRenderer.rect(beginX + (spaceBetweenBars+barWidth)*bar, beginY+height, barWidth, barHeights[bar]);
|
||||||
shapeRenderer.rect(beginX + spaceBetweenBars*bar, beginY, beginX+barWidth, beginY+barHeights[barHeights.length - 1 - bar]);
|
shapeRenderer.rect(beginX + (spaceBetweenBars+barWidth)*bar, beginY-barHeights[barHeights.length - 1 - bar], barWidth, barHeights[barHeights.length - 1 - bar]);
|
||||||
}
|
}
|
||||||
shapeRenderer.end();
|
shapeRenderer.end();
|
||||||
|
batch.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
|
@ -112,6 +112,7 @@ public class PCMObtainer implements Observer, Disposable, PCMSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setMusic() {
|
private void setMusic() {
|
||||||
|
Gdx.app.debug("PCMObtainer", "music set.");
|
||||||
try {
|
try {
|
||||||
Field sourceIDField = ClassReflection.getDeclaredField(OpenALMusic.class, "sourceID");
|
Field sourceIDField = ClassReflection.getDeclaredField(OpenALMusic.class, "sourceID");
|
||||||
sourceIDField.setAccessible(true);
|
sourceIDField.setAccessible(true);
|
||||||
@ -155,7 +156,7 @@ public class PCMObtainer implements Observer, Disposable, PCMSystem {
|
|||||||
private class BufferStreamReadThread implements Runnable {
|
private class BufferStreamReadThread implements Runnable {
|
||||||
private String name = "PCM-Audio-Processing";
|
private String name = "PCM-Audio-Processing";
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
private volatile boolean run;
|
private volatile boolean run = true;
|
||||||
private boolean paused;
|
private boolean paused;
|
||||||
private long timeOfLastRead;
|
private long timeOfLastRead;
|
||||||
private int waitTime;
|
private int waitTime;
|
||||||
@ -212,9 +213,9 @@ public class PCMObtainer implements Observer, Disposable, PCMSystem {
|
|||||||
@Override
|
@Override
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
if (o == mc) {
|
if (o == mc) {
|
||||||
if (arg.equals(mc.states.LOADED)) {
|
if (arg == mc.states.LOADED) {
|
||||||
setMusic();
|
setMusic();
|
||||||
} else if (arg.equals(mc.states.PLAYING)) {
|
} else if (arg == mc.states.PLAYING) {
|
||||||
streamReadThread.start();
|
streamReadThread.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package zero1hd.rhythmbullet.desktop.graphics.ui.components;
|
package zero1hd.rhythmbullet.desktop.graphics.ui.components;
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
|
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.audio.MusicController;
|
import zero1hd.rhythmbullet.audio.MusicController;
|
||||||
|
|
||||||
@ -37,14 +39,15 @@ public class MusicControls extends HorizontalGroup {
|
|||||||
super.act(delta);
|
super.act(delta);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
play.addListener(new ChangeListener() {
|
play.addListener(new ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
if (play.isChecked()) {
|
if (play.isChecked()) {
|
||||||
sc.play();
|
sc.play();
|
||||||
} else {
|
} else {
|
||||||
sc.pause();
|
sc.pause();
|
||||||
}
|
}
|
||||||
|
super.clicked(event, x, y);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addActor(play);
|
addActor(play);
|
||||||
|
@ -99,13 +99,13 @@ public class MainPage extends Page implements Observer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
// dhv.act(delta);
|
dhv.act(delta);
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
// dhv.draw(batch, parentAlpha);
|
dhv.draw(batch, parentAlpha);
|
||||||
super.draw(batch, parentAlpha);
|
super.draw(batch, parentAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user