From f7e5e5e35e1d26dd35c45e9c7b8ec1918bc1b75c Mon Sep 17 00:00:00 2001 From: Recrown Date: Fri, 26 May 2017 12:43:29 -0500 Subject: [PATCH] began re-tuning analyzer --- .../zero1hd/polyjet/audio/AudioAnalyzer.java | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java b/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java index 950c744..72067ba 100755 --- a/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java +++ b/core/src/zero1hd/polyjet/audio/AudioAnalyzer.java @@ -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);