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