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

View File

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

View File

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

View File

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

View File

@ -1,15 +1,17 @@
package zero1hd.polyjet.audio; package zero1hd.polyjet.audio;
import org.apache.commons.math3.random.MersenneTwister;
public class RhythmMapAlgorithm implements Runnable { public class RhythmMapAlgorithm implements Runnable {
AudioAnalyzer analyzer; AudioAnalyzer analyzer;
MersenneTwister rand;
public RhythmMapAlgorithm(AudioAnalyzer analyzer) { public RhythmMapAlgorithm(AudioAnalyzer analyzer) {
this.analyzer = analyzer; this.analyzer = analyzer;
rand = new MersenneTwister(analyzer.getPUID());
} }
@Override @Override
public void run() { 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; MusicSelectionPage ms;
AnalyzePage ap; AnalyzePage ap;
private Vector3 cameraPos; private Vector3 cameraPos;
private Polyjet core; private Polyjet core;
public PreGameScreen(Polyjet core) { public PreGameScreen(Polyjet core) {
@ -61,7 +59,7 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, M
switch (ID) { switch (ID) {
case MUSIC_SELECTED: case MUSIC_SELECTED:
cameraPos.x = 1.5f*Gdx.graphics.getWidth(); 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; break;
case SPECTRAL_FLUX_DONE: case SPECTRAL_FLUX_DONE:
break; break;
@ -91,7 +89,6 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, M
stage.addActor(ms); stage.addActor(ms);
ap = new AnalyzePage(core.getDefaultSkin(), core.getAssetManager()); ap = new AnalyzePage(core.getDefaultSkin(), core.getAssetManager());
ap.getAudioAnalyzer().sender.addListener(this);
ap.miniSender.addListener(this); ap.miniSender.addListener(this);
ap.setPosition(Gdx.graphics.getWidth(), ap.getY()); ap.setPosition(Gdx.graphics.getWidth(), ap.getY());
stage.addActor(ap); 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); displayName = new ScrollText(audioInfo.getSongName(), skin, true);
defaults().align(Align.top); defaults().align(Align.top);

View File

@ -16,6 +16,7 @@ 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.util.MiniEvents; import zero1hd.polyjet.util.MiniEvents;
import zero1hd.polyjet.util.MiniListener;
public class AnalyzePage extends Page { public class AnalyzePage extends Page {
AudioAnalyzer audioAnalyzer; AudioAnalyzer audioAnalyzer;
@ -58,7 +59,7 @@ public class AnalyzePage extends Page {
addActor(back); addActor(back);
} }
public void setSong(AudioData music, AudioInfo audioInfo) { public void setSong(AudioData music, AudioInfo audioInfo, MiniListener listener) {
songInfo.clear(); songInfo.clear();
audioAnalyzer = new AudioAnalyzer(); audioAnalyzer = new AudioAnalyzer();
@ -75,7 +76,9 @@ public class AnalyzePage extends Page {
@Override @Override
public void act(float delta) { public void act(float delta) {
status.setText("Initial analysis: " + audioAnalyzer.getProgress()); if (music != null) {
status.setText("Initial analysis: " + audioAnalyzer.getProgress());
}
super.act(delta); super.act(delta);
} }
@ -86,11 +89,8 @@ public class AnalyzePage extends Page {
return false; return false;
} }
} }
public void clearAudioData() { public void clearAudioData() {
music = null; 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.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -104,7 +105,7 @@ public class MusicSelectionPage extends Page {
public void run() { public void run() {
Gdx.app.debug("Music Search Thread", "Finished loading: " + selectable.getName()); Gdx.app.debug("Music Search Thread", "Finished loading: " + selectable.getName());
musicChoices.add(selectable).prefSize(panelWidthCalc(getWidth()), musicChoiceScroller.getHeight()); musicChoices.add(selectable).prefSize(panelWidthCalc(getWidth()), musicChoiceScroller.getHeight());
selectable.addInfoToPanel(musicChoiceScroller, panelWidthCalc(getWidth()) - 20f); selectable.addInfoToPanel(panelWidthCalc(getWidth()) - 20f);
selectable.addListener(new ChangeListener() { selectable.addListener(new ChangeListener() {
@Override @Override

View File

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

View File

@ -18,8 +18,9 @@ public class BeatViewer extends Window {
int songIndex; int songIndex;
AudioData music; AudioData music;
Texture lightOn; 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); super(title, skin);
defaults().space(5f); defaults().space(5f);
setSize(64, 100); setSize(64, 100);
@ -111,7 +112,8 @@ public class BeatViewer extends Window {
super.act(delta); super.act(delta);
} }
public void setMusic(AudioData audioData) { public void setMusic(AudioData audioData, AudioAnalyzer analyzer) {
this.music = audioData; this.music = audioData;
this.data = analyzer;
} }
} }