fixed and cleaned code up

This commit is contained in:
Harrison Deng 2017-05-28 17:30:35 -05:00
parent b4a6bbbea3
commit a52e5fc0ed
12 changed files with 53 additions and 38 deletions

View File

@ -41,14 +41,7 @@ project(":desktop") {
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile group: 'com.googlecode.soundlibs', name: 'mp3spi', version: '1.9.5-1'
compile "org.apache.commons:commons-math3:3.2"
compile "com.github.rwl:jtransforms:2.4.0"
compile "org:jaudiotagger:2.0.3"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
}
}
@ -71,14 +64,13 @@ project(":android") {
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile group: 'com.googlecode.soundlibs', name: 'mp3spi', version: '1.9.5-1'
compile "org.apache.commons:commons-math3:3.2"
compile "com.github.rwl:jtransforms:2.4.0"
compile "org:jaudiotagger:2.0.3"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
}
}
@ -89,8 +81,11 @@ project(":core") {
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile group: 'com.googlecode.soundlibs', name: 'mp3spi', version: '1.9.5-1'
compile group: 'com.googlecode.soundlibs', name: 'jlayer', version: '1.0.1-1'
compile "org.apache.commons:commons-math3:3.2"

View File

@ -104,7 +104,6 @@ public class AudioAnalyzer {
seedDigit ++;
}
float fluxVal = 0;
//bass detection
fluxVal = 0;
@ -305,4 +304,8 @@ public class AudioAnalyzer {
public void stop() {
work = false;
}
public int getPUID() {
return PUID;
}
}

View File

@ -46,7 +46,7 @@ public class AudioInfo implements Disposable {
e.printStackTrace();
}
invalidMusic = true;
// invalidMusic = true;
} else {

View File

@ -19,6 +19,9 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.files.FileHandle;
import javazoom.jl.decoder.Decoder;
import javazoom.spi.mpeg.sampled.convert.DecodedMpegAudioInputStream;
public class Mp3AudioData implements AudioData {
private int readWindowSize = 1024;
@ -31,7 +34,10 @@ public class Mp3AudioData implements AudioData {
private int sampleCount;
private AudioInputStream in;
DecodedMpegAudioInputStream dStream;
Decoder decoder = new Decoder();
public Mp3AudioData(FileHandle audioFile) {
try {
sampleCount = (int) new MP3File(audioFile.file()).getMP3AudioHeader().getNumberOfFrames();

View File

@ -1,15 +1,17 @@
package zero1hd.polyjet.audio;
import org.apache.commons.math3.random.MersenneTwister;
public class RhythmMapAlgorithm implements Runnable {
AudioAnalyzer analyzer;
MersenneTwister rand;
public RhythmMapAlgorithm(AudioAnalyzer analyzer) {
this.analyzer = analyzer;
rand = new MersenneTwister(analyzer.getPUID());
}
@Override
public void run() {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,5 @@
package zero1hd.polyjet.entity;
public enum Entities {
Bar_Beat, Void_Circle;
}

View File

@ -24,9 +24,7 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, M
MusicSelectionPage ms;
AnalyzePage ap;
private Vector3 cameraPos;
private Polyjet core;
public PreGameScreen(Polyjet core) {
@ -61,7 +59,7 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, M
switch (ID) {
case MUSIC_SELECTED:
cameraPos.x = 1.5f*Gdx.graphics.getWidth();
ap.setSong(Audio.getAudioData(ms.getSelectedMusic()), ms.getSelectedMusicInfo());
ap.setSong(Audio.getAudioData(ms.getSelectedMusic()), ms.getSelectedMusicInfo(), this);
break;
case SPECTRAL_FLUX_DONE:
break;
@ -91,7 +89,6 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, M
stage.addActor(ms);
ap = new AnalyzePage(core.getDefaultSkin(), core.getAssetManager());
ap.getAudioAnalyzer().sender.addListener(this);
ap.miniSender.addListener(this);
ap.setPosition(Gdx.graphics.getWidth(), ap.getY());
stage.addActor(ap);

View File

@ -43,7 +43,7 @@ public class MusicSelectable extends Button implements Disposable {
}
public void addInfoToPanel(ScrollPane scroller, float coverSize) {
public void addInfoToPanel(float coverSize) {
displayName = new ScrollText(audioInfo.getSongName(), skin, true);
defaults().align(Align.top);

View File

@ -16,6 +16,7 @@ import zero1hd.polyjet.audio.AudioAnalyzer;
import zero1hd.polyjet.audio.AudioData;
import zero1hd.polyjet.audio.AudioInfo;
import zero1hd.polyjet.util.MiniEvents;
import zero1hd.polyjet.util.MiniListener;
public class AnalyzePage extends Page {
AudioAnalyzer audioAnalyzer;
@ -58,7 +59,7 @@ public class AnalyzePage extends Page {
addActor(back);
}
public void setSong(AudioData music, AudioInfo audioInfo) {
public void setSong(AudioData music, AudioInfo audioInfo, MiniListener listener) {
songInfo.clear();
audioAnalyzer = new AudioAnalyzer();
@ -75,7 +76,9 @@ public class AnalyzePage extends Page {
@Override
public void act(float delta) {
status.setText("Initial analysis: " + audioAnalyzer.getProgress());
if (music != null) {
status.setText("Initial analysis: " + audioAnalyzer.getProgress());
}
super.act(delta);
}
@ -86,11 +89,8 @@ public class AnalyzePage extends Page {
return false;
}
}
public void clearAudioData() {
music = null;
}
public AudioAnalyzer getAudioAnalyzer() {
return audioAnalyzer;
}
}

View File

@ -2,6 +2,7 @@ package zero1hd.polyjet.ui.pages;
import java.io.File;
import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -104,7 +105,7 @@ public class MusicSelectionPage extends Page {
public void run() {
Gdx.app.debug("Music Search Thread", "Finished loading: " + selectable.getName());
musicChoices.add(selectable).prefSize(panelWidthCalc(getWidth()), musicChoiceScroller.getHeight());
selectable.addInfoToPanel(musicChoiceScroller, panelWidthCalc(getWidth()) - 20f);
selectable.addInfoToPanel(panelWidthCalc(getWidth()) - 20f);
selectable.addListener(new ChangeListener() {
@Override

View File

@ -46,7 +46,7 @@ public class CreativeStage extends Stage implements MiniListener {
fpsViewer = new FPSWindow("FPS", core.getDefaultSkin());
beatViewer = new BeatViewer("Beat", core.getDefaultSkin(), core, analyzer);
beatViewer = new BeatViewer("Beat", core.getDefaultSkin(), core);
graphViewer = new GraphWindow("Peak Values", core.getDefaultSkin());
volumeWindow = new VolumeWindow("Volume adjustments", core.getDefaultSkin(), core.getPrefs());
@ -198,7 +198,7 @@ public class CreativeStage extends Stage implements MiniListener {
break;
case MUSIC_SELECTED:
beatViewer.setMusic(null);
beatViewer.setMusic(null, null);
volumeWindow.setMusic(null);
graphViewer.setData(null, null, null);
musicPlayBackControls.setAudiofile(null);
@ -213,9 +213,13 @@ public class CreativeStage extends Stage implements MiniListener {
case MUSIC_DATA_CLEANED:
musicPlayBackControls.setAudiofile(musicSelector.getSelectedMusic());
volumeWindow.setMusic(musicPlayBackControls.getAudiofile());
beatViewer.setMusic(musicPlayBackControls.getAudiofile());
beatViewer.setMusic(musicPlayBackControls.getAudiofile(), analyzer);
graphViewer.setData(analyzer.getBassPeaks(), analyzer.getUMPeaks(), musicPlayBackControls.getAudiofile());
break;
case MAP_GENERATED:
break;
default:
break;
}
}
}

View File

@ -18,8 +18,9 @@ public class BeatViewer extends Window {
int songIndex;
AudioData music;
Texture lightOn;
private AudioAnalyzer data;
public BeatViewer(String title, Skin skin, Polyjet core, final AudioAnalyzer data) {
public BeatViewer(String title, Skin skin, Polyjet core) {
super(title, skin);
defaults().space(5f);
setSize(64, 100);
@ -111,7 +112,8 @@ public class BeatViewer extends Window {
super.act(delta);
}
public void setMusic(AudioData audioData) {
public void setMusic(AudioData audioData, AudioAnalyzer analyzer) {
this.music = audioData;
this.data = analyzer;
}
}