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