SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートIIopenFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
Atsushi Tadokoro
 
openFrameworks入門 - 多摩美メディアアートII
openFrameworks入門 - 多摩美メディアアートIIopenFrameworks入門 - 多摩美メディアアートII
openFrameworks入門 - 多摩美メディアアートII
Atsushi Tadokoro
 
python-geohex
python-geohexpython-geohex
python-geohex
Ryo Aita
 
Infitopost notepad
Infitopost   notepadInfitopost   notepad
Infitopost notepad
Anand Kumar
 
c ++ informe Nº5 ucsm
c ++ informe Nº5 ucsmc ++ informe Nº5 ucsm
c ++ informe Nº5 ucsm
Isaac Aquino
 

Mais procurados (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
 

Mais de Atsushi Tadokoro

「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
Atsushi Tadokoro
 
プログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめようプログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめよう
Atsushi Tadokoro
 
Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2
Atsushi Tadokoro
 
coma Creators session vol.2
coma Creators session vol.2coma Creators session vol.2
coma Creators session vol.2
Atsushi Tadokoro
 
Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1
Atsushi Tadokoro
 
Interactive Music II Processingによるアニメーション
Interactive Music II ProcessingによるアニメーションInteractive Music II Processingによるアニメーション
Interactive Music II Processingによるアニメーション
Atsushi Tadokoro
 
Interactive Music II Processing基本
Interactive Music II Processing基本Interactive Music II Processing基本
Interactive Music II Processing基本
Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Atsushi Tadokoro
 
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Atsushi Tadokoro
 
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描くiTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
Atsushi Tadokoro
 
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリメディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
Atsushi Tadokoro
 
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Atsushi Tadokoro
 
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
Atsushi Tadokoro
 
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3DプログラミングWebデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Atsushi Tadokoro
 
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画するiTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
Atsushi Tadokoro
 
Media Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替えMedia Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替え
Atsushi Tadokoro
 

Mais de Atsushi Tadokoro (20)

「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
 
プログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめようプログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめよう
 
Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2
 
coma Creators session vol.2
coma Creators session vol.2coma Creators session vol.2
coma Creators session vol.2
 
Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1
 
Interactive Music II Processingによるアニメーション
Interactive Music II ProcessingによるアニメーションInteractive Music II Processingによるアニメーション
Interactive Music II Processingによるアニメーション
 
Interactive Music II Processing基本
Interactive Music II Processing基本Interactive Music II Processing基本
Interactive Music II Processing基本
 
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
 
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
 
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
 
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描くiTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
 
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリメディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
 
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
 
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
 
Tamabi media131118
Tamabi media131118Tamabi media131118
Tamabi media131118
 
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3DプログラミングWebデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
 
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画するiTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
 
Media Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替えMedia Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替え
 

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){}