Analyse a Sound File Without Playback

edited February 2017 in Library Questions

I read up on examples of how to use FFT functions to create an audio visualiser as the audio is being played backed. Just wondering, is there a way to analyse a sound file without playing back? For example, read through the sound file and store the FFT analysis in a 2D array of spectrum[frame][band].



  • Thanks! That is certainly helpful!

  • I realised that the FFT functions only seem to work on a small portion for the audio stored in the buffer, are there any way to make it perform for the entire sound file? Perhaps there is a way to create a buffer to hold the entire or operate from the values returned from getChannel().

  • How big is your buffer after you read your file and at what sampling rate? You should check the documentation to see if they discuss about buffer size limits.

    You could also provide details about what you would like to do with your information. You could get more ideas from other forum goers. If you post your code, it will assist ppl to see your approach.

    I have done FFTs in "long" buffers but not in Processing.


  • I think it would easier to show an image of I am trying to create:

    This program analyses the entire sound file (does not play it back), and and finds out what seems to be the average or RMS amplitude of each frequency bands throughout the entire song (shown on the bottom left). From the graph, you know that is a bassy song as the lower frequencies have an average higher amplitude and this is probably a lossy sound file since frequencies around the 22KHz are cut off.

    I am trying to make something like this. I would like to analyse the song without playing back.

    No code to show yet, still just trying out different functions in Minim and planning on how to algorithm should be like. Sorry for my poor expression. Anyway my buffer was set to the default 1024 in Minim.

  • No need to show your code. It just make things easier. I will have to check the documentation. I will do it after work... like in few hours to see if it is possible to change the buffer size. If your song is 60 seconds long, then you will need a buffer of size 60 / (1/22000) = 1.32E6

    To test the code to see if it is bassy or not, what songs do you have in mind?


  • I've cooked up a terrible attempt meanwhile. You can download everything including the mp3 here:

    The song is one of the free-to-use background music from Youtube, so no issues with copyrights here.

    import ddf.minim.*;
    import ddf.minim.analysis.*;
    Minim minim=new Minim(this); 
    AudioSample mySound;
    FFT fft;
    String soundFileName="Dutty.mp3";
    int avgSize=12000;
    float[] allSamples;
    void setup(){
      size(800, 600);
      mySound = minim.loadSample("Dutty.mp3", 4194304); //I tried to load the entire song into buffer big enough
      mySound.trigger(); //Seems like I have to play the sound for FFT to work?
      fft = new FFT(mySound.bufferSize(), mySound.sampleRate());
      //I see in the example, the buffer is being fed into the function every draw() cycle, 
      //i assume now that I had thrown everything into the buffer, i only need to do this once?
      //I was hoping to draw the graph amplitude of frequencies 0-800Hz 
      //Seems like some amplitude is over 1? Shouldn't the values be between 0 and 1?
      for(int i = 0; i < 800; i++) { line( i, height, i, height - fft.getFreq(i)); }
      println("done ");
    void draw(){
  • You should check the example provided by the library. In Processing, go to File>>Examples and then minim>>Analysis>>offlineAnalysis. Now this example does not load the full spectrum at once but gives you a really neat idea of the frequencies observed in your data.


  • Sure man, will check it out once I'm free.

  • I see, so you can actually pass an array of float that you get from getChannel to the FFT function.

Sign In or Register to comment.