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 raro;
FFT fft;
int bandas;
float ang;
void setup(){
size(1080,720,OPENGL);
bandas = 100;
minim = new Minim(this);
raro = minim.loadFile("raro.mp3");
fft = new FFT(raro.bufferSize(), raro.sampleRate());
fft.linAverages(bandas);
raro.loop();
colorMode(HSB, 255);
background(0);
ang =0;
}
void draw(){
background(map (raro.mix.level(),0,0.2,255,0));
ang+=0.001;
fft.forward(raro.mix);
for (int i=0; i<bandas; i+=1){
rotateY (ang);
pushMatrix();
translate(map(i,0,bandas-1,100,width-100),height/2);
noStroke();
fill(map(i,0,bandas-1,0,255),raro.mix.level()*3000,255);
box(20,fft.getBand(i)*300,20);
popMatrix();
}
}
practicas 2
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);
}
}
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);
}
}
Wednesday, February 15, 2017
AnĂ¡lisis de audio 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 bebeAudio;
float rot;
float max;
void setup() {
size (1080, 720, OPENGL);
minim = new Minim(this);
bebeAudio = minim.loadFile("baby.wav");
max=0;
}
void draw() {
rot+=0.01;
background(255);
pushMatrix();
translate(width/2, height/2);
rotateY(rot);
noFill();
int veces = int(map(bebeAudio.left.level(),0,0.237,0,45));
for (int i=0; i<veces; i+=1) {
box (100, 75, 50);
rotateX(0.2);
rotateY(0.5);
scale(1.05);
}
popMatrix();
fill(0);
if (bebeAudio.isPlaying()) {
text("Pulsa cualquier tecla para pausar", 20, 20);
} else
{
text ("Pulsa cualquier tecla para reproducir", 20, 20);
}
//if (bebeAudio.left.level()>max){
// max = bebeAudio.left.level() ;
//}
//String maxStr = str(max);
//text(maxStr, 20,40);
}
void keyPressed() {
if (bebeAudio.isPlaying()) {
bebeAudio.pause();
} else if (bebeAudio.position()==bebeAudio.length()) {
bebeAudio.rewind();
bebeAudio.play();
} else {
bebeAudio.play();
}
}
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
Minim minim;
AudioPlayer bebeAudio;
float rot;
float max;
void setup() {
size (1080, 720, OPENGL);
minim = new Minim(this);
bebeAudio = minim.loadFile("baby.wav");
max=0;
}
void draw() {
rot+=0.01;
background(255);
pushMatrix();
translate(width/2, height/2);
rotateY(rot);
noFill();
int veces = int(map(bebeAudio.left.level(),0,0.237,0,45));
for (int i=0; i<veces; i+=1) {
box (100, 75, 50);
rotateX(0.2);
rotateY(0.5);
scale(1.05);
}
popMatrix();
fill(0);
if (bebeAudio.isPlaying()) {
text("Pulsa cualquier tecla para pausar", 20, 20);
} else
{
text ("Pulsa cualquier tecla para reproducir", 20, 20);
}
//if (bebeAudio.left.level()>max){
// max = bebeAudio.left.level() ;
//}
//String maxStr = str(max);
//text(maxStr, 20,40);
}
void keyPressed() {
if (bebeAudio.isPlaying()) {
bebeAudio.pause();
} else if (bebeAudio.position()==bebeAudio.length()) {
bebeAudio.rewind();
bebeAudio.play();
} else {
bebeAudio.play();
}
}
Wednesday, February 8, 2017
slider 1
import de.bezier.guido.*;
Slider miSlider;
void setup() {
size(1080, 720);
Interactive.make( this );
miSlider= new Slider(20, 20, width-40, 32);
}
void draw(){
background (0);
String texto =str(miSlider.value);
text(texto, width/2, height/2);
fill (255);
//text("lo que hace el slider", 33,23);
}
public class Slider
{
float x, y, width, height;
float valueX = 0, value;
Slider ( float xx, float yy, float ww, float hh )
{
x = xx;
y = yy;
width = ww;
height = hh;
valueX = x;
// register it
Interactive.add( this );
}
// called from manager
void mouseDragged ( float mx, float my )
{
valueX = mx - height/2;
if ( valueX < x ) valueX = x;
if ( valueX > x+width-height ) valueX = x+width-height;
value = map( valueX, x, x+width-height, 0, 1 );
}
void draw ()
{
noStroke();
fill( 100 );
rect(x, y, width, height);
fill( 120 );
rect( valueX, y, height, height );
}
}
Slider miSlider;
void setup() {
size(1080, 720);
Interactive.make( this );
miSlider= new Slider(20, 20, width-40, 32);
}
void draw(){
background (0);
String texto =str(miSlider.value);
text(texto, width/2, height/2);
fill (255);
//text("lo que hace el slider", 33,23);
}
public class Slider
{
float x, y, width, height;
float valueX = 0, value;
Slider ( float xx, float yy, float ww, float hh )
{
x = xx;
y = yy;
width = ww;
height = hh;
valueX = x;
// register it
Interactive.add( this );
}
// called from manager
void mouseDragged ( float mx, float my )
{
valueX = mx - height/2;
if ( valueX < x ) valueX = x;
if ( valueX > x+width-height ) valueX = x+width-height;
value = map( valueX, x, x+width-height, 0, 1 );
}
void draw ()
{
noStroke();
fill( 100 );
rect(x, y, width, height);
fill( 120 );
rect( valueX, y, height, height );
}
}
BOLITA CLASS ARRAY
Bolita [] miBol;
int cant;
void setup() {
size(1080,720);
cant = 20;
miBol = new Bolita[cant];
for (int i=0; i<cant; i+=1){
miBol [i] = new Bolita (random(width), random(height), random(10), random(35),1,1,color (random(120), random(80), random(255)));
}
}
void draw() {
background(0);
for (int i=0; i<cant; i+=1){
miBol[i].move();
miBol[i].display();
}
}
class Bolita {
float posX, posY, speed, tam;
int dirX, dirY;
color col;
Bolita (float tposX, float tposY, float tspeed, float ttam, int tdirX, int tdirY, color tcol) {
posX=tposX;
posY=tposY;
speed=tspeed;
tam=ttam;
dirX=tdirX;
dirY=tdirY;
col = tcol;
}
void move() {
posX += speed*dirX;
posY += speed*dirY;
if (posX>width-(tam/2)||posX<tam/2) {
dirX=-dirX;
}
if (posY>height-(tam/2)||posY<tam/2) {
dirY=-dirY;
}
}
void display() {
fill (col);
ellipse(posX, posY, tam, tam);
}
}
int cant;
void setup() {
size(1080,720);
cant = 20;
miBol = new Bolita[cant];
for (int i=0; i<cant; i+=1){
miBol [i] = new Bolita (random(width), random(height), random(10), random(35),1,1,color (random(120), random(80), random(255)));
}
}
void draw() {
background(0);
for (int i=0; i<cant; i+=1){
miBol[i].move();
miBol[i].display();
}
}
class Bolita {
float posX, posY, speed, tam;
int dirX, dirY;
color col;
Bolita (float tposX, float tposY, float tspeed, float ttam, int tdirX, int tdirY, color tcol) {
posX=tposX;
posY=tposY;
speed=tspeed;
tam=ttam;
dirX=tdirX;
dirY=tdirY;
col = tcol;
}
void move() {
posX += speed*dirX;
posY += speed*dirY;
if (posX>width-(tam/2)||posX<tam/2) {
dirX=-dirX;
}
if (posY>height-(tam/2)||posY<tam/2) {
dirY=-dirY;
}
}
void display() {
fill (col);
ellipse(posX, posY, tam, tam);
}
}
Bolita CLASS
Bolita miBol;
void setup() {
size(1080,720);
miBol = new Bolita(width/2, height/2, 2, 20, 1, 1, color (0,255,0));
}
void draw() {
background(0);
miBol.move();
miBol.display();
}
class Bolita {
float posX, posY, speed, tam;
int dirX, dirY;
color col;
Bolita (float tposX, float tposY, float tspeed, float ttam, int tdirX, int tdirY, color tcol) {
posX=tposX;
posY=tposY;
speed=tspeed;
tam=ttam;
dirX=tdirX;
dirY=tdirY;
col = tcol;
}
void move() {
posX += speed*dirX;
posY += speed*dirY;
if (posX>width-(tam/2)||posX<tam/2) {
dirX=-dirX;
}
if (posY>height-(tam/2)||posY<tam/2) {
dirY=-dirY;
}
}
void display() {
fill (col);
ellipse(posX, posY, tam, tam);
}
}
void setup() {
size(1080,720);
miBol = new Bolita(width/2, height/2, 2, 20, 1, 1, color (0,255,0));
}
void draw() {
background(0);
miBol.move();
miBol.display();
}
class Bolita {
float posX, posY, speed, tam;
int dirX, dirY;
color col;
Bolita (float tposX, float tposY, float tspeed, float ttam, int tdirX, int tdirY, color tcol) {
posX=tposX;
posY=tposY;
speed=tspeed;
tam=ttam;
dirX=tdirX;
dirY=tdirY;
col = tcol;
}
void move() {
posX += speed*dirX;
posY += speed*dirY;
if (posX>width-(tam/2)||posX<tam/2) {
dirX=-dirX;
}
if (posY>height-(tam/2)||posY<tam/2) {
dirY=-dirY;
}
}
void display() {
fill (col);
ellipse(posX, posY, tam, tam);
}
}
Subscribe to:
Posts (Atom)