Frequencies in Processing with Minim and making Colours

172 Views Asked by At

This is my code:

 import ddf.minim.*;
 import ddf.minim.analysis.*;

  Minim minim;
  AudioPlayer player;
 AudioMetaData meta;
 BeatDetect beat;

 float noiseMulti = 300;
int radius = 100;
float nScale = 200;

void setup() {
size(700, 700, P2D);
background(0);
 smooth();
 minim = new Minim(this);
player = minim.loadFile("pirates.mp3");
 player.loop();

meta = player.getMetaData();
beat = new BeatDetect(player.bufferSize(), player.sampleRate());
beat.setSensitivity(300);
  }
void draw(){
noStroke();
fill(0);
rect(0,0, width, height);
translate(width/2, height/2);

beat.detect(player.mix);
if  (beat.isKick()){
 noiseMulti = 300;
 nScale = 150;
 }
 else{
 if(nScale >100) nScale *= 0.9;
 noiseMulti *= 0.5;
   }

stroke(0,255,0);
  for (int lat = -90; lat < 90; lat ++){
for (int lng = -180; lng < 180; lng += 2){
 float _lat = radians (lat);
 float _lng = radians(lng);
 float n = noise(_lat * noiseMulti / 100, _lng * noiseMulti / 100 + millis() );

// ellipse(0,0,_lat*100 + n, _lng*100+n);

   float x = (radius + nScale * n * _lat);
 float y = (radius + n* nScale) ;
 // float z = (radius + n * nScale) * cos(_lat) * sin(_lng);
//  point (x,y,z);
point (x,y);
 
    }
  }

 }
     void stop()
   {
      player.close();
      minim.stop();
      super.stop();
  } 

I'm trying to make each range of frequencies a different colour. For example, it uses green for the beats, but, I'm trying to get it to also have different colours for the high tones. The song I used is "Up is Down' from Pirates of the Caribbean.

0

There are 0 best solutions below