Minim sound really choppy and grainy
in
Core Library Questions
•
3 months ago
I don't know if it's my code or if my PC is sh*t. Help? Using two .wav
- import ddf.minim.spi.*;
- import ddf.minim.signals.*;
- import ddf.minim.*;
- import ddf.minim.analysis.*;
- import ddf.minim.ugens.*;
- import ddf.minim.effects.*;
- Minim minim;
- AudioPlayer mus,mus2;
- float w=1;
- float a=0;
- PImage gin;
- float p=180;
- void setup()
- {
- size(800,800);
- background(0);
- gin = loadImage("gin.jpg");
- minim = new Minim(this);
- mus = minim.loadFile("ser.wav",4096);
- mus2 = minim.loadFile("l2.wav",4096);
- }
- void draw()
- {
- stroke(255);
- strokeWeight(1);
- if (!mousePressed)
- {
- background(0);
- imageMode(CENTER);
- tint(255,p);
- if (mouseY > 400)
- {
- p=p-0.5;
- }
- else
- {
- p=p+0.5;
- }
- image(gin,400,400);
- stroke(random(255));
- line(400,400,mouseX,mouseY);
- if (mouseY < height/2)
- {
- strokeWeight(random(1,7));
- stroke(random(1,128),0,255,random(0,128));
- line(800,0,random(800),random(800));
- line(800,0,random(800),random(800));
- line(800,0,random(800),random(800));
- line(800,0,random(800),random(800));
- line(800,0,random(800),random(800));
- line(800,0,random(800),random(800));
- line(800,0,random(800),random(800));
- line(800,0,random(800),random(800));
- a=0;
- }
- else
- {
- strokeWeight(random(1,7));
- stroke(255,0,random(0,128),random(0,128));
- line(0,800,random(800),random(800));
- line(0,800,random(800),random(800));
- line(0,800,random(800),random(800));
- line(0,800,random(800),random(800));
- line(0,800,random(800),random(800));
- line(0,800,random(800),random(800));
- line(0,800,random(800),random(800));
- line(0,800,random(800),random(800));
- }
- }
- else
- {
- if (mouseY < height/2)
- {
- mus.play();
- }
- else
- {
- mus2.play();
- }
- strokeWeight(abs(mouseY-pmouseY)/4);
- rectMode(CENTER);
- rect(400,400,800,800);
- fill(0,0,0,a);
- a=a+1;
- line(mouseX,mouseY,random(800),random(800));
- line(mouseX,mouseY,random(800),random(800));
- line(mouseX,mouseY,random(800),random(800));
- line(mouseX,mouseY,random(800),random(800));
- line(mouseX,mouseY,random(800),random(800));
- line(mouseX,mouseY,random(800),random(800));
- line(mouseX,mouseY,random(800),random(800));
- line(mouseX,mouseY,random(800),random(800));
- line(mouseX,mouseY,random(800),random(800));
- line(mouseX,mouseY,random(800),random(800));
- if (mouseY < height/2 )
- {
- strokeWeight(w);
- stroke(random(255),0,0,255);
- line(400,400,mouseX,mouseY);
- }
- else
- {
- strokeWeight(w);
- stroke(0,0,random(255),255);
- line(400,400,mouseX,mouseY);
- }
- }
- p=constrain(p,0,180);
- }
- void stop()
- {
- mus.close();
- minim.stop();
- super.stop();
- }
1