Hi,
I want to send some variables from a program wrote in c++ to pd. How can I do that?
Tx
-
C++
-
ok...if you want the program in c++ to be running alongside Pd and have the two programs communicate (ie exchange variables, etc), the easiest way is probably to implement tcp/ip support in your c++ program and send variables to the port that Pd is listening too. i haven't done tcp/ip programming in c++ yet, but i did write a perl program that communicated with Pd. if you'd like to use native, builtin Pd objects, netsend and netreceive are what you are looking for. however, your c++ program will be more portable and reusable if you use OSC.
make sense?
--zac -
tx,
where can i find some examples of osc communication?
i have tried with c not with c++, but i get a message form pd when i try to execute netreceive saying that the port is busy.
sugestions? -
if i have some time this week, i'll dig up the Perl script and Pd patch i made to communicate between Perl and Pd. i know Perl isn't what you are working with but it will give you some idea of how to get the netreceive and netsend stuff working.
as far as OSC goes, check out this webpage:
[url=http://www.cnmat.berkeley.edu/OpenSoundControl/index.html ]http://www.cnmat.berkeley.edu/OpenSoundControl/index.html
OSC allows computers to communicate using a URL-style addressing scheme with messages containing various data types. it's pretty helpful for going from computer to computer (e.g. you have two Pd systems running), although OSC is also great for communication between different software on one computer. -
Hi,
I am trying with OSC. I followd the ling you gave me. From there I followed the pd link to http://barely.a.live.fm/pd/OSC/, that it is not working right now. But I found that in http://barely.a.live.fm/pd/OSC/OLD are some files. From those files I tried OSCx.tgz and OSCx.0.15b1.tgz. I tried to followed the instructions and I had a problem with tne m_imp.h with both packages. I got
In file included from dumpOSC.c:71:
m_imp.h:17: error: syntax error before "t_symbol"
followd by a huge list of errors.
I also tried with the flies from [url=http://cvs.sourceforge.net/viewcvs.py/pure-data/externals/OSCx/#dirlist, ]http://cvs.sourceforge.net/viewcvs.py/pure-data/externals/OSCx/#dirlis t,
I downloaded them manually because I don´t know a more smart way to do that. I followd the instructions in the readme file. When I get to execute the command "make OSC" in the folder OSC I get
/usr/lib/gcc/i386-redhat-linux/3.4.3/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
OSC.o(.text+0x17): In function `OSC_new':
: undefined reference to `pd_new'
followd by many lines.
How did you install the OSC library? Any idea where is my mistake?
tx -
i didn't actually compile my own OSC library. my binaries for OSC came with the Pd package I installed. what platform are you using? i am on win xp and can probably point you in the right direction for windows binaries. check this forum for OSC, because i think this matter has been discussed before.
if you need to compile your own binary, you will most likely need to change the provided make files so they are compatible with you system.
--zac -
i am working on fedorra core 3. I got the package from planet crrma that doesn't provide OSC. I will check the forum discussions to find out how to solve this issue. Thanks.
-
For this code I used the src from pd. This lines are written in c and they create, communicate and write info to a socket. I added a ';' at the end of the string that is generated from the interaction with the keyboard. That allows to send the info to pd. the patch with netreceive has to be open in pd otherwise the socket won't be created. It was written in fc3.
#include <sys/types.h> #include <string.h> #include <stdio.h> #include <errno.h> #include <stdlib.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h> #include <netdb.h> #include <stdio.h> #include <unistd.h> #define SOCKET_ERROR -1 #define BUFSIZE 4096 int main(int argc, char **argv) { int sockfd, portno=3000, protocol; struct sockaddr_in server; struct hostent *hp; char *hostname; hostname = "127.0.0.1"; protocol = SOCK_STREAM; sockfd = socket(AF_INET, protocol, 0); if (sockfd < 0) exit(1); server.sin_family = AF_INET;//connect socket using hostname hp = gethostbyname(hostname); if (hp == 0) exit(1); memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length); server.sin_port = htons((unsigned short)portno); //assign client port number connect(sockfd,(struct sockaddr *) &server, sizeof (server));//connect while (1) //now loop reading stdin and sending it to socket { char buf[BUFSIZE], *bp, nsent, nsend; fgets(buf, BUFSIZE, stdin); nsend = strlen(buf); for (bp = buf, nsent = 0; nsent < nsend;) { int res = send(sockfd, buf, nsend-nsent, 0); if (res < 0) exit(1); send(sockfd, ";", 1, 0); nsent += res; bp += res; } } }
htttp://onsight.id.gu.se/~alejandro/portfolio
-
This is reviving a very old thread, but does anyone know where I can find a tutorial to link PD to C++? I have downloaded the OSCPACK before but have to build my own class library. My C++ programming skills are such that I can make a few programs in C++ but cant begin to understand what building my own class library even means. I'd be very grateful to hear from anyone who has done this before..?
-
I don't know if this is useful to you but ZenGarden - https://github.com/mhroth/ZenGarden - is a rewrite of Pd in C++. You could incorporate it as a library into your program.
-
If you want to embed Pd into a C++ program, you should check out libpd: http://gitorious.org/pdlib/pages/Libpd
-
C++ http://www.openframeworks.cc/ offers an OSC addon called ofxOsc (by Damian Stewart) which I find very helpful to communicate with Pd :-D
To receive OSC messages I use [dumpOSC 12345] with the apparently deprecated (?) [routeOSC]...