Landscape generator with the help of sound

edited April 2016 in Library Questions

Hello,

I am working on a landscape generator. i had the idea of a Perlin Noise surface wich interacts with sound. I wonder how i can feed it with even more parameters to get it more visible that the sound has an influence on the surface? has anybody an idea or even a similar example i can look on?

This is my code:

import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer player;
AudioMetaData meta;
BeatDetect beat;

FFT fftLin;
FFT fftLog;



boolean record;                                                


int datascale = 250;
int dsh = datascale / 2;
float[][] data = new float [datascale][datascale];
float incrementation = 0.01;
int dataheight = 190;
int g;
int p;
float fram;
float z = 0.9;
float zoff = 3;
boolean stop;
boolean lnon;
float framspeed = 0.01;
boolean mouseleftpressed;


import peasy.*;
PeasyCam cam;

void setup() {
  background(0);
  stroke(255);
  strokeWeight(1);
  size(1920, 1080,P3D);
    minim = new Minim(this);
  player = minim.loadFile("groove.mp3");
  meta = player.getMetaData();
  beat = new BeatDetect();
  player.loop();
//  player.play();



}
void draw() {


   beat.detect(player.mix);


    lights();
     if(stop==false) {
    fram += framspeed;
  }

 translate(width/2, height/2);
  rotateY(map(mouseX,0,width*0.1,-PI/2,PI/2));           
  rotateX(map(mouseY,0,height*0.1,-PI/2,PI/2));              


int bsize = player.bufferSize();

  for(int i = 0; i < datascale; i++) {                                                                                                     //funktion  incrementation
      for(int j = 0; j < datascale; j++) {
       data[i][j] = 2 * noise((i+bsize)*incrementation/4+52, (j+p)*incrementation/4+35, fram/4) + (noise((i+g)*incrementation,
        (j+p)*bsize + pow(noise((i+bsize)*incrementation, (j+p)*incrementation, fram)*2, 2), fram+zoff)) * dataheight;
     }
   }                                                                                                                                           //funktion

  background(0);        //hier wird geupdated


  scale(2);

  for(int i = 1; i < datascale-1; i++) {                                                                                             //konstruktion
    for(int j = 1; j < datascale-1; j++) {


      if(lnon == true) {
        line((i-dsh)*2, (j-dsh)*2, data[i][j], (i-1-dsh)*2, (j-1-dsh)*2, data[i-1][j-1]);
        line((i-dsh)*2, (j-dsh)*2, data[i][j], (i-1-dsh)*2, (j+1-dsh)*2, data[i-1][j+1]);
      }else{
        noStroke();
        beginShape(TRIANGLE_STRIP);
          vertex((i-dsh)*2, (j-dsh)*2, data[i][j]);
          vertex((i-dsh)*2, (j+1-dsh)*2, data[i][j+1]);
          vertex((i+1-dsh)*2, (j-dsh)*2, data[i+1][j]);
          vertex((i+1-dsh)*2, (j+1-dsh)*2, data[i+1][j+1]);
        endShape(CLOSE);
      }
    }
  }        


 }                                                                                                                                  //konstruktion 

Answers

Sign In or Register to comment.