Loading...
Logo
Processing Forum
I don't know if it's my code or if my PC is sh*t. Help? Using two .wav

Copy code
  1. import ddf.minim.spi.*;
  2. import ddf.minim.signals.*;
  3. import ddf.minim.*;
  4. import ddf.minim.analysis.*;
  5. import ddf.minim.ugens.*;
  6. import ddf.minim.effects.*;

  7. Minim minim;
  8. AudioPlayer mus,mus2;

  9. float w=1;
  10. float a=0;
  11. PImage gin;
  12. float p=180;

  13. void setup()
  14. {
  15.   size(800,800);
  16.   background(0);
  17.   
  18.   gin = loadImage("gin.jpg");
  19.   minim = new Minim(this);
  20.   mus = minim.loadFile("ser.wav",4096);
  21.   mus2 = minim.loadFile("l2.wav",4096);
  22. }

  23. void draw()
  24. {
  25.   stroke(255);
  26.   strokeWeight(1);
  27.    if (!mousePressed)
  28.   {
  29.     background(0);
  30.     imageMode(CENTER);
  31.     tint(255,p);
  32.      if (mouseY > 400)
  33.   {
  34.     p=p-0.5;
  35.   }
  36.   else
  37.   {
  38.     p=p+0.5;
  39.   }
  40.     image(gin,400,400);
  41.     stroke(random(255));
  42.     line(400,400,mouseX,mouseY);
  43.     if (mouseY < height/2)
  44.     {
  45.      strokeWeight(random(1,7));
  46.      stroke(random(1,128),0,255,random(0,128));
  47.      
  48.      line(800,0,random(800),random(800));
  49.      line(800,0,random(800),random(800));
  50.      line(800,0,random(800),random(800));
  51.      line(800,0,random(800),random(800));
  52.      line(800,0,random(800),random(800));
  53.      line(800,0,random(800),random(800));
  54.      line(800,0,random(800),random(800));
  55.      line(800,0,random(800),random(800));
  56.      
  57.      a=0;
  58.     }
  59.     else
  60.     {
  61.      strokeWeight(random(1,7));
  62.      stroke(255,0,random(0,128),random(0,128));
  63.      
  64.      line(0,800,random(800),random(800));
  65.      line(0,800,random(800),random(800));
  66.      line(0,800,random(800),random(800));
  67.      line(0,800,random(800),random(800));
  68.      line(0,800,random(800),random(800));
  69.      line(0,800,random(800),random(800));
  70.      line(0,800,random(800),random(800));
  71.      line(0,800,random(800),random(800)); 
  72.     } 
  73.    }
  74.    else
  75.    {
  76.     if (mouseY < height/2)
  77.     {
  78.       mus.play();
  79.     }
  80.     else
  81.     {
  82.       mus2.play();
  83.     }
  84.    strokeWeight(abs(mouseY-pmouseY)/4);
  85.    rectMode(CENTER);
  86.    rect(400,400,800,800);
  87.    fill(0,0,0,a);
  88.    a=a+1;
  89.    line(mouseX,mouseY,random(800),random(800));
  90.    line(mouseX,mouseY,random(800),random(800));
  91.    line(mouseX,mouseY,random(800),random(800));
  92.    line(mouseX,mouseY,random(800),random(800));
  93.    line(mouseX,mouseY,random(800),random(800));
  94.    line(mouseX,mouseY,random(800),random(800));
  95.    line(mouseX,mouseY,random(800),random(800));
  96.    line(mouseX,mouseY,random(800),random(800));
  97.    line(mouseX,mouseY,random(800),random(800));
  98.    line(mouseX,mouseY,random(800),random(800));
  99.        
  100.     if (mouseY < height/2 )
  101.     {
  102.       strokeWeight(w);
  103.       stroke(random(255),0,0,255);
  104.       line(400,400,mouseX,mouseY);
  105.     }
  106.     else
  107.     {
  108.       strokeWeight(w);
  109.       stroke(0,0,random(255),255);
  110.       line(400,400,mouseX,mouseY);
  111.     }
  112.    } 

  113. p=constrain(p,0,180);

  114. }

  115. void stop()
  116. {
  117.   mus.close();
  118.   minim.stop();
  119.   super.stop();
  120. }

Replies(2)


try:
don't specify a buffer size
you have 4096 twice           

I've tried even without specifying the buffer size at all. And if my logic is correct, I wrote it twice for each individual .wav, but I might be wrong.

Still choppy and grainy.

Any other idea?