progress working on rhythm map

This commit is contained in:
2017-06-23 15:31:36 -05:00
parent fb10f2081e
commit 329ff21c75
9 changed files with 168 additions and 46 deletions

View 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;
}
}

View 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;
}
}

View 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
}
}
}
}