cleaning up and preparing for reflection visuals and music synchronization

This commit is contained in:
2018-01-03 22:39:43 -06:00
parent 2b1b8ba620
commit f292d6f81c
5 changed files with 183 additions and 185 deletions

View File

@@ -32,11 +32,7 @@ public class VisualizerCore implements Disposable {
if (mm != null && calc && mm.isPlaying()) {
updateTimer += delta;
if (updateTimer >= updateRate) {
mm.playbackIndexUpdate();
System.out.println(mm.getPlaybackIndexPosition() + "vs" + mm.getReadIndex());
while (mm.getPlaybackIndexPosition() > mm.getReadIndex()) {
mm.skipReadWindow();
}
//TODO use current buffer being played
lock.lock();
mm.readSamples(audioPCM);
fft.realForward(audioPCM);

View File

@@ -4,14 +4,14 @@ import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
public class AudioSampleReader {
public class WAVSampleReader {
private int channels;
private double sampleRate;
private byte[] buffer;
private AudioInputStream audioInputStream;
private boolean mergeChannels;
public AudioSampleReader(AudioInputStream ais) throws IOException {
public WAVSampleReader(AudioInputStream ais) throws IOException {
audioInputStream = ais;
buffer = new byte[audioInputStream.getFormat().getFrameSize()];

View File

@@ -83,14 +83,8 @@ public interface MusicManager extends Disposable {
public FileHandle getMusicFile();
/**
* Synchronizes the playback and read threads
* @return the amount of windows that have been read.
*/
public void synchronize();
public int framesRead();
/**
* @return the window that the current read index is on
*/
public int getReadIndex();
public void skipReadWindow();
}