SlideShare a Scribd company logo
1 of 27
//

   ofxOscMessage m;

   m.setAddress( "/setxy" );

   m.addFloatArg( float(x) / float(ofGetWidth()));

   m.addFloatArg( float(y) / float(ofGetHeight()));

   sender.sendMessage( m );
#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;
string message;
     int sliderValue;
     ofPoint position;
};

#endif
#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;
}
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();


       
         }
    }
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 );
}
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){
}
(
//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);
)
//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;
//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;
)
#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; //
};
#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){}
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);
}
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){}
Sbaw091027
Sbaw091027
Sbaw091027
Sbaw091027
Sbaw091027

More Related Content

What's hot

openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートIIopenFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートIIAtsushi Tadokoro
 
openFrameworks入門 - 多摩美メディアアートII
openFrameworks入門 - 多摩美メディアアートIIopenFrameworks入門 - 多摩美メディアアートII
openFrameworks入門 - 多摩美メディアアートIIAtsushi Tadokoro
 
Cómo crear una calculadora js jv-ng
Cómo crear una calculadora js jv-ngCómo crear una calculadora js jv-ng
Cómo crear una calculadora js jv-nggzuz sanchez
 
python-geohex
python-geohexpython-geohex
python-geohexRyo Aita
 
Most Common JavaScript Mistakes
Most Common JavaScript MistakesMost Common JavaScript Mistakes
Most Common JavaScript MistakesYoann Gotthilf
 
The core of javascript
The core of javascriptThe core of javascript
The core of javascriptspringuper
 
Infitopost notepad
Infitopost   notepadInfitopost   notepad
Infitopost notepadAnand Kumar
 
c ++ informe Nº5 ucsm
c ++ informe Nº5 ucsmc ++ informe Nº5 ucsm
c ++ informe Nº5 ucsmIsaac Aquino
 
The Flavor of TypeScript
The Flavor of TypeScriptThe Flavor of TypeScript
The Flavor of TypeScriptDmitry Sheiko
 
Metodos Numericos(Segundo Taller De Aplicadas)
Metodos Numericos(Segundo Taller De Aplicadas)Metodos Numericos(Segundo Taller De Aplicadas)
Metodos Numericos(Segundo Taller De Aplicadas)guest1bb7f49
 

What's hot (18)

Rafael vasquez
Rafael vasquezRafael vasquez
Rafael vasquez
 
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートIIopenFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
 
openFrameworks入門 - 多摩美メディアアートII
openFrameworks入門 - 多摩美メディアアートIIopenFrameworks入門 - 多摩美メディアアートII
openFrameworks入門 - 多摩美メディアアートII
 
Cómo crear una calculadora js jv-ng
Cómo crear una calculadora js jv-ngCómo crear una calculadora js jv-ng
Cómo crear una calculadora js jv-ng
 
python-geohex
python-geohexpython-geohex
python-geohex
 
week-24x
week-24xweek-24x
week-24x
 
Simulacion - Algoritmo congruencial cuadratico
Simulacion - Algoritmo congruencial cuadraticoSimulacion - Algoritmo congruencial cuadratico
Simulacion - Algoritmo congruencial cuadratico
 
Most Common JavaScript Mistakes
Most Common JavaScript MistakesMost Common JavaScript Mistakes
Most Common JavaScript Mistakes
 
The core of javascript
The core of javascriptThe core of javascript
The core of javascript
 
Davidgordillo2
Davidgordillo2Davidgordillo2
Davidgordillo2
 
Infitopost notepad
Infitopost   notepadInfitopost   notepad
Infitopost notepad
 
c ++ informe Nº5 ucsm
c ++ informe Nº5 ucsmc ++ informe Nº5 ucsm
c ++ informe Nº5 ucsm
 
The Flavor of TypeScript
The Flavor of TypeScriptThe Flavor of TypeScript
The Flavor of TypeScript
 
Metodos Numericos(Segundo Taller De Aplicadas)
Metodos Numericos(Segundo Taller De Aplicadas)Metodos Numericos(Segundo Taller De Aplicadas)
Metodos Numericos(Segundo Taller De Aplicadas)
 
Bifurcaciones (Ejemplo)
Bifurcaciones (Ejemplo)Bifurcaciones (Ejemplo)
Bifurcaciones (Ejemplo)
 
Includes
IncludesIncludes
Includes
 
Assignment
AssignmentAssignment
Assignment
 
Dij
DijDij
Dij
 

Viewers also liked (19)

Ginger Kipps Portfolio
Ginger Kipps PortfolioGinger Kipps Portfolio
Ginger Kipps Portfolio
 
Technology And Education 1
Technology And Education 1Technology And Education 1
Technology And Education 1
 
Nje D3
Nje D3Nje D3
Nje D3
 
Creative Commons Power Point
Creative Commons Power PointCreative Commons Power Point
Creative Commons Power Point
 
Native App vs. Browser
Native App vs. BrowserNative App vs. Browser
Native App vs. Browser
 
Handout1 PSD
Handout1 PSDHandout1 PSD
Handout1 PSD
 
Virginia Kipps Portfolio 2 11
Virginia Kipps Portfolio 2 11Virginia Kipps Portfolio 2 11
Virginia Kipps Portfolio 2 11
 
Nje D3
Nje D3Nje D3
Nje D3
 
Nje D3
Nje D3Nje D3
Nje D3
 
Technology And Education 1
Technology And Education 1Technology And Education 1
Technology And Education 1
 
Semana del libro
Semana del libroSemana del libro
Semana del libro
 
Pa La Pres Final
Pa La Pres FinalPa La Pres Final
Pa La Pres Final
 
Work Hard Work Smart
Work Hard Work SmartWork Hard Work Smart
Work Hard Work Smart
 
A Case Study on Diamond Marketing - what is the meaning of diamond to Chinese...
A Case Study on Diamond Marketing - what is the meaning of diamond to Chinese...A Case Study on Diamond Marketing - what is the meaning of diamond to Chinese...
A Case Study on Diamond Marketing - what is the meaning of diamond to Chinese...
 
Work Hard Work Smart1
Work Hard Work Smart1Work Hard Work Smart1
Work Hard Work Smart1
 
Hyperinflation
HyperinflationHyperinflation
Hyperinflation
 
Biological Clock
Biological ClockBiological Clock
Biological Clock
 
Work Hard Work Smart
Work Hard Work SmartWork Hard Work Smart
Work Hard Work Smart
 
Globalisation and its links to the five dimensions of poverty
Globalisation and its links to the five dimensions of povertyGlobalisation and its links to the five dimensions of poverty
Globalisation and its links to the five dimensions of poverty
 

Sbaw091027

  • 1.
  • 2.
  • 3. // ofxOscMessage m; m.setAddress( "/setxy" ); m.addFloatArg( float(x) / float(ofGetWidth())); m.addFloatArg( float(y) / float(ofGetHeight())); sender.sendMessage( m );
  • 4.
  • 5.
  • 6. #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;
  • 7. string message; int sliderValue; ofPoint position; }; #endif
  • 8. #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; }
  • 9. 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(); } }
  • 10. 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 ); }
  • 11. 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){ }
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. ( //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); )
  • 17. //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;
  • 18. //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; )
  • 19. #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; // };
  • 20. #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){}
  • 21. 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); }
  • 22. 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){}