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
|
split: 9, 9, 9, 9
|
||||||
orig: 20, 20
|
orig: 20, 20
|
||||||
offset: 0, 0
|
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
|
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;
|
avgBPS = -1f;
|
||||||
int beats = 0;
|
float beats = 0;
|
||||||
if (avgBPS == -1 && bassPeaks.get(i) != 0) {
|
if (avgBPS == -1 && bassPeaks.get(i) != 0) {
|
||||||
//this should actually equal to 1;
|
//this should actually equal to 1;
|
||||||
avgBPS = 0;
|
avgBPS = 0;
|
||||||
@ -225,8 +225,8 @@ public class AudioAnalyzer {
|
|||||||
}
|
}
|
||||||
//then we minus one from the beats so it actually works out
|
//then we minus one from the beats so it actually works out
|
||||||
avgBPS -= UMPrunned.size-lastID;
|
avgBPS -= UMPrunned.size-lastID;
|
||||||
avgBPS /= beats;
|
|
||||||
avgBPS *= secondsPerFrame;
|
avgBPS *= secondsPerFrame;
|
||||||
|
avgBPS = beats/avgBPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ public class MusicSelectable extends Button implements Disposable {
|
|||||||
|
|
||||||
private Texture defaultAlbumCover;
|
private Texture defaultAlbumCover;
|
||||||
AudioInfo audioInfo;
|
AudioInfo audioInfo;
|
||||||
|
|
||||||
public MusicSelectable(FileHandle musicFile, Preferences musicData, final Skin skin, Texture defaultAlbumC) {
|
public MusicSelectable(FileHandle musicFile, Preferences musicData, final Skin skin, Texture defaultAlbumC) {
|
||||||
super(skin, "info-button");
|
super(skin, "info-button");
|
||||||
this.skin = skin;
|
this.skin = skin;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package zero1hd.polyjet.ui.builders;
|
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.Batch;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
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() {
|
public float getFontHeight() {
|
||||||
return fontHeight;
|
return fontHeight;
|
||||||
}
|
}
|
||||||
@ -100,11 +136,10 @@ public class ScrollText extends Widget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
validate();
|
|
||||||
|
|
||||||
coords.x = getX();
|
coords.x = getX();
|
||||||
coords.y = getY();
|
coords.y = getY();
|
||||||
getParent().localToStageCoordinates(coords);
|
// localToStageCoordinates(coords);
|
||||||
|
|
||||||
clipBounds.setX(coords.x);
|
clipBounds.setX(coords.x);
|
||||||
clipBounds.setY(coords.y - 0.5f*getHeight());
|
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.AudioAnalyzer;
|
||||||
import zero1hd.polyjet.audio.AudioData;
|
import zero1hd.polyjet.audio.AudioData;
|
||||||
import zero1hd.polyjet.audio.AudioInfo;
|
import zero1hd.polyjet.audio.AudioInfo;
|
||||||
|
import zero1hd.polyjet.ui.builders.ScrollText;
|
||||||
import zero1hd.polyjet.util.MiniEvents;
|
import zero1hd.polyjet.util.MiniEvents;
|
||||||
import zero1hd.polyjet.util.MiniListener;
|
import zero1hd.polyjet.util.MiniListener;
|
||||||
|
|
||||||
@ -33,11 +34,14 @@ public class AnalyzePage extends Page implements MiniListener {
|
|||||||
private TextButton back;
|
private TextButton back;
|
||||||
private Image loadingCircle;
|
private Image loadingCircle;
|
||||||
private long startTime, endTime;
|
private long startTime, endTime;
|
||||||
|
private ScrollText songName;
|
||||||
private Label[] info;
|
private Label[] info;
|
||||||
public AnalyzePage(Skin skin, AssetManager assets) {
|
public AnalyzePage(Skin skin, AssetManager assets) {
|
||||||
super("Results", skin);
|
super("Results", skin);
|
||||||
this.skin = skin;
|
this.skin = skin;
|
||||||
songInfo = new Table(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 = new Image(assets.get("cybercircle1.png", Texture.class));
|
||||||
loadingCircle.setPosition((getWidth()-loadingCircle.getWidth())/2, (getHeightBelowTitle()-loadingCircle.getHeight())/2);
|
loadingCircle.setPosition((getWidth()-loadingCircle.getWidth())/2, (getHeightBelowTitle()-loadingCircle.getHeight())/2);
|
||||||
@ -55,37 +59,40 @@ public class AnalyzePage extends Page implements MiniListener {
|
|||||||
audioAnalyzer.stop();
|
audioAnalyzer.stop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
songInfo.setSize(getWidth(), getHeightBelowTitle());
|
|
||||||
|
|
||||||
|
|
||||||
info = new Label[6];
|
info = new Label[6];
|
||||||
for (int i = 0; i < info.length; i++) {
|
for (int i = 0; i < info.length; i++) {
|
||||||
info[i] = new Label(null, skin, "sub-font", skin.getColor("default"));
|
info[i] = new Label(null, skin, "sub-font", skin.getColor("default"));
|
||||||
}
|
}
|
||||||
|
|
||||||
addActor(back);
|
addActor(back);
|
||||||
|
addActor(songInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSong(AudioData music, AudioInfo audioInfo, MiniListener listener) {
|
public void setSong(AudioData music, AudioInfo audioInfo, MiniListener listener) {
|
||||||
songInfo.clear();
|
songInfo.clear();
|
||||||
|
songInfo.pad(15f);
|
||||||
songInfo.defaults().align(Align.left);
|
songInfo.defaults().align(Align.left);
|
||||||
audioAnalyzer = new AudioAnalyzer();
|
audioAnalyzer = new AudioAnalyzer();
|
||||||
audioAnalyzer.sender.addListener(this);
|
audioAnalyzer.sender.addListener(this);
|
||||||
|
|
||||||
this.music = music;
|
this.music = music;
|
||||||
|
|
||||||
|
songName = new ScrollText(audioInfo.getSongName(), skin, true);
|
||||||
audioAnalyzer.startAnalyticalThread(music);
|
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++) {
|
for (int i = 0; i < info.length; i++) {
|
||||||
info[i].setColor(1f, 1f, 1f, 0f);
|
info[i].setColor(1f, 1f, 1f, 0f);
|
||||||
info[i].setText(null);
|
info[i].setText(null);
|
||||||
songInfo.row();
|
songInfo.row();
|
||||||
songInfo.add(info[i]);
|
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) {
|
public void handle(MiniEvents ID) {
|
||||||
switch (ID) {
|
switch (ID) {
|
||||||
case ANALYZER_ITERATED:
|
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() + "%");
|
info[0].setText("Initial analysis: " + audioAnalyzer.getProgress() + "%");
|
||||||
break;
|
break;
|
||||||
case SPECTRAL_FLUX_DONE:
|
case SPECTRAL_FLUX_DONE:
|
||||||
songInfo.row();
|
|
||||||
endTime = System.currentTimeMillis();
|
endTime = System.currentTimeMillis();
|
||||||
info[1].setText("Done. Analyze time: " + ((endTime - startTime)/1000f) + "s");
|
info[1].setText("Done. Analyze time: " + ((endTime - startTime)/1000f) + "s");
|
||||||
info[1].addAction(Actions.color(Color.BLACK, 0.75f));
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user