improved spectrum sampling
This commit is contained in:
parent
02afe42cd9
commit
153452d10e
@ -30,7 +30,7 @@ import org.wyrez.audio.util.SampleBuffer;
|
|||||||
import org.wyrez.audio.util.SampleHelper;
|
import org.wyrez.audio.util.SampleHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*Processor to create analysis-data of audio samples
|
* Processor to create analysis-data of audio samples
|
||||||
*
|
*
|
||||||
* @author Darth Affe
|
* @author Darth Affe
|
||||||
*/
|
*/
|
||||||
@ -191,12 +191,15 @@ public class AudioProcessor {
|
|||||||
System.arraycopy(spectrumBuffer, 0, lastSpectrumBuffer, 0, spectrumBuffer.length);
|
System.arraycopy(spectrumBuffer, 0, lastSpectrumBuffer, 0, spectrumBuffer.length);
|
||||||
System.arraycopy(fft.getSpectrum(band), 0, spectrumBuffer, 0, spectrumBuffer.length);
|
System.arraycopy(fft.getSpectrum(band), 0, spectrumBuffer, 0, spectrumBuffer.length);
|
||||||
|
|
||||||
|
float spectrumAvg = 0;
|
||||||
float flux = 0;
|
float flux = 0;
|
||||||
for (int j = 0; j < spectrumBuffer.length; j++) {
|
for (int j = 0; j < spectrumBuffer.length; j++) {
|
||||||
spectrum.add(spectrumBuffer[j]);
|
spectrumAvg += spectrumBuffer[j];
|
||||||
float value = (spectrumBuffer[j] - lastSpectrumBuffer[j]);
|
float value = (spectrumBuffer[j] - lastSpectrumBuffer[j]);
|
||||||
flux += value < 0 ? 0 : value;
|
flux += value < 0 ? 0 : value;
|
||||||
}
|
}
|
||||||
|
spectrumAvg /= spectrumBuffer.length;
|
||||||
|
spectrum.add(spectrumAvg);
|
||||||
spectralFlux.add(flux);
|
spectralFlux.add(flux);
|
||||||
}
|
}
|
||||||
this.spectralFlux = SampleHelper.convertToFloatArray(spectralFlux);
|
this.spectralFlux = SampleHelper.convertToFloatArray(spectralFlux);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user