Sbaw091027

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Sbaw091027 - Presentation Transcript

    1. // ofxOscMessage m; m.setAddress( "/setxy" ); m.addFloatArg( float(x) / float(ofGetWidth())); m.addFloatArg( float(y) / float(ofGetHeight())); sender.sendMessage( m );
    2. #ifndef _TEST_APP #define _TEST_APP #include "ofMain.h" #include "ofxOsc.h" class testApp : public ofBaseApp { public: void setup(); void update(); void draw(); void keyPressed (int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); //OSC ofxOscSender sender;
    3. string message; int sliderValue; ofPoint position; }; #endif
    4. #include "testApp.h" void testApp::setup(){ ofBackground(0, 0, 0); //OSC //IP port IP:127.0.0.1 port:3000 sender.setup("127.0.0.1", 3000); // OSC "/message" ofxOscMessage m; m.setAddress( "/message" ); m.addStringArg("oF -> Max: connected"); // sender.sendMessage(m); //OSC port:3001 receiver.setup(3001); sliderValue = 0; }
    5. void testApp::update(){ //OSC // while(receiver.hasWaitingMessages()){ //OSC ofxOscMessage m; // receiver.getNextMessage(&m); //OSC "/slider" if ( m.getAddress() == "/slider" ){ //sliderValue int sliderValue = m.getArgAsInt32(0); } //OSC "/position" if ( m.getAddress() == "/position" ){ //position x y int position.x = m.getArgAsInt32(0)/127.0 * ofGetWidth(); position.y = ofGetHeight() - m.getArgAsInt32(1)/127.0 * ofGetHeight(); } }
    6. void testApp::draw(){ //sliderValue ofSetColor(255, 255, 255); string buf; buf = "slider value: " + ofToString(sliderValue, 4); ofDrawBitmapString( buf, 20, 20 ); //positoin ofSetColor(0, 31, 255); ofCircle(position.x, position.y, 40); } void testApp::keyPressed(int key){ } void testApp::keyReleased(int key){ } void testApp::mouseMoved(int x, int y){ // OSC OSC "/mouse/position" ofxOscMessage m; m.setAddress( "/mouse/position" ); m.addIntArg( x ); m.addIntArg( y ); sender.sendMessage( m ); }
    7. void testApp::mouseDragged(int x, int y, int button){ } void testApp::mousePressed(int x, int y, int button){ // OSC OSC "/mouse/mouse" 1 ofxOscMessage m; m.setAddress( "/mouse/button" ); m.addIntArg(1); sender.sendMessage( m ); } void testApp::mouseReleased(int x, int y, int button){ // OSC OSC "/mouse/mouse" 0 ofxOscMessage m; m.setAddress( "/mouse/button" ); m.addIntArg(0); sender.sendMessage( m ); } void testApp::windowResized(int w, int h){ }
    8. ( //FM SynthDef("fm2", { arg bus = 0, freq = 440, carPartial = 0.5, modPartial = 0.5, detune=2.0, index = 3, mul = 0.2, ts = 1; var mod; var car; mod = SinOsc.ar( freq * modPartial, 0, freq * index * LFNoise1.kr(5.reciprocal).abs); car = SinOsc.ar( [(freq * carPartial) + mod,(freq+detune * carPartial) + mod], 0, mul); car = FreeVerb.ar( car* EnvGen.kr(Env.new([0,1], [5])), 0.5, 0.8, 0.2, 1.0); Out.ar(bus, car); }).load(s); )
    9. //OSCResponder ( var play=false; // ON/OFF OSC "/toggle" OSCresponderNode(nil, "/toggle", { arg time, resp, msg; if(msg[1] == 1, { s.sendMsg("/s_new", "fm2", x=s.nextNodeID, 1,1); play=true; }, { s.sendMsg("/n_free", x); play=false; } ) }).add;
    10. //FM OSC "/setxy" OSCresponderNode(nil, "/setxy", { arg time, resp, msg; var mod, index; mod = msg[1]*4.0; index = msg[2]*100.0; if(play == true, { s.sendMsg("/n_set", x, "modPartial", mod, "index", index); }); }).add; )
    11. #ifndef _TEST_APP #define _TEST_APP #include "ofMain.h" #include "ofxOsc.h" #define HOST "localhost" #define PORT 57120 class testApp : public ofBaseApp { public: void setup(); void update(); void draw(); void keyPressed (int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); ofxOscSender sender; //OSC string info; // };
    12. #include "testApp.h" void testApp::setup(){ ofBackground(0, 0, 0); // OSC sender.setup( HOST, PORT ); } void testApp::update(){ } void testApp::draw(){ // ofDrawBitmapString(info, 10, 10); } void testApp::keyPressed(int key){} void testApp::keyReleased(int key){} void testApp::mouseMoved(int x, int y){}
    13. void testApp::mouseDragged(int x, int y, int button){ // OSC "/setxy" ofxOscMessage m; m.setAddress( "/setxy" ); m.addFloatArg( float(x) / float(ofGetWidth())); m.addFloatArg( float(y) / float(ofGetHeight())); sender.sendMessage( m ); info = m.getAddress()+" "+ m.getArgAsString(0)+ " "+ m.getArgAsString(1); } void testApp::mousePressed(int x, int y, int button){ // OSC "/toggle" ofxOscMessage m; m.setAddress( "/toggle" ); m.addIntArg( 1 ); sender.sendMessage( m ); info = m.getAddress() + " " + m.getArgAsString(0); }
    14. void testApp::mouseReleased(int x, int y, int button){ // OSC "/toggle" ofxOscMessage m; m.setAddress( "/toggle" ); m.addIntArg( 0 ); sender.sendMessage( m ); info = m.getAddress() + " " + m.getArgAsString(0); } void testApp::windowResized(int w, int h){}
    SlideShare Zeitgeist 2009

    + Atsushi TadokroAtsushi Tadokro Nominate

    custom

    109 views, 0 favs, 1 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 109
      • 62 on SlideShare
      • 47 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 2
    Most viewed embeds
    • 47 views on http://yoppa.org

    more

    All embeds
    • 47 views on http://yoppa.org

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?