adjustments for visualizer

This commit is contained in:
Harrison Deng 2018-01-13 01:24:32 -06:00
parent 4d6cbaa652
commit b07c9ffd44
2 changed files with 4 additions and 3 deletions

View File

@ -106,7 +106,7 @@ public class BasicVisualizer extends VisualizerCore {
public void setMM(MusicManager mm) {
maxAvgHeight = 0;
currentAvg = 0;
float validBins = (6400/((mm.getSampleRate()/2)/((mm.getReadWindowSize()/2)+1)));
float validBins = (9000/((mm.getSampleRate()/2)/((mm.getReadWindowSize()/2)+1)));
Gdx.app.debug("Visualizer", "valid frequency bins " + validBins);
binsPerBar = MathUtils.round((validBins/barCount));
barHeights = new float[barCount];

View File

@ -29,7 +29,7 @@ public class Visualizer extends Widget implements Disposable {
private ShortBuffer compareBuffer;
private ShortBuffer buffer;
private int sourceID;
private float visRefreshRate = 1f/60f;
private float visRefreshRate;
private float timer;
private int readWindowIndex;
public Visualizer() {
@ -60,6 +60,7 @@ public class Visualizer extends Widget implements Disposable {
+ "\nDuration in seconds: " + mm.getDuration() +
"\nSample rate: " + mm.getSampleRate());
vis.setMM(mm);
visRefreshRate = mm.getReadWindowSize()/mm.getSampleRate();
mmSet = true;
}
@ -152,7 +153,7 @@ public class Visualizer extends Widget implements Disposable {
}
int originalPos = buffer.position();
System.out.println(visRefreshRate);
prevBuffer = ShortBuffer.allocate(buffer.capacity());
buffer.rewind();
prevBuffer.put(buffer);