scratch con max/msp y processing [VIDEO] and some source
Posted on 08.04.09 by i2off @ 9:52 PM

esa es una version que testeamos junto a la gente de Sudala.cl (pablo y nolo)
muchas gracias a ellos por la onda para probarlo

aca va un pic del main patch de maxmsp
main patch Scratch App on Max/MSP

y aca va el source de processing del control de la bandeja

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

int ww=800;
int hh=600;
int discoX=400;
int discoY=400;
float rotaDisco=0;

float SDJlengthsample=0;
float SDJVUELTA=1818.18;
float SDJval=0;
float SDJval2 = 0;
float SDJval2rad=0;
float SDJval2radT=0;
float SDJlastval=0;
float SDJvalT=0;
float SDJvalFrame=0;
float SDJvalFrameT=0;
float SDJgradT=0;
float SDJrota=0;
float SDJrotaAnt=0;
int SDJmodostop=0;
float SDJinercia=0.0;
float SDJinercia2=0.0;

int SDJmouseDown=0;

void setup(){
size(ww,hh,P3D);
oscP5 = new OscP5(this,12000);
myRemoteLocation = new NetAddress("127.0.0.1",13000);
OscMessage myMessage = new OscMessage("/sDJ/requestData");
myMessage.add(1);
oscP5.send(myMessage, myRemoteLocation);
}
void draw(){
background(50);
if(mousePressed){
if(SDJmouseDown==0){
SDJval2radT = atan2(mouseX-discoX,mouseY-discoY);
SDJgradT=SDJval2radT;

SDJmouseDown=1;
if(SDJmodostop==0){
SDJrota=0;
SDJrotaAnt=0;
SDJinercia=0;
OscMessage myMessage = new OscMessage("/sDJ/mouseState");
myMessage.add(1);
oscP5.send(myMessage, myRemoteLocation);
}
}else{
float gg=atan2(mouseX-discoX,mouseY-discoY);
float grad1=(gg-SDJgradT)%(PI);
if(grad1>PI/2.0){
grad1-=PI;
}
if(grad1<-PI/2.0){
grad1+=PI;
}
SDJgradT=gg;
SDJrota+=grad1;
float vv=SDJrota;//(rota-val2radT);
SDJval2rad = SDJvalT-vv;
//if(grad1!=0){
SDJinercia=grad1;
//}
float ff=(((((-vv*180.0/PI)+180.0)/360.0)-0.5)*SDJVUELTA);
float SDJval2 = SDJvalFrameT+ff;
if(SDJval2<0){
SDJval2=SDJlengthsample-(abs(SDJval2)%SDJlengthsample);
}
//println(SDJlengthsample);
OscMessage myMessage = new OscMessage("/sDJ/newPos");
myMessage.add(SDJval2);
oscP5.send(myMessage, myRemoteLocation);
}
}else{
if(SDJmouseDown==1){
if(SDJmodostop==0){
OscMessage myMessage = new OscMessage("/sDJ/mouseState");
myMessage.add(0);
oscP5.send(myMessage, myRemoteLocation);
}
SDJmouseDown=0;
}

}
pushMatrix();
ellipseMode(CENTER);
translate(discoX,discoY,0);
if(SDJmouseDown==0 && SDJmodostop==0){
SDJval2=SDJvalFrame;
SDJvalFrameT=SDJvalFrame;
SDJval2rad=SDJval;
SDJvalT=SDJval;
SDJinercia*=0.9;
OscMessage myMessage = new OscMessage("/sDJ/inercia");
myMessage.add(SDJinercia);
oscP5.send(myMessage, myRemoteLocation);
rotateZ(SDJval);
}else{
if(SDJmouseDown==0){
makeInercia();
}
rotateZ(SDJval2rad);

}

fill(255);
ellipse(0,0,300,300);
translate(0,130,0);
fill(100);
ellipse(0,0,30,30);
popMatrix();
rotaDisco+=0.1;
}
void makeInercia(){
SDJrota+=SDJinercia;
float vv=SDJrota;
SDJval2rad = SDJvalT-vv;
float ff=(((((-vv*180.0/PI)+180.0)/360.0)-0.5)*SDJVUELTA);
SDJval2 = SDJvalFrameT+ff;
if(SDJval2<0){
SDJval2=SDJval2+SDJlengthsample;
}
SDJinercia*=0.95;
OscMessage myMessage = new OscMessage("/sDJ/newPos");
myMessage.add(SDJval2);
oscP5.send(myMessage, myRemoteLocation);
}
void oscEvent(OscMessage theOscMessage) {
/* print the address pattern and the typetag of the received OscMessage */
//print("### received an osc message.");
//print(" addrpattern: "+theOscMessage.addrPattern());
//println(" typetag: "+theOscMessage.typetag());
if(theOscMessage.checkAddrPattern("/sDJ/rotadisco")){
float v=theOscMessage.get(0).floatValue();
//println(v);
SDJval = (((v%SDJVUELTA)/SDJVUELTA)*360.0)*PI/180;
SDJvalFrame=v;
}
if(theOscMessage.checkAddrPattern("/sDJ/setlength")){
float v=theOscMessage.get(0).floatValue();
SDJlengthsample=v;
}
if(theOscMessage.checkAddrPattern("/sDJ/setstop")){
SDJmodostop=1;
SDJrota=0;
SDJrotaAnt=0;
SDJinercia=0;
OscMessage myMessage = new OscMessage("/sDJ/mouseState");
myMessage.add(1);
oscP5.send(myMessage, myRemoteLocation);
}
if(theOscMessage.checkAddrPattern("/sDJ/setplay")){
SDJmodostop=0;
OscMessage myMessage = new OscMessage("/sDJ/mouseState");
myMessage.add(0);
oscP5.send(myMessage, myRemoteLocation);
}
}


Filed under: audio and maxmsp and processing and sourcecode
Comments:

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)


*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


Stream.i2offPlusR3nder

Main Menu
Home
audio
maxmsp
opencv
processing
quartzcomposer
sourcecode
Uncategorized
videomapping

Search

  • Sites

  • Social


  • Syndication
    RSS 2.0
    Comments RSS 2.0
    WordPress

    Credits and Copyright
    Proudly powered by WordPress. All content © 2004-2005 Author
    Wordpress Firewall (*)

    Archives
    August 2009
    July 2009
    April 2009
    March 2009
    December 2008
    September 2008
    August 2008

    Recent Entries
    scratch con max/msp y processing [VIDEO] and some source
    SamsungDJ (scratch con maxmsp/processing en un touchscreen)[pruebas y codigo en max/msp]
    SamsungDJ (scratch con maxmsp/processing en un touchscreen)
    Guia de Setup de OpenCV con XCode
    Tracking FX en Realtime con FaceRecognition
    Video Mapping sobre superficie Curva, solucion 1
    Nueva Version de OpenFrameworks [permite exportar para iPhone]
    Entorno Para programacion tipo Max/Msp en Processing
    About
    Multitouch para el gobierno de la ciudad de buenos aires
    Automapeo para proyeccion
    Proximas Fechas [Paris y Emiratos Arabes Unidos]
    Proxima fecha, BOGOTA!
    LightPixelApp+ RegnumLuminis [que hay tras LightPixelJockey] [arduino+processing]
    CLANDESTINA WEEKEND NERD NUMBER 3