Processing-3D shapes

edited December 4 in Library Questions

How can I create three-dimensional shapes whose sides are expanding based on the sound beats?

Answers

  • What are you having trouble with?

    Drawing 3D shapes?

    Making their size depend on some other input?

    Loading and playing sounds?

    Detecting beats in the sound?

    What code do you have so far? POST IT.

  • this is my code and i want to put smaller shapes inside the shpere

    1 2

  • please post code as text not as image

    select code with mouse and press the small C in the command bar

  • import ddf.minim.*;

    Minim minim; AudioSample kick; AudioSample snare;

    import peasy.*; import peasy.org.apache.commons.math.*; import peasy.org.apache.commons.math.geometry.*;

    PeasyCam cam;

    float kickHeight = 100;

    void setup() { size (600, 600, P3D); cam = new PeasyCam(this, 500); minim = new Minim(this); kick = minim.loadSample( "tragoudi1.mp3",1024); // buffer size

    }

    void draw() { background(0); fill(200); lights();

    float r = 200; int total = 50; for (int i = 0; i < total; i++) { float lon = map(i, 0, total, -PI, PI); for (int j = 0; j < total; j++) { float lat = map(j, 0, total, -HALF_PI, HALF_PI); float x = r * sin(lon) * cos(lat); float y = r * sin(lon) * sin(lat); float z = r * cos(lon); stroke(255); point(x, y, z); } }

    for (int i = 0; i < kick.bufferSize() - 1; i++) { float x1 = map(i, 0, kick.bufferSize(), 0, width); float x2 = map(i+1, 0, kick.bufferSize(), 0, width); float y1 = kick.mix.get(i)kickHeight; float y2 = kick.mix.get(i+1)kickHeight; stroke(255,85,0); line(x1, 50 - kick.mix.get(i)kickHeight, x2, 50 - kick.mix.get(i+1)kickHeight); rect(x1,y1,20,40); } }

    void keyPressed() { if ( key == 'k' ) kick.trigger(); }``

  • Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text

    Kf

  • When you get the amplitude of the current sound, you could use this as y value or as radius value; use map to apply to the range you need

Sign In or Register to comment.