began re-tuning analyzer
This commit is contained in:
parent
ad0138c489
commit
f7e5e5e35e
@ -16,7 +16,6 @@ public class AudioAnalyzer {
|
|||||||
float[] audioPCM;
|
float[] audioPCM;
|
||||||
float[] spectrum;
|
float[] spectrum;
|
||||||
float[] lastSpectrum;
|
float[] lastSpectrum;
|
||||||
float[] fftData;
|
|
||||||
|
|
||||||
Runnable analysisAlgorithm;
|
Runnable analysisAlgorithm;
|
||||||
Runnable thresholdCalculator;
|
Runnable thresholdCalculator;
|
||||||
@ -63,11 +62,11 @@ public class AudioAnalyzer {
|
|||||||
bassThresholdMultiplier = 1.5f;
|
bassThresholdMultiplier = 1.5f;
|
||||||
UMThresholdMultiplier = 2f;
|
UMThresholdMultiplier = 2f;
|
||||||
|
|
||||||
bassBinBegin = binCalculator(60);
|
bassBinBegin = 1;
|
||||||
bassBinEnd = binCalculator(800);
|
bassBinEnd = 17;
|
||||||
|
|
||||||
UMBinBegin = binCalculator(1500);
|
UMBinBegin = 300;
|
||||||
UMBinEnd = binCalculator(3000);
|
UMBinEnd = 450;
|
||||||
|
|
||||||
UMThresholdCalcRange = thresholdRangeCalc(0.5f);
|
UMThresholdCalcRange = thresholdRangeCalc(0.5f);
|
||||||
bassThresholdCalcRange = thresholdRangeCalc(0.7f);
|
bassThresholdCalcRange = thresholdRangeCalc(0.7f);
|
||||||
@ -236,7 +235,6 @@ public class AudioAnalyzer {
|
|||||||
|
|
||||||
public void startAnalyticalThread(AudioData audiofile) {
|
public void startAnalyticalThread(AudioData audiofile) {
|
||||||
audioPCM = new float[audiofile.getReadWindowSize()];
|
audioPCM = new float[audiofile.getReadWindowSize()];
|
||||||
fftData = new float[audiofile.getReadWindowSize()];
|
|
||||||
spectrum = new float[(audiofile.getReadWindowSize()/2)+1];
|
spectrum = new float[(audiofile.getReadWindowSize()/2)+1];
|
||||||
lastSpectrum = new float[(audiofile.getReadWindowSize()/2)+1];
|
lastSpectrum = new float[(audiofile.getReadWindowSize()/2)+1];
|
||||||
this.audiofile = audiofile;
|
this.audiofile = audiofile;
|
||||||
@ -265,16 +263,6 @@ public class AudioAnalyzer {
|
|||||||
return UMPeaks;
|
return UMPeaks;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int binCalculator(int frequency) {
|
|
||||||
float totalBins = audiofile.getReadWindowSize()/2 +1;
|
|
||||||
float frequencyRange = audiofile.getFormat().getSampleRate()/2;
|
|
||||||
|
|
||||||
//Formula derived from: (22050b/513)+(22050/513/2) = F
|
|
||||||
//let b be the bin
|
|
||||||
//let F be the frequency.
|
|
||||||
return (int) (totalBins*(frequency - (frequencyRange/totalBins*2))/frequencyRange);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int thresholdRangeCalc(float durationOfRange) {
|
private int thresholdRangeCalc(float durationOfRange) {
|
||||||
float timePerWindow = (float)audiofile.getReadWindowSize()/audiofile.getFormat().getSampleRate();
|
float timePerWindow = (float)audiofile.getReadWindowSize()/audiofile.getFormat().getSampleRate();
|
||||||
return (int) (durationOfRange/timePerWindow);
|
return (int) (durationOfRange/timePerWindow);
|
||||||
|
Loading…
Reference in New Issue
Block a user