fullscreen
com_in.pdeparticle.pdeparticles.pdetexto.pde
//functions that recive the parameters from the Onionface.
import oscP5.*;
import netP5.*;
//classe on guardem les dades que venen del onionFace.
class onionFaceData_Class{
OscP5 oscP5;
NetAddress myRemoteLocation;
float medLow,medMed,medHi,param1,param2,param3,param4,param5,param6,param7,param8;
int longCadenaFreq;
float[] cadenaFreq;
//boolean lock = false;
//inicialitzem
int numCanals = 16;
//constructor
onionFaceData_Class(){
//start oscP5, listening
oscP5 = new OscP5(this,12000);
myRemoteLocation = new NetAddress("localhost",24000);
cadenaFreq = new float[256];
for (int i=0;i<256;i++){
cadenaFreq[i] = 0;
}
inicializa();
}
/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage){
/* print the address pattern and the typetag of the received OscMessage */
//print("### received an osc message.");
//print(" theOscMessage.get(0).floatValue(): "+theOscMessage.get(0).floatValue());
setMedLow(theOscMessage.get(0).floatValue());
setMedMed(theOscMessage.get(1).floatValue());
setMedHi(theOscMessage.get(2).floatValue());
setLongCadenaFreq(theOscMessage.get(3).intValue());
//geting the float array
//println("theOscMessage.typetag(); = " + theOscMessage.typetag());
for(int i=0;i<getLongCadenaFreq();i++){
setCadenaFreq(theOscMessage.get(i+4).floatValue(),i);
//println("i =" + i+ "theOscMessage.get(i+4).floatValue() = "+ theOscMessage.get(i+4).floatValue()+ "getCadenaFreq(i) ="+getCadenaFreq(i));
}
setParam1(theOscMessage.get(4+getLongCadenaFreq()).floatValue());
setParam2(theOscMessage.get(5+getLongCadenaFreq()).floatValue());
setParam3(theOscMessage.get(6+getLongCadenaFreq()).floatValue());
setParam4(theOscMessage.get(7+getLongCadenaFreq()).floatValue());
setParam5(theOscMessage.get(8+getLongCadenaFreq()).floatValue());
setParam6(theOscMessage.get(9+getLongCadenaFreq()).floatValue());
setParam7(theOscMessage.get(10+getLongCadenaFreq()).floatValue());
setParam8(theOscMessage.get(11+getLongCadenaFreq()).floatValue());
//println("ens entra = " + theOscMessage.get(12+getLongCadenaFreq()).intValue());
//float[] array = theOscMessage.get(4).floatValue();
//println ("este es el valor que nos llega =" + array[1]);
}
void mandaFrames() {
/* in the following different ways of creating osc messages are shown by example */
OscMessage myMessage = new OscMessage("/test");
//myMessage.add(1234);
myMessage.add("frame");
float numFrame = (frameCount/2) + 3000;
println("numFrame = " + numFrame);
myMessage.add(numFrame); /* add an int to the osc message */
oscP5.send(myMessage, myRemoteLocation);
}
void inicializa() {
//inicializar
/* in the following different ways of creating osc messages are shown by example */
OscMessage myMessage = new OscMessage("/iniciar");
myMessage.add(true); /* add an int to the osc message */
oscP5.send(myMessage, myRemoteLocation);
}
//////////////////////////////////////////INFO INTERFICIE//////////////////////////////
void mandaInterf(){
//
OscMessage myMessage = new OscMessage("/infoInterf");
String nomSk = "liniesA5_2";
String param1 = "VEL_CAM+HI";
String param2 = "VEL_LINIES+MED";
String param3 = "COLOR_LINIES+LOW";
String param4 = "TAMANYO_LINIAS";
String param5 = "FREE";
String param6 = "FREE";
String param7 = "COLOR_VERM";
String param8 = "VEL";
myMessage.add(nomSk); /* add an int to the osc message */
myMessage.add(param1);
myMessage.add(param2);
myMessage.add(param3);
myMessage.add(param4);
myMessage.add(param5);
myMessage.add(param6);
myMessage.add(param7);
myMessage.add(param8);
oscP5.send(myMessage, myRemoteLocation);
//oscP5.send(myMessage, myRemoteLocation);
}
////Functions to get and set de diferent variables.
//posa cada un de les factors
////////////////PARAMETRES///////////////////////
void setParam1(float param1){
this.param1 = param1;
}
void setParam2(float param2){
this.param2 = param2;
}
void setParam3(float param3){
this.param3 = param3;
}
void setParam4(float param4){
this.param4 = param4;
}
void setParam5(float param5){
this.param5 = param5;
}
void setParam6(float param6){
this.param6 = param6;
}
void setParam7(float param7){
this.param7 = param7;
}
void setParam8(float param8){
this.param8 = param8;
}
//////////////////////////////////////////////////////////////////////////////////
float getParam1(){
return (param1);
}
float getParam2(){
return (param2);
}
float getParam3(){
return (param3);
}
float getParam4(){
return (param4);
}
float getParam5(){
return (param5);
}
float getParam6(){
return (param6);
}
float getParam7(){
return (param7);
}
float getParam8(){
return (param8);
}
///////////////////////////////////////////
//posa cada un de les
void setMedLow(float medLow){
this.medLow = medLow;
}
//function that returns de medLow
float getMedLow(){
return (this.medLow);
}
//posa cada un de les
void setMedMed(float medMed){
this.medMed = medMed;
}
//function that returns de medLow
float getMedMed(){
return (this.medMed);
}
//posa cada un de les
void setMedHi(float medHi){
this.medHi = medHi;
}
//function that returns de medLow
float getMedHi(){
return (this.medHi);
}
//Funcio que agafa la longitud de la cadana de frecuencies
void setLongCadenaFreq(int longCadenaFreqIn){
longCadenaFreq = longCadenaFreqIn;
//println("estoy definiendo la long del array = " + longCadenaFreq);
cadenaFreq = new float[longCadenaFreq];
}
//function returns the freq array size
int getLongCadenaFreq(){
return(longCadenaFreq);
}
//posa cada un de les
void setCadenaFreq(float cadenaFreqs,int i){
cadenaFreq[i] = cadenaFreqs;
//println(" cadenaFreq[i] =" + cadenaFreq[i]);
}
//function that returns de medLow
float getCadenaFreq(int cont){
float temp = 0;
//println("estoy en getCadenaFreq" + " cont =" + cont+ "cadenaFreq.lenght =" +cadenaFreq.length );
temp = cadenaFreq[cont];
return (temp);
}
}
class particle {
float x;
float y;
float px;
float py;
float magnitude;
float angle;
float mass;
particle( float dx, float dy, float V, float A, float M ) {
float q = onionData.getMedHi()*onionData.getParam1();
x = dx;
y = dy;
px = dx;
py = dy;
magnitude = V;
angle = A;
mass = M;
}
void reset( float dx, float dy, float V, float A, float M ) {
float q = onionData.getMedHi()*onionData.getParam1();
x = dx-+100*q;
y = dy-+100*q;
px = dx;
py = dy;
magnitude = V;
angle = A;
mass = M;
}
void gravitate( particle Z ) {
float F, mX, mY, A;
if( sq( x - Z.x ) + sq( y - Z.y ) != 0 ) {
float q = onionData.getMedHi()*onionData.getParam1();
F = mass * Z.mass*q;
mX = ( mass * x + Z.mass * Z.x ) / ( mass + Z.mass );
mY = ( mass * y + Z.mass * Z.y ) / ( mass + Z.mass );
A = findAngle( mX - x, mY - y );
mX = F * cos(A);
mY = F * sin(A);
mX += magnitude * cos(angle);
mY += magnitude * sin(angle);
magnitude = sqrt( sq(mX) + sq(mY) );
angle = findAngle( mX, mY );
}
}
void repel( particle Z ) {
float F, mX, mY, A;
if( sq( x - Z.x ) + sq( y - Z.y ) != 0 ) {
F = mass * Z.mass;
mX = ( mass * x + Z.mass * Z.x ) / ( mass + Z.mass );
mY = ( mass * y + Z.mass * Z.y ) / ( mass + Z.mass );
A = findAngle( x - mX, y - mY );
mX = F * cos(A);
mY = F * sin(A);
mX += magnitude * cos(angle);
mY += magnitude * sin(angle);
magnitude = sqrt( sq(mX) + sq(mY) );
angle = findAngle( mX, mY );
}
}
void deteriorate() {
magnitude *= 0.925;
}
void update() {
x += magnitude * cos(angle);
y += magnitude * sin(angle);
}
void display() {
line(px,py,x,y);
px = x;
py = y;
}
}
float findAngle( float x, float y ) {
float theta;
if(x == 0) {
if(y > 0) {
theta = HALF_PI;
}
else if(y < 0) {
theta = 3*HALF_PI;
}
else {
theta = 0;
}
}
else {
theta = atan( y / x );
if(( x < 0 ) && ( y >= 0 )) { theta += PI; }
if(( x < 0 ) && ( y < 0 )) { theta -= PI; }
}
return theta;
}
/*
Andres Kõpper
Processing class, IED Barcelona, FINAL PROJECT- mUSIC VIDEo
14.03.2011
This is a typography creator, created with geomerative library for processing.
*/
import ddf.minim.*;
import fisica.*;
// Declare the variable for the background image
PImage backG;
//Declare the classes for the audio library.
Minim minim;
AudioPlayer player;
onionFaceData_Class onionData;
float r;
float g;
float b;
float a;
int NumberStrings =4;
ArrayList MPlist;
String param1 = "otsustamatus";
String param2 = "mõnel needus";
String param3 = "mõnel voorus";
String param4 = "mõnel";
String param5 = "hoolsuse olematus";
String param6 = "tähelepanu puudus";
String param7 = "ei oska mõelda midagi";
String param8 = "ei julge öelda sõnagi";
String param9 ="ei suuda valida";
String param10 = "otsustada, sõnastada";
String param11 = "Tee tee";
String param12 ="ära tee";
String msg = "hea soe";
FWorld world;
PFont font;
particle[] Z = new particle[6000];
float colour = random(1000);
void setup() {
smooth();
size(1080,640,P2D);
background(255);
smooth();
//Set values for RGBA
r = random(140);
g = random(120);
b = random(100);
a = random(140,200);
PFont f;
f = createFont("HandTimes", 24, true);
Fisica.init(this);
//Load the font
font = loadFont("HandTIMES-100.vlw");
minim = new Minim(this);
// load a file, give the AudioPlayer buffers that are 2048 samples long
player = minim.loadFile("suudlus.mp3");
// play the file
player.play();
onionData = new onionFaceData_Class();
float q = onionData.getMedHi()*onionData.getParam1();
for(int i = 0; i < Z.length; i++) {
Z[i] = new particle( random(width), random(height), 0, 0, 1 );
}
frameRate(60);
colorMode(RGB,255);
}
void draw() {
// background(0);
//ellipse(width/2,height/2,q,100);
float r;
stroke(255);
float q = onionData.getMedHi()*onionData.getParam1();
// world.setGravity(random(-20*q,20*q), (random(-20*q,20*q)));
filter(INVERT);
float w = onionData.getMedLow()*onionData.getParam2();
fill(255,140);
rect(0,0,width,height);
//rect(0,0,width/2,height/2);
colorMode(HSB,1);
for(int i = 0; i < Z.length ; i++) {
Z[i].gravitate( new particle(width/2, height/2, 0, 0, 1 ) );
Z[i].repel( new particle( width/2, height/2, 0, 0, 1) );
Z[i].deteriorate();
Z[i].update();
r = float(i)/Z.length;
stroke( colour,pow(r,0.1), 1-r, 0.15 );
Z[i].display();
}
colorMode(RGB,255);
colour+=random(0.01);
if( colour > 1 ) {
colour = colour%1;
}
filter(INVERT);
//fill(0);
//ellipse(width/2,height/2,10+w,10+w);
}
void keyPressed(){
textAlign(CENTER);
float w = onionData.getMedLow()*onionData.getParam2();
fill(0);
textFont(font, w);
//text("oota veel", width/2, height/2+5);
}
//I build the class
class Texto extends FBox {
String texto;
float textOffset;
Texto(String _texto){
super(textWidth(_texto), textAscent() + textDescent());
texto = _texto;
textOffset = textAscent() - getHeight()/2;
}
}