0

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.

  • A few general tips to get an answer: First use a linter or the "autoformatting" feature of your IDE or text editor on the code you post: The broken identation makes it really painful to read your code. Your question should always state what you are trying to do but also what is your actual issue: Here you want to make each range a different color but you don't explain what doesn't work or what is blocking you: People will not try to read your code and guess what is your problem. Only post the relevant code to your issue (see [mcve](https://stackoverflow.com/help/minimal-reproducible-example)) – statox Jan 19 '21 at 08:58
  • currently you're only controlling the Perlin Noise based on beat detection. you can move the `stroke();` in the same if/else sections and change the colour as desired – George Profenza Jan 19 '21 at 22:51

0 Answers0