progress working on rhythm map
This commit is contained in:
parent
fb10f2081e
commit
329ff21c75
@ -36,7 +36,7 @@ public class AudioAnalyzer {
|
||||
private FloatArray UMPeaks = new FloatArray();
|
||||
private float UMMaxValue;
|
||||
|
||||
private FloatArray overlappedBeats = new FloatArray();
|
||||
private FloatArray overlappedPeaks = new FloatArray();
|
||||
|
||||
float bassThresholdMultiplier;
|
||||
float UMThresholdMultiplier;
|
||||
@ -204,9 +204,9 @@ public class AudioAnalyzer {
|
||||
//overlapping beats
|
||||
for (int i = 0; i < UMPeaks.size && work; i++) {
|
||||
if (bassPeaks.get(i) != 0 && UMPeaks.get(i) != 0) {
|
||||
overlappedBeats.add(bassPeaks.get(i)+UMPeaks.get(i)/2);
|
||||
overlappedPeaks.add(bassPeaks.get(i)+UMPeaks.get(i)/2);
|
||||
} else {
|
||||
overlappedBeats.add(0);
|
||||
overlappedPeaks.add(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ public class AudioAnalyzer {
|
||||
UMPrunned.shrink();
|
||||
UMPeaks.shrink();
|
||||
|
||||
overlappedBeats.shrink();
|
||||
overlappedPeaks.shrink();
|
||||
}
|
||||
|
||||
public void startAnalyticalThread(AudioData audiofile) {
|
||||
@ -306,4 +306,8 @@ public class AudioAnalyzer {
|
||||
public int getPUID() {
|
||||
return PUID;
|
||||
}
|
||||
|
||||
public FloatArray getOverlappedPeaks() {
|
||||
return overlappedPeaks;
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
package zero1hd.polyjet.audio;
|
||||
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
|
||||
public class GamePlayMap {
|
||||
private Music playableClip;
|
||||
private float playTime;
|
||||
|
||||
public GamePlayMap(AudioData audioData) {
|
||||
playableClip = audioData.getPlaybackMusic();
|
||||
playTime = audioData.getDuration();
|
||||
}
|
||||
|
||||
public Music getPlayableClip() {
|
||||
return playableClip;
|
||||
}
|
||||
|
||||
public float getPlayTime() {
|
||||
return playTime;
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
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() {
|
||||
}
|
||||
}
|
22
core/src/zero1hd/polyjet/audio/map/EntitySpawnInfo.java
Executable file
22
core/src/zero1hd/polyjet/audio/map/EntitySpawnInfo.java
Executable file
@ -0,0 +1,22 @@
|
||||
package zero1hd.polyjet.audio.map;
|
||||
|
||||
import zero1hd.polyjet.entity.Entities;
|
||||
|
||||
public class EntitySpawnInfo {
|
||||
private Entities entityType;
|
||||
private double[] parameters;
|
||||
|
||||
public EntitySpawnInfo(Entities entityType, double... parameters) {
|
||||
this.entityType = entityType;
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public Entities getEntityType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return entityType.name() + ": " + parameters.length;
|
||||
}
|
||||
}
|
100
core/src/zero1hd/polyjet/audio/map/GamePlayMap.java
Executable file
100
core/src/zero1hd/polyjet/audio/map/GamePlayMap.java
Executable file
@ -0,0 +1,100 @@
|
||||
package zero1hd.polyjet.audio.map;
|
||||
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import zero1hd.polyjet.audio.AudioData;
|
||||
import zero1hd.polyjet.entity.Entities;
|
||||
|
||||
public class GamePlayMap {
|
||||
private Music playableClip;
|
||||
private float playTime;
|
||||
private Array<EntitySpawnInfo> spawnList;
|
||||
private boolean building;
|
||||
private int index;
|
||||
|
||||
/**
|
||||
* GamePlayMap is what the game area will use to generate entities and judge current audio data
|
||||
* @param audioData audio data
|
||||
*/
|
||||
public GamePlayMap(AudioData audioData) {
|
||||
playableClip = audioData.getPlaybackMusic();
|
||||
playTime = audioData.getDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns audio data
|
||||
* @return
|
||||
*/
|
||||
public Music getPlayableClip() {
|
||||
return playableClip;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the runtime time of the overall song
|
||||
* @return
|
||||
*/
|
||||
public float getPlayTime() {
|
||||
return playTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* call this when beginning to build map
|
||||
*/
|
||||
public void start() {
|
||||
building = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* call this when finishing building map
|
||||
*/
|
||||
public void end() {
|
||||
building = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* used to add data types for what entity to spawn at that index position
|
||||
* cannot be null.
|
||||
* @param entityType what type of entity to spawn
|
||||
* @param parameters the arguments for the entity. It is important to have the same amount of parameters the entity requires to spawn
|
||||
*/
|
||||
public void addToMap(Entities entityType, double... parameters) {
|
||||
if (building && entityType != null && parameters != null) {
|
||||
spawnList.add(new EntitySpawnInfo(entityType, parameters));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* use this to add rest for current index position
|
||||
*/
|
||||
public void addRestToMap() {
|
||||
if (building) {
|
||||
spawnList.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only works when not started.
|
||||
* retrieve next entity in list.
|
||||
* @return
|
||||
*/
|
||||
public EntitySpawnInfo nextEntity() {
|
||||
if (!building) {
|
||||
index++;
|
||||
|
||||
EntitySpawnInfo spawnInfo = spawnList.get(index);
|
||||
return spawnInfo;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set retrieve entity index position.
|
||||
* @param index
|
||||
*/
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
}
|
36
core/src/zero1hd/polyjet/audio/map/RhythmMapAlgorithm.java
Executable file
36
core/src/zero1hd/polyjet/audio/map/RhythmMapAlgorithm.java
Executable file
@ -0,0 +1,36 @@
|
||||
package zero1hd.polyjet.audio.map;
|
||||
|
||||
import org.apache.commons.math3.random.MersenneTwister;
|
||||
|
||||
import com.badlogic.gdx.utils.FloatArray;
|
||||
|
||||
import zero1hd.polyjet.audio.AudioAnalyzer;
|
||||
|
||||
public class RhythmMapAlgorithm implements Runnable {
|
||||
private FloatArray bassPeaks;
|
||||
private FloatArray UMPeaks;
|
||||
private FloatArray overlappedPeaks;
|
||||
private MersenneTwister rand;
|
||||
public RhythmMapAlgorithm(AudioAnalyzer analyzer) {
|
||||
bassPeaks = analyzer.getBassPeaks();
|
||||
UMPeaks = analyzer.getUMPeaks();
|
||||
overlappedPeaks = analyzer.getOverlappedPeaks();
|
||||
rand = new MersenneTwister(analyzer.getPUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (int index = 0; index < bassPeaks.size; index++) {
|
||||
if (overlappedPeaks.get(index) != 0) {
|
||||
//TODO basic void spawning
|
||||
} else if (bassPeaks.get(index) != 0) {
|
||||
//TODO basic bar spawning
|
||||
} else {
|
||||
if (UMPeaks.get(index) != 0) {
|
||||
//TODO basic pellet scatter spawn
|
||||
}
|
||||
//TODO rest of the basic generation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,6 @@ import zero1hd.polyjet.entity.Entities;
|
||||
import zero1hd.polyjet.entity.Entity;
|
||||
|
||||
public class VoidCircle extends Actor implements Entity, Poolable {
|
||||
private float warnTime;
|
||||
private float timer;
|
||||
private float endRadius;
|
||||
private float currentRadius;
|
||||
@ -32,7 +31,6 @@ public VoidCircle(Texture voidTexture) {
|
||||
|
||||
public void init(float endRadius, float x, float y, float growthRate, float warningTime) {
|
||||
timer = warningTime;
|
||||
warnTime = warningTime;
|
||||
this.endRadius = endRadius;
|
||||
setSize(2f*endRadius, 2f*endRadius);
|
||||
center.set(getWidth()/2f, getHeight()/2f);
|
||||
@ -89,7 +87,6 @@ public VoidCircle(Texture voidTexture) {
|
||||
endRadius = 0;
|
||||
done = false;
|
||||
begin = false;
|
||||
warnTime = 0;
|
||||
center.set(0, 0);
|
||||
voidCircleTexture.setPosition(0, 0);
|
||||
setSize(0, 0);
|
||||
|
@ -19,7 +19,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
import zero1hd.polyjet.Polyjet;
|
||||
import zero1hd.polyjet.audio.AudioData;
|
||||
import zero1hd.polyjet.audio.GamePlayMap;
|
||||
import zero1hd.polyjet.audio.map.GamePlayMap;
|
||||
import zero1hd.polyjet.ui.stages.GamePlayArea;
|
||||
import zero1hd.polyjet.ui.windows.FPSWindow;
|
||||
|
||||
|
@ -9,7 +9,7 @@ import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||
|
||||
import zero1hd.polyjet.Polyjet;
|
||||
import zero1hd.polyjet.audio.GamePlayMap;
|
||||
import zero1hd.polyjet.audio.map.GamePlayMap;
|
||||
import zero1hd.polyjet.controls.KeyMap;
|
||||
import zero1hd.polyjet.entity.CollisionDetector;
|
||||
import zero1hd.polyjet.entity.Entities;
|
||||
|
Loading…
Reference in New Issue
Block a user