Get frequencies of sound

Hi, to start, sorry for my English but I’m French so I’ll maybe do some mistakes.

I’m totally new on Processing and I’d like to get bass of the song of my PC. To do it, I already found a code wich do a spectrograme of the sound of my PC.

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;



Minim minim;
AudioInput in;
FFT fft;
int w;

void setup()
{
  size(640, 840);
  minim = new Minim(this);
  in = minim.getLineIn(Minim.STEREO, 512);
  fft = new FFT(in.bufferSize(), in.sampleRate());
  fft.logAverages(60, 7);
  stroke(255);
  w = width/fft.avgSize();
  strokeWeight(w);
  strokeCap(SQUARE);
}

void draw()
{
  background(0);
  fft.forward(in.mix);
  
  for(int i = 0; i < fft.avgSize(); i++) {
    line((i * w) + (w / 2), height, (i * w) + (w / 2), height - fft.getAvg(i) * 4);
    
  }
 
    
}

I saw that the 5th, 6th, 7th 8th and 9th columns correspond to the bass of the music :
https://gyazo.com/2a58b24018f36c37d207b346ca7fa680

I would like to know, with my code when there are bass frequencies.

I totally don’t know how to do it;
Can you help me please ? Thanks a lot :slight_smile:

pick that data , add them up and compare them with a limit
if the limit is hit change the background color

import ddf.minim.*;
import ddf.minim.analysis.*;
//import ddf.minim.effects.*;
//import ddf.minim.signals.*;
//import ddf.minim.spi.*;
//import ddf.minim.ugens.*;

Minim minim;
AudioInput in;
FFT fft;
int w;
boolean diagp = true;
float bsum=0,blimit=50;

void setup() {
  size(640, 840);
  minim = new Minim(this);
  in = minim.getLineIn(Minim.STEREO, 512);
  fft = new FFT(in.bufferSize(), in.sampleRate());
  fft.logAverages(60, 7);
  stroke(255);
  w = width/fft.avgSize();
  strokeWeight(w);
  strokeCap(SQUARE);
  print("AVG array "+fft.avgSize());//  63
}

void draw() {
  if ( bsum > blimit ) background(200,0,0);
  else                 background(0);
  fft.forward(in.mix);
  for (int i = 0; i < fft.avgSize(); i++) {
    line((i * w) + (w / 2), height, (i * w) + (w / 2), height - fft.getAvg(i) * 4);
  }
    bsum=0;
    for ( int i = 0; i<5; i++) {
      int p = i+5;
      if ( diagp ) print( " ["+p+"] "+nf(fft.getAvg(p), 0, 2) );
      bsum += fft.getAvg(p);
    }
    if ( diagp ) println();

}