Skip to content

Klemek/Audio-Analysis

 
 

Repository files navigation

Scc Count Badge Maven Central License

Audio-Analysis

A simple FFT library in Java. Compute FFT from any WAV or MP3 file and perform calculation on it.

Disclaimer : I'm not the author of this repo

Use

// Compute FFT from WAV/MP3 file
WaveDecoder decoder = new WaveDecoder(new FileInputStream(wavFile));
FFT fft = new FFT(1024, wavFileObj.getSampleRate());

//Do calculation from FFT
float[] samples = new float[1024];
float[] spectrum = new float[1024 / 2 + 1];
float[] lastSpectrum = new float[1024 / 2 + 1];
List<Float> spectralFlux = new ArrayList<Float>();

while (decoder.readSamples(samples) > 0) {
    fft.forward(samples);
    System.arraycopy(spectrum, 0, lastSpectrum, 0, spectrum.length);
    System.arraycopy(fft.getSpectrum(), 0, spectrum, 0, spectrum.length);

    float flux = 0;
    for (int i = 0; i < spectrum.length; i++)
        flux += (spectrum[i] - lastSpectrum[i]);
    spectralFlux.add(flux);
}

Origin of this library

I stumbled on this stackoverflow question from 2014 while searching how to compute a simple FFT in Java. The first answer was linking to a dead repository on code.google.com but someone had the brillant idea to clone it to Github before it was too late.

I just did some cleanup and uploaded it to Maven Central for a everyone.

About

Easy-to-use FFT library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 99.9%
  • Batchfile 0.1%