temporarily disabled mp3's, began adding small event system
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
package zero1hd.polyjet.audio;
|
||||
|
||||
import org.jaudiotagger.audio.AudioFile;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.FloatArray;
|
||||
|
||||
import edu.emory.mathcs.jtransforms.fft.FloatFFT_1D;
|
||||
import zero1hd.polyjet.util.MiniEvents;
|
||||
import zero1hd.polyjet.util.MiniListener;
|
||||
|
||||
public class AudioAnalyzer {
|
||||
private boolean containsData;
|
||||
|
||||
private boolean finalized;
|
||||
FloatFFT_1D fft;
|
||||
public AudioData audiofile;
|
||||
|
||||
@@ -44,9 +45,12 @@ public class AudioAnalyzer {
|
||||
int UMThresholdCalcRange;
|
||||
int bassThresholdCalcRange;
|
||||
|
||||
private Array<MiniListener> listeners;
|
||||
|
||||
private volatile int progress;
|
||||
public AudioAnalyzer() {
|
||||
listeners = new Array<>();
|
||||
|
||||
analysisAlgorithm = new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -108,6 +112,8 @@ public class AudioAnalyzer {
|
||||
|
||||
shrinkData();
|
||||
containsData = true;
|
||||
|
||||
send(MiniEvents.SPECTRAL_FLUX_DONE);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -188,6 +194,8 @@ public class AudioAnalyzer {
|
||||
}
|
||||
|
||||
Gdx.app.debug("Audio Analyzer", "overlapped beats checked.");
|
||||
|
||||
finalized = true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -242,6 +250,11 @@ public class AudioAnalyzer {
|
||||
thresholdClean.start();
|
||||
}
|
||||
|
||||
public void runThresholdCleaning() {
|
||||
Thread thresholdClean = new Thread(thresholdCalculator);
|
||||
thresholdClean.start();
|
||||
}
|
||||
|
||||
public FloatArray getBassPeaks() {
|
||||
return bassPeaks;
|
||||
}
|
||||
@@ -287,4 +300,18 @@ public class AudioAnalyzer {
|
||||
public synchronized int getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public boolean isFinalized() {
|
||||
return finalized;
|
||||
}
|
||||
|
||||
public void addListener(MiniListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void send(MiniEvents ID) {
|
||||
while (listeners.iterator().hasNext()) {
|
||||
listeners.iterator().next().handle(ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -46,6 +46,8 @@ public class AudioInfo implements Disposable {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
invalidMusic = true;
|
||||
|
||||
} else {
|
||||
|
||||
try {
|
||||
|
Reference in New Issue
Block a user