cleaned code and tuned audio analyzer
This commit is contained in:
@@ -65,7 +65,7 @@ public class AudioAnalyzer {
|
||||
UMThresholdMultiplier = 2f;
|
||||
|
||||
bassBinBegin = 1;
|
||||
bassBinEnd = 17;
|
||||
bassBinEnd = 15;
|
||||
|
||||
UMBinBegin = 300;
|
||||
UMBinEnd = 450;
|
||||
|
@@ -3,8 +3,9 @@ package zero1hd.polyjet.audio;
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
public interface AudioData {
|
||||
public interface AudioData extends Disposable {
|
||||
/**
|
||||
* sets a integer variable to the current window of audio data the playback is at.
|
||||
* Useful for efficiency because we compute once for that frame then get the values everytime it is required instead of calculating every time we get the index.
|
||||
|
@@ -20,7 +20,6 @@ import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
|
||||
import javazoom.jl.decoder.Decoder;
|
||||
import javazoom.spi.mpeg.sampled.convert.DecodedMpegAudioInputStream;
|
||||
|
||||
public class Mp3AudioData implements AudioData {
|
||||
private int readWindowSize = 1024;
|
||||
@@ -35,8 +34,6 @@ public class Mp3AudioData implements AudioData {
|
||||
|
||||
private AudioInputStream in;
|
||||
|
||||
DecodedMpegAudioInputStream dStream;
|
||||
|
||||
Decoder decoder = new Decoder();
|
||||
public Mp3AudioData(FileHandle audioFile) {
|
||||
try {
|
||||
@@ -149,4 +146,15 @@ public class Mp3AudioData implements AudioData {
|
||||
return sampleCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
playbackMusic.dispose();
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -8,11 +8,10 @@ import javax.sound.sampled.AudioFormat;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
import zero1hd.wavedecoder.WavDecoder;
|
||||
|
||||
public class WavAudioData implements AudioData, Disposable {
|
||||
public class WavAudioData implements AudioData {
|
||||
private int readWindowSize = 1024;
|
||||
private AudioFormat format;
|
||||
int readIndex;
|
||||
@@ -78,5 +77,6 @@ public class WavAudioData implements AudioData, Disposable {
|
||||
@Override
|
||||
public void dispose() {
|
||||
playbackMusic.dispose();
|
||||
decoder.cleanAndClose();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user