Window { private void processSample() { lastProcessedSpectrum = pushedSamples; FFTSignalProcessing.ProcessingResult result = signalProcessing.processSample(window, aWeighting, true); if(windowResults.length > 1) { System.arraycopy(windowResults, 1, windowResults, 0, windowResults.length - 1); } windowResults[windowResults.length - 1] = result; } Window(FFTSignalProcessing.WINDOW_TYPE window, int samplingRate, double[] standardFrequencies,
                  double windowTime, boolean aWeighting,
                  double dbFsReference,boolean outputThinFrequency);  Window(FFTSignalProcessing.WINDOW_TYPE window, int samplingRate, double[] standardFrequencies,
                  double windowTime, boolean aWeighting,
                  double dbFsReference,boolean outputThinFrequency, double overlap); boolean isOutputThinFrequency(); void setaWeighting(boolean aWeighting); FFTSignalProcessing.WINDOW_TYPE getWindowType(); boolean isAWeighting(); double getWindowTime(); double computeWindowLeq(); void cleanWindows(); FFTSignalProcessing.ProcessingResult getLastWindowMean(); boolean isCacheEmpty(); int getWindowIndex(); double getOverlap(); int getMaximalBufferSize(); void pushSample(short[] buffer); final FFTSignalProcessing.WINDOW_TYPE window; }
@Test public void testVoice1() throws IOException { final int sampleRate = 44100; double p0 = 32767.; double dbFsReference = -20 * Math.log10(p0); double[] refSpl = {-66, -68.04, -67.52, -45.97, -31.96, -37.13, -49.21, -35.29, -43.01, -42.95, -48.65, -49.04, -53.27, -52.15, -52.65, -52.8, -52.31, -53.56, -52.54, -53.96, -53.63, -58.53, -67.22}; double refGlobalSpl = 0; for (double lvl : refSpl) { refGlobalSpl += Math.pow(10, lvl / 10.); } refGlobalSpl = 10 * Math.log10(refGlobalSpl); InputStream inputStream = WindowTest.class.getResourceAsStream("speak_44100Hz_16bitsPCM_10s.raw"); short[] signal = SOSSignalProcessing.loadShortStream(inputStream, ByteOrder.LITTLE_ENDIAN); FFTSignalProcessing fftSignalProcessing = new FFTSignalProcessing(sampleRate, ThirdOctaveBandsFiltering.STANDARD_FREQUENCIES_REDUCED, signal.length, dbFsReference); fftSignalProcessing.addSample(signal); FFTSignalProcessing.ProcessingResult processingResult = fftSignalProcessing.processSample(FFTSignalProcessing.WINDOW_TYPE.RECTANGULAR, false, false); assertEquals(refGlobalSpl, fftSignalProcessing.computeGlobalLeq(), 0.01); assertEquals(refGlobalSpl, processingResult.getGlobaldBaValue(), 0.01); checkSplSpectrum(refSpl, testFFTWindow(signal, sampleRate, 0.125, FFTSignalProcessing.WINDOW_TYPE.TUKEY, dbFsReference), 0, 1.11); checkSplSpectrum(refSpl, testFFTWindow(signal, sampleRate, 0.125, FFTSignalProcessing.WINDOW_TYPE.RECTANGULAR, dbFsReference), 0, 2.64); checkSplSpectrum(refSpl, testFFTWindow(signal, sampleRate, 1., FFTSignalProcessing.WINDOW_TYPE.TUKEY, dbFsReference), 0, 0.36); checkSplSpectrum(refSpl, testFFTWindow(signal, sampleRate, 1., FFTSignalProcessing.WINDOW_TYPE.RECTANGULAR, dbFsReference), 0, 0.774); }