map algorithm and analysis page progress

This commit is contained in:
2017-07-10 23:54:49 -05:00
parent 1573884e99
commit 0cf0609442
5 changed files with 148 additions and 32 deletions

View File

@@ -50,7 +50,7 @@ public class AudioAnalyzer {
int PUID;
boolean work;
private volatile int progress;
private float secondsPerFrame;
private float secondsPerWindow;
public AudioAnalyzer() {
sender = new MiniSender();
@@ -190,7 +190,7 @@ public class AudioAnalyzer {
}
Gdx.app.debug("Audio Analyzer", "Data prunned.");
secondsPerFrame = audioData.getReadWindowSize()/audioData.getFormat().getSampleRate();
secondsPerWindow = audioData.getReadWindowSize()/audioData.getFormat().getSampleRate();
//peak detection
int lastID = 0;
@@ -225,7 +225,7 @@ public class AudioAnalyzer {
}
//then we minus one from the beats so it actually works out
avgBPS -= UMPrunned.size-lastID;
avgBPS *= secondsPerFrame;
avgBPS *= secondsPerWindow;
avgBPS = beats/avgBPS;
}
@@ -266,9 +266,9 @@ public class AudioAnalyzer {
analyticalThread.start();
}
public void runThresholdCleaning(float baseThresholdMultiplier, float UMThresholdMultiplier) {
this.bassThresholdMultiplier = baseThresholdMultiplier;
this.UMThresholdMultiplier = UMThresholdMultiplier;
public void runThresholdCleaning(float rangeModifier) {
this.bassThresholdMultiplier += rangeModifier;
this.UMThresholdMultiplier += rangeModifier;
work = true;
Thread thresholdClean = new Thread(thresholdCalculator);
thresholdClean.start();
@@ -339,7 +339,7 @@ public class AudioAnalyzer {
return avgBPS;
}
public float getsecondsPerFrame() {
return secondsPerFrame;
public float getsecondsPerWindow() {
return secondsPerWindow;
}
}

View File

@@ -16,15 +16,23 @@ public class RhythmMapAlgorithm implements Runnable {
private MersenneTwister rand;
private GamePlayMap map;
private float avgBPS;
private float second;
public RhythmMapAlgorithm(AudioAnalyzer analyzer) {
private float speedMod, healthMod;
private float windowPerSecond;
private volatile int progress;
public RhythmMapAlgorithm(AudioAnalyzer analyzer, float speedMod, float healthMod) {
bassPeaks = analyzer.getBassPeaks();
UMPeaks = analyzer.getUMPeaks();
overlappedPeaks = analyzer.getOverlappedPeaks();
map = new GamePlayMap(analyzer.getAudioData());
rand = new MersenneTwister(analyzer.getPUID());
avgBPS = analyzer.getAvgBPS();
second = analyzer.getsecondsPerFrame();
windowPerSecond = 1/analyzer.getsecondsPerWindow();
this.speedMod = speedMod;
this.healthMod = healthMod;
}
@Override
@@ -32,22 +40,23 @@ public class RhythmMapAlgorithm implements Runnable {
map.beginBuild();
for (int index = 0; index < bassPeaks.size; index++) {
if (bassPeaks.get(index) != 0 || UMPeaks.get(index) != 0) {
if (overlappedPeaks.get(index+3) != 0) {
int warningTime = (int) ((3/speedMod)*windowPerSecond);
if (overlappedPeaks.get(index + warningTime) != 0) {
//TODO basic void circle spawning
float endRadius = rand.nextFloat()*Polyjet.GAME_AREA_WIDTH;
float endRadius = overlappedPeaks.get(index+3)*Polyjet.GAME_AREA_WIDTH;
map.addToMap(Entities.VOID_CIRCLE,
endRadius,
rand.nextFloat()*Polyjet.GAME_AREA_WIDTH,
rand.nextFloat()*Polyjet.GAME_AREA_HEIGHT,
avgBPS,
3f*second
endRadius/avgBPS,
warningTime
);
}
if (bassPeaks.get(index) != 0) {
map.addToMap(Entities.BAR,
MathUtils.round(rand.nextFloat()*Polyjet.GAME_AREA_WIDTH),
bassPeaks.get(index)*Polyjet.GAME_AREA_HEIGHT/avgBPS);
((Polyjet.GAME_AREA_HEIGHT-bassPeaks.get(index)*Polyjet.GAME_AREA_HEIGHT)/avgBPS)*speedMod);
} else {
if (UMPeaks.get(index) != 0) {
//TODO basic pellet scatter spawn
@@ -57,6 +66,8 @@ public class RhythmMapAlgorithm implements Runnable {
} else {
map.addRestToMap();
}
progress = (int) (100f*index/bassPeaks.size);
}
map.endBuild();
}
@@ -64,4 +75,8 @@ public class RhythmMapAlgorithm implements Runnable {
public synchronized GamePlayMap getMap() {
return map;
}
public synchronized int getProgress() {
return progress;
}
}