Wednesday, February 22, 2017

tarea Minim 1

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;

Minim minim;
AudioPlayer llorar, reir;
  float nivelMax1, nivelMax2, ang;

void setup() {
  size (1080, 720, OPENGL);
  minim = new Minim(this);
  llorar = minim.loadFile("llorar.wav");
  reir = minim.loadFile("reir.wav");
  llorar.loop();
  reir.loop();
  nivelMax1=0;
  nivelMax2=0;
}
void draw(){
  ang+=0.1;
 background(0);
 noStroke();
 fill (0,255,0);
 rect (0,0,width/2,height);
 fill (0,0,255);
 rect (width/2,0,width/2,height);
 if (mouseX<width/2){
   llorar.play();
   reir.pause();
   println("verde cierto");
   float miNivel = llorar.mix.level();
   String miNivelTxt = str(miNivel);
   fill (0);
   //text (miNivelTxt, width/4, height/2);
   //if (miNivel>nivelMax1){
   // nivelMax1=miNivel;
   //}
   //String maxStr = str(nivelMax1);
   //text(maxStr, width/4, height/2+30);
   pushMatrix();
   translate(width/4, height/2);
   noFill();
   stroke(255,0,0);
   rotateY(ang);
   box (map(miNivel, 0, 0.202,0,80));
   popMatrix();
 }
 else {
   reir.play();
   llorar.pause();
   float miNivel = reir.mix.level();
   String miNivelTxt = str(miNivel);
   fill(255);
   text (miNivelTxt, (width/4)*3, height/2);
 }
}

No comments:

Post a Comment