Ejercicios hechos con Processing

De Libre y Abierto

Enrique Rosas

int kolor=0; //control de variacion del color
int ancho=0; //control del ancho de cada linea

void setup(){
  size(300,300);
}

void draw(){
  background(246,255,5);
  for(int i=100;i<=width-100;i+=25){ //delimitacion del area en donde se presenta la animacion en x y separacion entre lineas
    for(int j=100;j<=height-100;j+=25){ //delimitacion del area en donde se presenta la animacion en y y separacion entre lineas
      if(ancho>3){ //control del ancho de la linea
          ancho=0;
      }
      stroke(kolor,0,0); //determina color
      strokeWeight(ancho); //determina ancho
      smooth();
      line(i,mouseY,mouseX,j); //interactividad: movimiento del raton determina la posicion del dibujo
      if (kolor>255)kolor=0; //control del color
      else kolor+=1;
      ancho+=1;
    }
  }
}

Sem Aser

Para poder correr este visualizador de audio es necesario tener instalado supercollider (con algún servidor encendido), la librería de este mismo en processing y la librería minim (ambas las puedes encontrar en la extensión de librerías de processing).

//Audio esfera Sem Aser,
//Eric Auster proyect

import processing.opengl.*;
import supercollider.*;
import java.util.ArrayList;
import ddf.minim.*;
import damkjer.ocd.*;

Camera camera1;
Buffer buffer;
AudioPlayer song;


int cuantos = 8000;


float radio = 200;
float rx = 0;
float ry =0;

void setup()
{
  size(640, 480, OPENGL);
  hint(ENABLE_OPENGL_4X_SMOOTH); 
  frameRate(30);
  
  camera1 = new Camera(this, 100, 0, 0);
  
  buffer = new Buffer(2);
  buffer.read("/Users/aserperez/Desktop/lcd03.wav",
         this, "done"); 
         
  
  noiseDetail(7,0.5);

}
void done (Buffer buffer)
{
  println("Buffer loaded.");
  println("Channels:    " + buffer.channels);
  println("Frames:      " + buffer.frames);
  println("Sample Rate: " + buffer.sampleRate);  
}

void mousePressed()
{
  buffer.write("/tmp/test.aif", "aiff", "int16", this, "written");
  
}

void written (Buffer buffer)
{
  println("Buffer written to disk");
  Minim.start(this);
  song = Minim.loadFile("/tmp/test.aif");
  song.play();
}
void draw()
{
  background(0);
  translate(width/2,height/2);
  
  camera1.feed();
  rotateY(PI/3);

  float rxp = ((mouseX-(width/2))*0.01);
  float ryp = ((mouseY-(height/2))*0.01);
  rx = (rx*0.9)+(rxp*0.1);
  ry = (ry*0.9)+(ryp*0.1);
  rotateY(rx);
  rotateX(ry);
  noFill();
  sphereDetail(12);
  
  stroke(255,50);
  strokeWeight(0.1);
  if (song != null)
  {
    for (int i = 0; i < song.bufferSize() - 1; i+=24 )
    {
      sphere(50+song.left.get(i+2)*1000);
    }
  }
  
}


void stop()
{
  song.close();
  super.stop();
}
void mouseMoved() {
  camera1.zoom(radians(mouseY - pmouseY) / 4);
}

Herramientas personales