tuning with other songs
This commit is contained in:
parent
afd2d1aa41
commit
d65b94cd49
@ -47,7 +47,7 @@ public class AudioAnalyzer {
|
|||||||
|
|
||||||
public volatile MiniSender sender;
|
public volatile MiniSender sender;
|
||||||
|
|
||||||
private float avgBPS;
|
private float avgSPB;
|
||||||
|
|
||||||
int PUID;
|
int PUID;
|
||||||
boolean work;
|
boolean work;
|
||||||
@ -64,17 +64,17 @@ public class AudioAnalyzer {
|
|||||||
int tasksDone = 0;
|
int tasksDone = 0;
|
||||||
int totalTasks = audioData.getSampleCount()/audioData.getReadWindowSize();
|
int totalTasks = audioData.getSampleCount()/audioData.getReadWindowSize();
|
||||||
|
|
||||||
bassThresholdMultiplier = 2f;
|
bassThresholdMultiplier = 1.7f;
|
||||||
umThresholdMultiplier = 2f;
|
umThresholdMultiplier = 1.5f;
|
||||||
|
|
||||||
bassBinBegin = 1;
|
bassBinBegin = 1;
|
||||||
bassBinEnd = 20;
|
bassBinEnd = 25;
|
||||||
|
|
||||||
UMBinBegin = 300;
|
UMBinBegin = 300;
|
||||||
UMBinEnd = 450;
|
UMBinEnd = 512;
|
||||||
|
|
||||||
bassThresholdCalcRange = thresholdRangeCalc(0.35f);
|
bassThresholdCalcRange = thresholdRangeCalc(0.3f);
|
||||||
UMThresholdCalcRange = thresholdRangeCalc(0.7f);
|
UMThresholdCalcRange = thresholdRangeCalc(0.35f);
|
||||||
|
|
||||||
Gdx.app.debug("Read freq", String.valueOf(audioData.getFormat().getSampleRate()));
|
Gdx.app.debug("Read freq", String.valueOf(audioData.getFormat().getSampleRate()));
|
||||||
Gdx.app.debug("Using following bin ranges", "\nBass freq begin: " + bassBinBegin + "\nBass freq end: " + bassBinEnd + "\nMain freq begin: " + UMBinBegin + "\nMain freq end: " + UMBinEnd);
|
Gdx.app.debug("Using following bin ranges", "\nBass freq begin: " + bassBinBegin + "\nBass freq end: " + bassBinEnd + "\nMain freq begin: " + UMBinBegin + "\nMain freq end: " + UMBinEnd);
|
||||||
@ -110,13 +110,8 @@ public class AudioAnalyzer {
|
|||||||
//bass detection
|
//bass detection
|
||||||
fluxVal = 0;
|
fluxVal = 0;
|
||||||
for (int i = bassBinBegin; i < bassBinEnd && work; i++) {
|
for (int i = bassBinBegin; i < bassBinEnd && work; i++) {
|
||||||
if (spectrum[i] >= 0) {
|
fluxVal += ((spectrum[i] - lastSpectrum[i])) < 0
|
||||||
fluxVal += ((spectrum[i] - lastSpectrum[i])) < 0
|
? 0 : (spectrum[i] - lastSpectrum[i]);
|
||||||
? 0 : (spectrum[i] - lastSpectrum[i]);
|
|
||||||
} else {
|
|
||||||
fluxVal += ((spectrum[i] - lastSpectrum[i])) < 0
|
|
||||||
? 0 : (spectrum[i] - lastSpectrum[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bassSpectralFlux.add(fluxVal);
|
bassSpectralFlux.add(fluxVal);
|
||||||
|
|
||||||
@ -202,7 +197,7 @@ public class AudioAnalyzer {
|
|||||||
int lastID = 0;
|
int lastID = 0;
|
||||||
float bassBeats = 0;
|
float bassBeats = 0;
|
||||||
float umBeats = 0;
|
float umBeats = 0;
|
||||||
avgBPS = -1f;
|
avgSPB = -1f;
|
||||||
for (int i = 0; i < umPrunned.size-1 && work; i++) {
|
for (int i = 0; i < umPrunned.size-1 && work; i++) {
|
||||||
bassPeaks.add((bassPrunned.get(i) > bassPrunned.get(i+1) ? bassPrunned.get(i) : 0f));
|
bassPeaks.add((bassPrunned.get(i) > bassPrunned.get(i+1) ? bassPrunned.get(i) : 0f));
|
||||||
if (bassPeaks.get(i) > bassMaxValue) {
|
if (bassPeaks.get(i) > bassMaxValue) {
|
||||||
@ -216,21 +211,21 @@ public class AudioAnalyzer {
|
|||||||
|
|
||||||
//overlapping beats
|
//overlapping beats
|
||||||
if (bassPeaks.get(i) != 0 && umPeaks.get(i) != 0) {
|
if (bassPeaks.get(i) != 0 && umPeaks.get(i) != 0) {
|
||||||
overlappedPeaks.add(bassPeaks.get(i)+umPeaks.get(i)/2);
|
overlappedPeaks.add((bassPeaks.get(i)+umPeaks.get(i))/2f);
|
||||||
} else {
|
} else {
|
||||||
overlappedPeaks.add(0);
|
overlappedPeaks.add(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (avgBPS != -1) {
|
if (avgSPB != -1) {
|
||||||
if (bassPeaks.get(i) == 0) {
|
if (bassPeaks.get(i) == 0) {
|
||||||
avgBPS ++;
|
avgSPB ++;
|
||||||
} else {
|
} else {
|
||||||
bassBeats ++;
|
bassBeats ++;
|
||||||
lastID = i;
|
lastID = i;
|
||||||
}
|
}
|
||||||
} else if (bassPeaks.get(i) != 0) {
|
} else if (bassPeaks.get(i) != 0) {
|
||||||
avgBPS = 0;
|
avgSPB = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bassPeaks.get(i) != 0) {
|
if (bassPeaks.get(i) != 0) {
|
||||||
@ -244,10 +239,10 @@ 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
|
||||||
avgBPS -= umPrunned.size-lastID;
|
avgSPB -= umPrunned.size-lastID;
|
||||||
avgBPS *= secondsPerWindow;
|
avgSPB *= secondsPerWindow;
|
||||||
avgBPS /= bassBeats;
|
avgSPB /= bassBeats;
|
||||||
Gdx.app.debug("Audio Analyzer", "Avg BPS: " + avgBPS);
|
Gdx.app.debug("Audio Analyzer", "Avg BPS: " + avgSPB);
|
||||||
|
|
||||||
bassAvg /= bassBeats;
|
bassAvg /= bassBeats;
|
||||||
umBeats /= umBeats;
|
umBeats /= umBeats;
|
||||||
@ -357,8 +352,8 @@ public class AudioAnalyzer {
|
|||||||
return audioData;
|
return audioData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAvgBPS() {
|
public float getAvgSPB() {
|
||||||
return avgBPS;
|
return avgSPB;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getsecondsPerWindow() {
|
public float getsecondsPerWindow() {
|
||||||
|
@ -22,7 +22,8 @@ public class RhythmMapAlgorithm implements Runnable {
|
|||||||
|
|
||||||
private float avgBass;
|
private float avgBass;
|
||||||
private float avgUM;
|
private float avgUM;
|
||||||
private float avgBPS;
|
private float avgSPB;
|
||||||
|
private float umMax, bassMax;
|
||||||
|
|
||||||
private float speedMod, healthMod;
|
private float speedMod, healthMod;
|
||||||
|
|
||||||
@ -37,12 +38,14 @@ public class RhythmMapAlgorithm implements Runnable {
|
|||||||
overlappedPeaks = analyzer.getOverlappedPeaks();
|
overlappedPeaks = analyzer.getOverlappedPeaks();
|
||||||
map = new GamePlayMap(analyzer.getAudioData());
|
map = new GamePlayMap(analyzer.getAudioData());
|
||||||
rand = new MersenneTwister(analyzer.getPUID());
|
rand = new MersenneTwister(analyzer.getPUID());
|
||||||
avgBPS = analyzer.getAvgBPS();
|
avgSPB = analyzer.getAvgSPB();
|
||||||
windowPerSecond = 1/analyzer.getsecondsPerWindow();
|
windowPerSecond = 1/analyzer.getsecondsPerWindow();
|
||||||
|
|
||||||
this.speedMod = speedMod;
|
this.speedMod = speedMod;
|
||||||
this.healthMod = healthMod;
|
this.healthMod = healthMod;
|
||||||
|
|
||||||
|
umMax = analyzer.getUMMaxValue();
|
||||||
|
bassMax = analyzer.getBassMaxValue();
|
||||||
avgBass = analyzer.getBassAvg();
|
avgBass = analyzer.getBassAvg();
|
||||||
avgUM = analyzer.getUmAvg();
|
avgUM = analyzer.getUmAvg();
|
||||||
}
|
}
|
||||||
@ -53,22 +56,22 @@ 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) {
|
if ((index+warningTime < bassPeaks.size) && bassPeaks.get(index + warningTime) >= avgBass*3f/4f) {
|
||||||
//TODO basic void circle spawning
|
//TODO basic void circle spawning
|
||||||
float endRadius = overlappedPeaks.get(index + warningTime)*Polyjet.GAME_AREA_HEIGHT/4;
|
float endRadius = bassPeaks.get(index + warningTime)/bassMax*(Polyjet.GAME_AREA_HEIGHT/4f);
|
||||||
|
|
||||||
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/avgBPS,
|
endRadius/avgSPB,
|
||||||
warningTime
|
3f/speedMod
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (bassPeaks.get(index) != 0) {
|
if (bassPeaks.get(index) != 0) {
|
||||||
map.addToMap(Entities.BAR,
|
map.addToMap(Entities.BAR,
|
||||||
MathUtils.round(1.5f+rand.nextFloat()*(Polyjet.GAME_AREA_WIDTH-3)),
|
MathUtils.round(1.5f+rand.nextFloat()*(Polyjet.GAME_AREA_WIDTH-3)),
|
||||||
(8f/avgBPS)*speedMod);
|
(8f/avgSPB)*speedMod);
|
||||||
} else {
|
} else {
|
||||||
if (UMPeaks.get(index) != 0) {
|
if (UMPeaks.get(index) != 0) {
|
||||||
float xSpawnLocation = (rand.nextFloat()*(Polyjet.GAME_AREA_WIDTH-2))+1;
|
float xSpawnLocation = (rand.nextFloat()*(Polyjet.GAME_AREA_WIDTH-2))+1;
|
||||||
@ -76,7 +79,7 @@ public class RhythmMapAlgorithm implements Runnable {
|
|||||||
xSpawnLocation,
|
xSpawnLocation,
|
||||||
Polyjet.GAME_AREA_HEIGHT-0.25f,
|
Polyjet.GAME_AREA_HEIGHT-0.25f,
|
||||||
180*rand.nextFloat()+90,
|
180*rand.nextFloat()+90,
|
||||||
speedMod*(1f/avgBPS));
|
speedMod*(1f/avgSPB));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ public class Pellet extends Actor implements Entity, Poolable {
|
|||||||
setSize(0.75f, 0.75f);
|
setSize(0.75f, 0.75f);
|
||||||
hitBox.setSize(getWidth(), getHeight());
|
hitBox.setSize(getWidth(), getHeight());
|
||||||
this.rate = rate;
|
this.rate = rate;
|
||||||
setColor(1f, MathUtils.random(), 0f, 1f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,10 +114,8 @@ public class GamePlayArea extends Stage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
if (audioMap != null && time < audioMap.getPlayTime()) {
|
|
||||||
time += delta;
|
|
||||||
}
|
|
||||||
if (audioMap != null) {
|
if (audioMap != null) {
|
||||||
|
time = audioMap.getPlayableClip().getPosition();
|
||||||
ec.spawnEntity(this, audioMap.safeNextEntity());
|
ec.spawnEntity(this, audioMap.safeNextEntity());
|
||||||
}
|
}
|
||||||
collisionDetector.collisionCheck();
|
collisionDetector.collisionCheck();
|
||||||
|
@ -4,6 +4,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.InvalidParameterException;
|
import java.security.InvalidParameterException;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
|
|
||||||
public class WavDecoder {
|
public class WavDecoder {
|
||||||
@ -56,10 +57,14 @@ public class WavDecoder {
|
|||||||
|
|
||||||
String moreInfo = readBytesToString(4);
|
String moreInfo = readBytesToString(4);
|
||||||
if (moreInfo.equals("LIST")) { // 4
|
if (moreInfo.equals("LIST")) { // 4
|
||||||
readStream.skip(30);
|
while (true) {
|
||||||
if (!readBytesToString(4).equals("data")) {
|
if (readBytesToString(1).equals("d")) {
|
||||||
throw new InvalidParameterException("failed to read data with extra info.");
|
if (readBytesToString(3).equals("ata")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!moreInfo.equals("data")) {
|
} else if (!moreInfo.equals("data")) {
|
||||||
throw new InvalidParameterException("failed to read data.");
|
throw new InvalidParameterException("failed to read data.");
|
||||||
}
|
}
|
||||||
@ -132,7 +137,7 @@ public class WavDecoder {
|
|||||||
for (int channel = 0; channel < getChannels(); channel++) {
|
for (int channel = 0; channel < getChannels(); channel++) {
|
||||||
currentSample += readLittleEndianShort();
|
currentSample += readLittleEndianShort();
|
||||||
}
|
}
|
||||||
currentSample /= getChannels()*Short.MAX_VALUE+1;
|
currentSample /= getChannels() * Short.MAX_VALUE+1;
|
||||||
samples[i] = currentSample;
|
samples[i] = currentSample;
|
||||||
samplesRead++;
|
samplesRead++;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user