diff --git a/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java b/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java index 42e3ce1..3fd2b9b 100755 --- a/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java +++ b/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java @@ -221,7 +221,6 @@ public class AudioAnalyzer { if (bassPeaks.get(i) == 0) { avgSPB ++; } else { - bassBeats ++; lastID = i; } } else if (bassPeaks.get(i) != 0) { @@ -230,6 +229,8 @@ public class AudioAnalyzer { if (bassPeaks.get(i) != 0) { bassAvg += bassPeaks.get(i); + bassBeats++; + } if (umPeaks.get(i) != 0) { umAvg += umPeaks.get(i); @@ -239,14 +240,15 @@ public class AudioAnalyzer { } //then we minus one from the beats so it actually works out - avgSPB -= umPrunned.size-lastID; + avgSPB -= bassPrunned.size-lastID; avgSPB *= secondsPerWindow; avgSPB /= bassBeats; - Gdx.app.debug("Audio Analyzer", "Avg BPS: " + avgSPB); + Gdx.app.debug("Audio Analyzer", "Avg SPB: " + avgSPB); bassAvg /= bassBeats; - umBeats /= umBeats; - + umAvg /= umBeats; + Gdx.app.debug("Audio Analyzer", "Avg bass: " + bassAvg); + Gdx.app.debug("Audio Analyzer", "Avg UM: " + umAvg); if (work) { Gdx.app.debug("Audio Analyzer", "overlapped beats checked."); diff --git a/core/src/zero1hd/polyjet/audio/map/RhythmMapAlgorithm.java b/core/src/zero1hd/polyjet/audio/map/RhythmMapAlgorithm.java index c97cc9f..9bf93d4 100755 --- a/core/src/zero1hd/polyjet/audio/map/RhythmMapAlgorithm.java +++ b/core/src/zero1hd/polyjet/audio/map/RhythmMapAlgorithm.java @@ -45,9 +45,10 @@ public class RhythmMapAlgorithm implements Runnable { this.healthMod = healthMod; umMax = analyzer.getUMMaxValue(); + avgUM = analyzer.getUmAvg(); + bassMax = analyzer.getBassMaxValue(); avgBass = analyzer.getBassAvg(); - avgUM = analyzer.getUmAvg(); } @Override @@ -56,15 +57,15 @@ public class RhythmMapAlgorithm implements Runnable { for (int index = 0; index < bassPeaks.size; index++) { if (bassPeaks.get(index) != 0 || UMPeaks.get(index) != 0) { int warningTime = (int) ((3/speedMod)*windowPerSecond); - if ((index+warningTime < bassPeaks.size) && bassPeaks.get(index + warningTime) >= avgBass*3f/4f) { + if ((index+warningTime < bassPeaks.size) && bassPeaks.get(index + warningTime) >= avgBass) { //TODO basic void circle spawning - float endRadius = bassPeaks.get(index + warningTime)/bassMax*(Polyjet.GAME_AREA_HEIGHT/4f); + float endRadius = (bassPeaks.get(index + warningTime)/bassMax)*(Polyjet.GAME_AREA_HEIGHT/2f); map.addToMap(Entities.VOID_CIRCLE, endRadius, rand.nextFloat()*Polyjet.GAME_AREA_WIDTH, rand.nextFloat()*Polyjet.GAME_AREA_HEIGHT, - endRadius/avgSPB, + endRadius/(avgSPB*0.5f), 3f/speedMod ); } @@ -78,8 +79,8 @@ public class RhythmMapAlgorithm implements Runnable { map.addToMap(Entities.PELLET, xSpawnLocation, Polyjet.GAME_AREA_HEIGHT-0.25f, - 180*rand.nextFloat()+90, - speedMod*(1f/avgSPB)); + 140*rand.nextFloat()+110f, + (Polyjet.GAME_AREA_HEIGHT/4f)/avgSPB); } } diff --git a/core/src/zero1hd/polyjet/ui/builders/AudioGraph.java b/core/src/zero1hd/polyjet/ui/builders/AudioGraph.java index 3f4b68d..ed6ef0e 100755 --- a/core/src/zero1hd/polyjet/ui/builders/AudioGraph.java +++ b/core/src/zero1hd/polyjet/ui/builders/AudioGraph.java @@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.utils.FloatArray; @@ -16,7 +17,7 @@ public class AudioGraph extends Actor { FloatArray overlayGraph; int dataIndex; int displayMode; - + public float normalDataG1 = 1f, normalDataG2 = 1f, avgG1 = 1f, avgG2 = 1f; float scale; public AudioGraph(int graphSizeW, int graphSizeH) { @@ -42,11 +43,11 @@ public class AudioGraph extends Actor { if (Gdx.input.isKeyPressed(Keys.COMMA)) { if (scale > 0.05f) { - scale -= 0.005f; + scale -= 0.05f; } } else if (Gdx.input.isKeyPressed(Keys.PERIOD)) { if (scale < audioGraph.getHeight()) { - scale += 0.005f; + scale += 0.05f; } } if (Gdx.input.isKeyJustPressed(Keys.M)) { @@ -62,28 +63,31 @@ public class AudioGraph extends Actor { audioGraph.setColor(1f, 0f, 0f, 0.75f); for (int x = 0; x < audioGraph.getWidth(); x++) { try { - audioGraph.drawLine(x, audioGraph.getHeight(), x, (int) (audioGraph.getHeight()-mainGraph.get(dataIndex+x-audioGraph.getWidth()/2)*scale)); + audioGraph.drawLine(x, audioGraph.getHeight(), x, (int) (audioGraph.getHeight()-(mainGraph.get(dataIndex+x-audioGraph.getWidth()/2)/normalDataG1)*scale)); } catch (NullPointerException | IndexOutOfBoundsException e) { } + audioGraph.drawLine(0,audioGraph.getHeight() - MathUtils.round(scale*(avgG1/normalDataG1)), audioGraph.getWidth(), audioGraph.getHeight() - MathUtils.round(scale*(avgG1/normalDataG1))); } case 1: audioGraph.setColor(0f, 0f, 1f, 0.75f); for (int x = 0; x < audioGraph.getWidth() -1; x++) { try { - audioGraph.drawLine(x, audioGraph.getHeight(), x, (int) (audioGraph.getHeight()-overlayGraph.get(dataIndex+x-audioGraph.getWidth()/2)*scale)); + audioGraph.drawLine(x, audioGraph.getHeight(), x, (int) (audioGraph.getHeight()-(overlayGraph.get(dataIndex+x-audioGraph.getWidth()/2)/normalDataG2)*scale)); } catch (NullPointerException | IndexOutOfBoundsException e) { } + audioGraph.drawLine(0, audioGraph.getHeight() - MathUtils.round(scale*(avgG2/normalDataG2)), audioGraph.getWidth(), audioGraph.getHeight() - MathUtils.round(scale*(avgG2/normalDataG2))); } break; case 2: audioGraph.setColor(1f, 0f, 0f, 0.75f); for (int x = 0; x < audioGraph.getWidth(); x++) { try { - audioGraph.drawLine(x, audioGraph.getHeight(), x, (int) (audioGraph.getHeight()-mainGraph.get(dataIndex+x-audioGraph.getWidth()/2)*scale)); + audioGraph.drawLine(x, audioGraph.getHeight(), x, (int) (audioGraph.getHeight()-(mainGraph.get(dataIndex+x-audioGraph.getWidth()/2)/normalDataG1)*scale)); } catch (NullPointerException | IndexOutOfBoundsException e) { } } + audioGraph.drawLine(0, audioGraph.getHeight() - MathUtils.round(scale*(avgG1/normalDataG1)), audioGraph.getWidth(), audioGraph.getHeight() - MathUtils.round(scale*(avgG1/normalDataG1))); break; } diff --git a/core/src/zero1hd/polyjet/ui/stages/CreativeStage.java b/core/src/zero1hd/polyjet/ui/stages/CreativeStage.java index b3fa4b6..0875e49 100755 --- a/core/src/zero1hd/polyjet/ui/stages/CreativeStage.java +++ b/core/src/zero1hd/polyjet/ui/stages/CreativeStage.java @@ -262,6 +262,10 @@ public class CreativeStage extends Stage implements MiniListener { volumeWindow.setMusic(analyzer.getAudioData()); beatViewer.setMusic(analyzer.getAudioData(), analyzer); graphViewer.setData(analyzer.getBassPeaks(), analyzer.getUMPeaks(), analyzer.getAudioData()); + graphViewer.getGraph().avgG1 = analyzer.getBassAvg(); + graphViewer.getGraph().normalDataG1 = analyzer.getBassMaxValue(); + graphViewer.getGraph().avgG2 = analyzer.getUmAvg(); + graphViewer.getGraph().normalDataG2 = analyzer.getUMMaxValue(); gpa.setAudioMap(mapGen.getMap()); break; default: diff --git a/core/src/zero1hd/polyjet/ui/windows/GraphWindow.java b/core/src/zero1hd/polyjet/ui/windows/GraphWindow.java index 702f4fb..95c1bc8 100755 --- a/core/src/zero1hd/polyjet/ui/windows/GraphWindow.java +++ b/core/src/zero1hd/polyjet/ui/windows/GraphWindow.java @@ -26,6 +26,10 @@ public class GraphWindow extends Window { super.act(delta); } + public AudioGraph getGraph() { + return graph; + } + public void setData(FloatArray dataSet1, FloatArray dataSet2, AudioData audioData) { this.audioData = audioData; graph.setGraphingData(dataSet1, dataSet2);