From fa93634b9ec87e3ac0e48bdb38ffb810332270d8 Mon Sep 17 00:00:00 2001 From: Recrown Date: Mon, 11 Dec 2017 00:44:43 -0600 Subject: [PATCH] progress on better system for audio managers --- core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java | 5 +++-- core/src/zero1hd/rhythmbullet/audio/WAVManager.java | 4 +++- .../rhythmbullet/audio/visualizer/VisualizerCore.java | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java index 630c96d..aa300f1 100755 --- a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java +++ b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java @@ -1,6 +1,5 @@ package zero1hd.rhythmbullet.audio; -import java.io.BufferedInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -103,7 +102,9 @@ public class Mp3Manager implements MusicManager { @Override public void setReadIndexToPlaybackIndex() { try { - raf.seek((long) (getPositionInSeconds()*(long)sampleRate)); + long pointer = (long) (getPositionInSeconds()*(long)sampleRate)-readWindowSize; + raf.seek(pointer); + readWindowIndex = (int) (pointer/readWindowSize); } catch (IOException e) { e.printStackTrace(); } diff --git a/core/src/zero1hd/rhythmbullet/audio/WAVManager.java b/core/src/zero1hd/rhythmbullet/audio/WAVManager.java index e10d211..089f625 100755 --- a/core/src/zero1hd/rhythmbullet/audio/WAVManager.java +++ b/core/src/zero1hd/rhythmbullet/audio/WAVManager.java @@ -58,7 +58,9 @@ public class WAVManager implements MusicManager { @Override public void setReadIndexToPlaybackIndex() { try { - raf.seek((long) (getPositionInSeconds()*(long)getSampleRate())); + long pointer = (long) (getPositionInSeconds()*(long)getSampleRate())-readWindowSize; + raf.seek(pointer); + readWindowIndex = (int) (pointer/readWindowSize); } catch (IOException e) { e.printStackTrace(); } diff --git a/core/src/zero1hd/rhythmbullet/audio/visualizer/VisualizerCore.java b/core/src/zero1hd/rhythmbullet/audio/visualizer/VisualizerCore.java index 55bb058..4c412ce 100755 --- a/core/src/zero1hd/rhythmbullet/audio/visualizer/VisualizerCore.java +++ b/core/src/zero1hd/rhythmbullet/audio/visualizer/VisualizerCore.java @@ -24,7 +24,7 @@ public class VisualizerCore implements Disposable { this.width = width; this.xPos = x; this.yPos = y; - updateRate = 1f/30f; + updateRate = 1f/60f; lock = new ReentrantLock(); }