progress on better system for audio managers

This commit is contained in:
Harrison Deng 2017-12-11 00:44:43 -06:00
parent 51ce146611
commit fa93634b9e
3 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,5 @@
package zero1hd.rhythmbullet.audio; package zero1hd.rhythmbullet.audio;
import java.io.BufferedInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -103,7 +102,9 @@ public class Mp3Manager implements MusicManager {
@Override @Override
public void setReadIndexToPlaybackIndex() { public void setReadIndexToPlaybackIndex() {
try { try {
raf.seek((long) (getPositionInSeconds()*(long)sampleRate)); long pointer = (long) (getPositionInSeconds()*(long)sampleRate)-readWindowSize;
raf.seek(pointer);
readWindowIndex = (int) (pointer/readWindowSize);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -58,7 +58,9 @@ public class WAVManager implements MusicManager {
@Override @Override
public void setReadIndexToPlaybackIndex() { public void setReadIndexToPlaybackIndex() {
try { try {
raf.seek((long) (getPositionInSeconds()*(long)getSampleRate())); long pointer = (long) (getPositionInSeconds()*(long)getSampleRate())-readWindowSize;
raf.seek(pointer);
readWindowIndex = (int) (pointer/readWindowSize);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -24,7 +24,7 @@ public class VisualizerCore implements Disposable {
this.width = width; this.width = width;
this.xPos = x; this.xPos = x;
this.yPos = y; this.yPos = y;
updateRate = 1f/30f; updateRate = 1f/60f;
lock = new ReentrantLock(); lock = new ReentrantLock();
} }