Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Openframeworks/Pure Data OSC connection, What's wrong?

$
0
0

@Riccardo_Martorana wrote:

Hello, I'm trying to make a simple application with a graphical interface in OF and an audio patch in PD. In brief, the length of four lines drawn in OF should be connected via OSC to four faders in PD which control the pitch of four sound output.

It is supposed to be a basic arpeggiator of four steps, the pitch of each step should be determined by the distance between the central cursor and the graphical base of each step.

OF: I'm not sure whether I should use a bundle or single messages, but I tried both and it doesn't work anyway. If the problem is somewhere else I can't find it.

PD: I'm using PD extended, the patch itself is working, but it seems that it's not receiving anything from OF.

I hope that someone is able to find the problem, I don't know where to look for it! Thank you a lot!

Codes:

OF

void ofApp::setup(){

ofBackground(225);


// open an outgoing connection to HOST:PORT
sender.setup(HOST, PORT);

}

void ofApp::draw(){
ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2);
ofSetColor(0);
myFont.drawString("Distance", -140, -300);

ofPoint p0(mouseX - (ofGetWidth() / 2), mouseY - (ofGetHeight() / 2));

ofPoint p1(-200, -200);
ofPoint p2(200, -200);
ofPoint p3(200, 200);
ofPoint p4(-200, 200);


ofSetColor(0, 0, 0);
ofFill();
ofCircle(p0, 20);
ofCircle(p1, 20);
ofCircle(p2, 20);
ofCircle(p3, 20);
ofCircle(p4, 20);

ofLine(p0, p1);
ofLine(p0, p2);
ofLine(p0, p3);
ofLine(p0, p4);



int dist1 = p0.distance(p1);
int dist2 = p0.distance(p2);
int dist3 = p0.distance(p3);
int dist4 = p0.distance(p4);

ofLog(OF_LOG_NOTICE) << "THE DISTANCE ONE IS " << dist1;
ofSetColor(ofColor::white);
ofDrawBitmapString("Distance one: " + ofToString(dist1), -550, 100);

ofLog(OF_LOG_NOTICE) << "THE DISTANCE TWO IS " << dist2;
ofSetColor(ofColor::white);
ofDrawBitmapString("Distance two: " + ofToString(dist2), -550, 150);

ofLog(OF_LOG_NOTICE) << "THE DISTANCE THREE IS " << dist3;
ofSetColor(ofColor::white);
ofDrawBitmapString("Distance three: " + ofToString(dist3), -550, 200);

ofLog(OF_LOG_NOTICE) << "THE DISTANCE FOUR IS " << dist4;
ofSetColor(ofColor::white);
ofDrawBitmapString("Distance four: " + ofToString(dist4), -550, 250);



ofxOscMessage a;
a.setAddress("/dist1");
ofxOscMessage b;
b.setAddress("/dist2");
ofxOscMessage c;
c.setAddress("/dist3");
ofxOscMessage d;
d.setAddress("/dist4");

ofxOscBundle bundle;
bundle.addMessage(a);   //First ofxOscMessage message
bundle.addMessage(b);
bundle.addMessage(c);
bundle.addMessage(d);

//a.addFloatArg(button);
//b.addFloatArg(button);
//c.addFloatArg(button);
//d.addFloatArg(button);

sender.sendBundle(bundle);
sender.sendMessage(a);
sender.sendMessage(b);
sender.sendMessage(c);

sender.sendMessage(d);

}

PD

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles