Loading...
Logo
Processing Forum
Copy code
          Hi All sorry about the quote marks <<<

    Copy code
    1. int stRad = 100;
    2. SoundCircle SC;
    3. float angle=HALF_PI + PI;
    4. PGraphics waveForm;
    5. float seg=0;
    6. int segalpha;

    7. void setup() {
    8.   size(800, 800, P2D);
    9.   smooth();
    10.   frameRate(60);
    11.   stroke(250);
    12.   background(0);

    13.   
    14.   SC= new SoundCircle(width/2,height/2);
    15.   imageMode(CENTER);
    16.     waveForm  = createGraphics(width,height, P2D);

    17.  void draw() {
    18.   
    19.      
    20.     
    21.     SC.waveform();
    22.     SC.display();
    23.     
    24.      
    25.       
    26.     
    27. }

    28. class SoundCircle{
    29.      int cx;
    30.      int cy;
    31.      float buffCircle,buffAngle,bbuffAngle,abuffAngle,ax,ay,x,y,bx,by;
    32.      
    33.     SoundCircle(int tempx, int tempy){
    34.      cx = tempx;
    35.      cy = tempy;
    36.   
    37.      
    38.     }
    39.      
    40.    void waveform(){
    41.     float r = liveamp + 100.00;
    42.      buffCircle = TWO_PI/240.0;
    43.      buffAngle=buffCircle*frameCount;
    44.      bbuffAngle=buffCircle*(frameCount+1);
    45.      abuffAngle=buffCircle*(frameCount-1);
    46.       if (buffAngle <= TWO_PI) {
    47.       ax = cx + stRad * cos(buffAngle);
    48.       ay = cy + stRad * sin(buffAngle);
    49.       x = cx + r * cos(abuffAngle);
    50.       y = cy + r * sin(abuffAngle);
    51.       bx = cx + stRad * cos(bbuffAngle);
    52.       by = cy + stRad * sin(bbuffAngle);
    53.     
    54.   }
    55.       
    56.     
    57.     
    58.     }
    59.     
    60.       
    61.       void display(){
    62.         
    63.      
    64.       waveForm.beginDraw();
    65.       waveForm.stroke(250);
    66.       waveForm.beginShape(LINES);
    67.       waveForm.vertex(ax, ay);
    68.       waveForm.vertex(x, y);
    69.       waveForm.vertex(x, y);
    70.       waveForm.vertex(bx, by);
    71.       waveForm.endShape(CLOSE);
    72.       waveForm.endDraw();

    Copy code
    1. imageMode(CENTER);
    2.       translate(cx,cy);
    3.       
    4.        rotate(angle);
    5.       
    6.       image(waveForm, 0,0);
    Im guessing this is a horrible way to obliterate CPU

    Do you know anyway to lower the CPU usage?

    Many Thanks
    Miles

    Replies(2)

    Your code is missing parts.
    I only see a slow drawing of an irregular circle.
    I don't see the point of the sketch...
    Why call twice waveForm.vertex(x, y);?
    haha i knew it was bad

    i missed out th random number generator for liveamp

    i need to have the intervals between the points to be 200ms

    so its like a blocky jagged circle

    cheers
    miles