progress on analysis page
This commit is contained in:
parent
cf0114bac3
commit
1f84a68ae5
@ -310,4 +310,12 @@ holo-pane-down
|
||||
split: 9, 9, 9, 9
|
||||
orig: 20, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
large-pane
|
||||
rotate: false
|
||||
xy: 182, 5
|
||||
size: 9, 27
|
||||
split: 4, 4, 13, 13
|
||||
orig: 9, 27
|
||||
offset: 0, 0
|
||||
index: -1
|
Binary file not shown.
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.6 KiB |
@ -213,7 +213,7 @@ public class AudioAnalyzer {
|
||||
}
|
||||
|
||||
avgBPS = -1f;
|
||||
int beats = 0;
|
||||
float beats = 0;
|
||||
if (avgBPS == -1 && bassPeaks.get(i) != 0) {
|
||||
//this should actually equal to 1;
|
||||
avgBPS = 0;
|
||||
@ -225,8 +225,8 @@ public class AudioAnalyzer {
|
||||
}
|
||||
//then we minus one from the beats so it actually works out
|
||||
avgBPS -= UMPrunned.size-lastID;
|
||||
avgBPS /= beats;
|
||||
avgBPS *= secondsPerFrame;
|
||||
avgBPS = beats/avgBPS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,6 +28,7 @@ public class MusicSelectable extends Button implements Disposable {
|
||||
|
||||
private Texture defaultAlbumCover;
|
||||
AudioInfo audioInfo;
|
||||
|
||||
public MusicSelectable(FileHandle musicFile, Preferences musicData, final Skin skin, Texture defaultAlbumC) {
|
||||
super(skin, "info-button");
|
||||
this.skin = skin;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package zero1hd.polyjet.ui.builders;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||
@ -62,6 +64,40 @@ public class ScrollText extends Widget {
|
||||
});
|
||||
}
|
||||
|
||||
public ScrollText(String text, Skin skin, String fontName, Color color, boolean scrollOnHover) {
|
||||
super();
|
||||
setName(text);
|
||||
this.scrollOnHover = scrollOnHover;
|
||||
|
||||
this.text = text;
|
||||
font = skin.getFont(fontName);
|
||||
font.setColor(color);
|
||||
gLayout = new GlyphLayout(font, text);
|
||||
|
||||
fontHeight = gLayout.height;
|
||||
fontWidth = gLayout.width;
|
||||
|
||||
coords = new Vector2();
|
||||
|
||||
addListener(new ClickListener() {
|
||||
@Override
|
||||
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
|
||||
currentlyHovering = true;
|
||||
super.enter(event, x, y, pointer, fromActor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
|
||||
currentlyHovering = false;
|
||||
super.exit(event, x, y, pointer, toActor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public float getFontHeight() {
|
||||
return fontHeight;
|
||||
}
|
||||
@ -100,11 +136,10 @@ public class ScrollText extends Widget {
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
validate();
|
||||
|
||||
coords.x = getX();
|
||||
coords.y = getY();
|
||||
getParent().localToStageCoordinates(coords);
|
||||
// localToStageCoordinates(coords);
|
||||
|
||||
clipBounds.setX(coords.x);
|
||||
clipBounds.setY(coords.y - 0.5f*getHeight());
|
||||
|
@ -18,6 +18,7 @@ import com.badlogic.gdx.utils.Align;
|
||||
import zero1hd.polyjet.audio.AudioAnalyzer;
|
||||
import zero1hd.polyjet.audio.AudioData;
|
||||
import zero1hd.polyjet.audio.AudioInfo;
|
||||
import zero1hd.polyjet.ui.builders.ScrollText;
|
||||
import zero1hd.polyjet.util.MiniEvents;
|
||||
import zero1hd.polyjet.util.MiniListener;
|
||||
|
||||
@ -33,11 +34,14 @@ public class AnalyzePage extends Page implements MiniListener {
|
||||
private TextButton back;
|
||||
private Image loadingCircle;
|
||||
private long startTime, endTime;
|
||||
private ScrollText songName;
|
||||
private Label[] info;
|
||||
public AnalyzePage(Skin skin, AssetManager assets) {
|
||||
super("Results", skin);
|
||||
this.skin = skin;
|
||||
songInfo = new Table(skin);
|
||||
songInfo.setSize(getWidth()/2f, getHeightBelowTitle()/2f);
|
||||
songInfo.setBackground(skin.getDrawable("large-pane"));
|
||||
|
||||
loadingCircle = new Image(assets.get("cybercircle1.png", Texture.class));
|
||||
loadingCircle.setPosition((getWidth()-loadingCircle.getWidth())/2, (getHeightBelowTitle()-loadingCircle.getHeight())/2);
|
||||
@ -55,37 +59,40 @@ public class AnalyzePage extends Page implements MiniListener {
|
||||
audioAnalyzer.stop();
|
||||
}
|
||||
});
|
||||
songInfo.setSize(getWidth(), getHeightBelowTitle());
|
||||
|
||||
|
||||
info = new Label[6];
|
||||
for (int i = 0; i < info.length; i++) {
|
||||
info[i] = new Label(null, skin, "sub-font", skin.getColor("default"));
|
||||
}
|
||||
|
||||
addActor(back);
|
||||
addActor(songInfo);
|
||||
}
|
||||
|
||||
public void setSong(AudioData music, AudioInfo audioInfo, MiniListener listener) {
|
||||
songInfo.clear();
|
||||
songInfo.pad(15f);
|
||||
songInfo.defaults().align(Align.left);
|
||||
audioAnalyzer = new AudioAnalyzer();
|
||||
audioAnalyzer.sender.addListener(this);
|
||||
|
||||
this.music = music;
|
||||
|
||||
songName = new ScrollText(audioInfo.getSongName(), skin, true);
|
||||
audioAnalyzer.startAnalyticalThread(music);
|
||||
songInfo.add(new Label(audioInfo.getSongName(), skin, "default-font", skin.getColor("default")));
|
||||
songInfo.add(songName).expandX().fillX();
|
||||
|
||||
for (int i = 0; i < info.length; i++) {
|
||||
info[i].setColor(1f, 1f, 1f, 0f);
|
||||
info[i].setText(null);
|
||||
songInfo.row();
|
||||
songInfo.add(info[i]);
|
||||
}
|
||||
startTime = System.currentTimeMillis();
|
||||
songInfo.pack();
|
||||
songInfo.setPosition((getWidth()-songInfo.getWidth())/2f, (getHeightBelowTitle()-songInfo.getHeight())/2f);
|
||||
addActor(songInfo);
|
||||
info[0].addAction(Actions.color(Color.BLACK, 2.5f));
|
||||
|
||||
startTime = System.currentTimeMillis();
|
||||
songInfo.setPosition((getWidth()-songInfo.getWidth())/2f, (getHeightBelowTitle()-songInfo.getHeight())/2f);
|
||||
info[0].addAction(Actions.color(Color.BLACK, 2.5f));
|
||||
System.out.println(songInfo);
|
||||
}
|
||||
|
||||
|
||||
@ -110,17 +117,16 @@ public class AnalyzePage extends Page implements MiniListener {
|
||||
public void handle(MiniEvents ID) {
|
||||
switch (ID) {
|
||||
case ANALYZER_ITERATED:
|
||||
if (audioAnalyzer.getProgress() == 50) {
|
||||
songInfo.addAction(Actions.moveTo(40f, getHeightBelowTitle()-songInfo.getHeight()-25f, 0.75f, Interpolation.linear));
|
||||
}
|
||||
info[0].setText("Initial analysis: " + audioAnalyzer.getProgress() + "%");
|
||||
break;
|
||||
case SPECTRAL_FLUX_DONE:
|
||||
songInfo.row();
|
||||
endTime = System.currentTimeMillis();
|
||||
info[1].setText("Done. Analyze time: " + ((endTime - startTime)/1000f) + "s");
|
||||
info[1].addAction(Actions.color(Color.BLACK, 0.75f));
|
||||
|
||||
info[2].setText("Average enemies per second: " + audioAnalyzer.getAvgBPS());
|
||||
info[2].addAction(Actions.color(Color.BLACK, 1.5f));
|
||||
songInfo.addAction(Actions.moveTo(40f, getHeightBelowTitle()-songInfo.getHeight()-25f, 1f, Interpolation.smooth));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user