Frage

I'm trying to use libPd, the wrapper for PureData. But the documentation is poor and I'm not very into C++ Do you know how I can simply send a floating value to a Pd patch?

Do I need to install libPd or I can just include the files?

War es hilfreich?

Lösung 2

if you want to send a value to a running instance of Pd (the standalone application), you could do so via Pd's networking facilities.

e.g.

[netreceive 65432 1]
|
[route value]
|
[print]

will receive data sent from the cmdline via:

echo "value 1.234567;" | pdsend 65432 localhost udp

you can also send multiple values at once, e.g.

echo "value 1.234567 3.141592;" | pdsend 65432 localhost udp

if you find pdsend to slow for your purposes (e.g. if you launch the executable for each message you want to send you have a considerable overhead!), you could construct the message directly in your application and use an ordinary UDP-socket to send FUDI-messages to Pd.

FUDI-messages really are simple text strings, with atoms separated by whitespace and a terminating semicolon, e.g.

accelerator 1.23 3.14 2.97; button 1;

you might also considering using OSC, but for this you will need some externals (OSC by mrpeach; net by mrpeach (or iemnet)) on the Pd side.

as for performance, i've been using the latter with complex tracking data (hundreds of values per frame at 125fps) and for streaming multichannel audio, so i don't think this is a problem.

if you are already using libPd and only want to communicate from the host-application, use Adam's solution (but your question is a bit vague about that, so i'm including this answer just in case)

Andere Tipps

First of all, check out ofxpd. It has an excellent libpd implementaiton with OpenFrameworks. If you are starting with C++ you may want to start with OpenFrameworks since it has some great documentation and nice integration with Pd via the ofxpd extension.

There are two good references for getting started with libpd (though neither cover C++ in too much detail): the original article and Peter Brinkmann's book.

On the libpd wiki there is a page for getting started with libpd. The linked project at the bottom has some code snippets in main.cpp that demonstrate how to send floats to your Pd patch.

pd.sendBang("fromCPP");
pd.sendFloat("fromCPP", 100);
pd.sendSymbol("fromCPP", "test string");

In your Pd patch you'll set up a [receive fromCPP] and then these messages will register in your patch.

In order to get the print output you have to use the receivers from libpd in order to receiver the strings and then do something with them. libpd comes with PdBase, which is a great class for getting libpd up and running. PdBase has sendBang, sendFloat, sendMessage, and also has the receivers set up so that you can get output from your Pd patch.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top