improved debugging and more adjustments
This commit is contained in:
parent
d65b94cd49
commit
da494d22a3
@ -221,7 +221,6 @@ public class AudioAnalyzer {
|
|||||||
if (bassPeaks.get(i) == 0) {
|
if (bassPeaks.get(i) == 0) {
|
||||||
avgSPB ++;
|
avgSPB ++;
|
||||||
} else {
|
} else {
|
||||||
bassBeats ++;
|
|
||||||
lastID = i;
|
lastID = i;
|
||||||
}
|
}
|
||||||
} else if (bassPeaks.get(i) != 0) {
|
} else if (bassPeaks.get(i) != 0) {
|
||||||
@ -230,6 +229,8 @@ public class AudioAnalyzer {
|
|||||||
|
|
||||||
if (bassPeaks.get(i) != 0) {
|
if (bassPeaks.get(i) != 0) {
|
||||||
bassAvg += bassPeaks.get(i);
|
bassAvg += bassPeaks.get(i);
|
||||||
|
bassBeats++;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (umPeaks.get(i) != 0) {
|
if (umPeaks.get(i) != 0) {
|
||||||
umAvg += umPeaks.get(i);
|
umAvg += umPeaks.get(i);
|
||||||
@ -239,14 +240,15 @@ 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
|
||||||
avgSPB -= umPrunned.size-lastID;
|
avgSPB -= bassPrunned.size-lastID;
|
||||||
avgSPB *= secondsPerWindow;
|
avgSPB *= secondsPerWindow;
|
||||||
avgSPB /= bassBeats;
|
avgSPB /= bassBeats;
|
||||||
Gdx.app.debug("Audio Analyzer", "Avg BPS: " + avgSPB);
|
Gdx.app.debug("Audio Analyzer", "Avg SPB: " + avgSPB);
|
||||||
|
|
||||||
bassAvg /= bassBeats;
|
bassAvg /= bassBeats;
|
||||||
umBeats /= umBeats;
|
umAvg /= umBeats;
|
||||||
|
Gdx.app.debug("Audio Analyzer", "Avg bass: " + bassAvg);
|
||||||
|
Gdx.app.debug("Audio Analyzer", "Avg UM: " + umAvg);
|
||||||
|
|
||||||
if (work) {
|
if (work) {
|
||||||
Gdx.app.debug("Audio Analyzer", "overlapped beats checked.");
|
Gdx.app.debug("Audio Analyzer", "overlapped beats checked.");
|
||||||
|
@ -45,9 +45,10 @@ public class RhythmMapAlgorithm implements Runnable {
|
|||||||
this.healthMod = healthMod;
|
this.healthMod = healthMod;
|
||||||
|
|
||||||
umMax = analyzer.getUMMaxValue();
|
umMax = analyzer.getUMMaxValue();
|
||||||
|
avgUM = analyzer.getUmAvg();
|
||||||
|
|
||||||
bassMax = analyzer.getBassMaxValue();
|
bassMax = analyzer.getBassMaxValue();
|
||||||
avgBass = analyzer.getBassAvg();
|
avgBass = analyzer.getBassAvg();
|
||||||
avgUM = analyzer.getUmAvg();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,15 +57,15 @@ public class RhythmMapAlgorithm implements Runnable {
|
|||||||
for (int index = 0; index < bassPeaks.size; index++) {
|
for (int index = 0; index < bassPeaks.size; index++) {
|
||||||
if (bassPeaks.get(index) != 0 || UMPeaks.get(index) != 0) {
|
if (bassPeaks.get(index) != 0 || UMPeaks.get(index) != 0) {
|
||||||
int warningTime = (int) ((3/speedMod)*windowPerSecond);
|
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
|
//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,
|
map.addToMap(Entities.VOID_CIRCLE,
|
||||||
endRadius,
|
endRadius,
|
||||||
rand.nextFloat()*Polyjet.GAME_AREA_WIDTH,
|
rand.nextFloat()*Polyjet.GAME_AREA_WIDTH,
|
||||||
rand.nextFloat()*Polyjet.GAME_AREA_HEIGHT,
|
rand.nextFloat()*Polyjet.GAME_AREA_HEIGHT,
|
||||||
endRadius/avgSPB,
|
endRadius/(avgSPB*0.5f),
|
||||||
3f/speedMod
|
3f/speedMod
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -78,8 +79,8 @@ public class RhythmMapAlgorithm implements Runnable {
|
|||||||
map.addToMap(Entities.PELLET,
|
map.addToMap(Entities.PELLET,
|
||||||
xSpawnLocation,
|
xSpawnLocation,
|
||||||
Polyjet.GAME_AREA_HEIGHT-0.25f,
|
Polyjet.GAME_AREA_HEIGHT-0.25f,
|
||||||
180*rand.nextFloat()+90,
|
140*rand.nextFloat()+110f,
|
||||||
speedMod*(1f/avgSPB));
|
(Polyjet.GAME_AREA_HEIGHT/4f)/avgSPB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Pixmap;
|
|||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.utils.FloatArray;
|
import com.badlogic.gdx.utils.FloatArray;
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ public class AudioGraph extends Actor {
|
|||||||
FloatArray overlayGraph;
|
FloatArray overlayGraph;
|
||||||
int dataIndex;
|
int dataIndex;
|
||||||
int displayMode;
|
int displayMode;
|
||||||
|
public float normalDataG1 = 1f, normalDataG2 = 1f, avgG1 = 1f, avgG2 = 1f;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
public AudioGraph(int graphSizeW, int graphSizeH) {
|
public AudioGraph(int graphSizeW, int graphSizeH) {
|
||||||
@ -42,11 +43,11 @@ public class AudioGraph extends Actor {
|
|||||||
|
|
||||||
if (Gdx.input.isKeyPressed(Keys.COMMA)) {
|
if (Gdx.input.isKeyPressed(Keys.COMMA)) {
|
||||||
if (scale > 0.05f) {
|
if (scale > 0.05f) {
|
||||||
scale -= 0.005f;
|
scale -= 0.05f;
|
||||||
}
|
}
|
||||||
} else if (Gdx.input.isKeyPressed(Keys.PERIOD)) {
|
} else if (Gdx.input.isKeyPressed(Keys.PERIOD)) {
|
||||||
if (scale < audioGraph.getHeight()) {
|
if (scale < audioGraph.getHeight()) {
|
||||||
scale += 0.005f;
|
scale += 0.05f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Gdx.input.isKeyJustPressed(Keys.M)) {
|
if (Gdx.input.isKeyJustPressed(Keys.M)) {
|
||||||
@ -62,28 +63,31 @@ public class AudioGraph extends Actor {
|
|||||||
audioGraph.setColor(1f, 0f, 0f, 0.75f);
|
audioGraph.setColor(1f, 0f, 0f, 0.75f);
|
||||||
for (int x = 0; x < audioGraph.getWidth(); x++) {
|
for (int x = 0; x < audioGraph.getWidth(); x++) {
|
||||||
try {
|
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) {
|
} 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:
|
case 1:
|
||||||
audioGraph.setColor(0f, 0f, 1f, 0.75f);
|
audioGraph.setColor(0f, 0f, 1f, 0.75f);
|
||||||
for (int x = 0; x < audioGraph.getWidth() -1; x++) {
|
for (int x = 0; x < audioGraph.getWidth() -1; x++) {
|
||||||
try {
|
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) {
|
} catch (NullPointerException | IndexOutOfBoundsException e) {
|
||||||
}
|
}
|
||||||
|
audioGraph.drawLine(0, audioGraph.getHeight() - MathUtils.round(scale*(avgG2/normalDataG2)), audioGraph.getWidth(), audioGraph.getHeight() - MathUtils.round(scale*(avgG2/normalDataG2)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
audioGraph.setColor(1f, 0f, 0f, 0.75f);
|
audioGraph.setColor(1f, 0f, 0f, 0.75f);
|
||||||
for (int x = 0; x < audioGraph.getWidth(); x++) {
|
for (int x = 0; x < audioGraph.getWidth(); x++) {
|
||||||
try {
|
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) {
|
} catch (NullPointerException | IndexOutOfBoundsException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
audioGraph.drawLine(0, audioGraph.getHeight() - MathUtils.round(scale*(avgG1/normalDataG1)), audioGraph.getWidth(), audioGraph.getHeight() - MathUtils.round(scale*(avgG1/normalDataG1)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,6 +262,10 @@ public class CreativeStage extends Stage implements MiniListener {
|
|||||||
volumeWindow.setMusic(analyzer.getAudioData());
|
volumeWindow.setMusic(analyzer.getAudioData());
|
||||||
beatViewer.setMusic(analyzer.getAudioData(), analyzer);
|
beatViewer.setMusic(analyzer.getAudioData(), analyzer);
|
||||||
graphViewer.setData(analyzer.getBassPeaks(), analyzer.getUMPeaks(), analyzer.getAudioData());
|
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());
|
gpa.setAudioMap(mapGen.getMap());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -26,6 +26,10 @@ public class GraphWindow extends Window {
|
|||||||
super.act(delta);
|
super.act(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AudioGraph getGraph() {
|
||||||
|
return graph;
|
||||||
|
}
|
||||||
|
|
||||||
public void setData(FloatArray dataSet1, FloatArray dataSet2, AudioData audioData) {
|
public void setData(FloatArray dataSet1, FloatArray dataSet2, AudioData audioData) {
|
||||||
this.audioData = audioData;
|
this.audioData = audioData;
|
||||||
graph.setGraphingData(dataSet1, dataSet2);
|
graph.setGraphingData(dataSet1, dataSet2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user