Hi,
I'm a novice with processing
and I'm currently exploring different things I can do with processing...
Right now, my waveform in my example is static.
I want to know how I could make the waveform look as if it's 'flying' to the right side of the canvas.
Moving like a flock of birds I mean...
Is it even possible with my codes below?
What do I need to do with the code to make that effect?
Help me out!
- import ddf.minim.*;
- import ddf.minim.signals.*;
- import ddf.minim.analysis.*;
- import ddf.minim.effects.*;
- Minim minim;
- AudioPlayer track;
- WaveformRenderer waveform;
- float bpm = 50.2;
- float mspb = 60000/bpm;
- float x = 0;
- float y = 0;
- float x1 =0;
- float x2 =0;
- float y2 =0;
- float y1 =0;
- float line_height = 1;
- int time = 0;
- void setup()
- {
- size(800, 200,P3D);
- background(255);
- stroke(255);
- strokeWeight(0);
- frameRate(20);
- smooth();
- minim = new Minim(this);
- track = minim.loadFile("rude.mp3", 2048);
- track.loop();
- waveform = new WaveformRenderer();
- track.addListener(waveform);
- }
- void draw() {
- int lapse = millis();
- for (int i = 0; i < track.left.size()-1; i++) {
- x1 = x;
- x2 = x;
- y1 = track.left.get(i);
- y2 = track.left.get(i+1);
- fill(random(255), map( abs(track.left.get(i)), 0, .2, 0, 255), 2);
- noStroke();
- ellipseMode(CENTER);
- ellipse(x, y,abs(track.left.get(i))*10,abs(track.left.get(i))*10);
- x+=abs(track.left.get(i))*20;
- x+=5;
- }
- if (lapse > mspb || x > width ) {
- // start a new line on the left
- time = millis();
- y += 6;
- x = 0;
- if (y > height){
- y = 0;
- background(255);
- }
- }
- waveform.draw();
- }
- class WaveformRenderer implements AudioListener
- {
- private float[] left;
- private float[] right;
- WaveformRenderer(){
- left = null;
- right = null;
- }
- synchronized void samples(float[] samp){
- left = samp;
- }
- synchronized void samples(float[] sampL, float[] sampR){
- left = sampL;
- right = sampR;
- }
- synchronized void draw(){
- beginShape();
- for ( int i = 0; i < left.length; i++ ){
- ellipse(i, height/2 + left[i]*50, 1, 1);
- ellipse(i, height/2 + left[i]*50, abs(track.left.get(i))*50, abs(track.left.get(i))*50);
- i+=20;
- }
- endShape();
- }
- }
- void stop(){
- track.close();
- minim.stop();
- super.stop();
- }
1