papa_sangre I assume that the only way to do this is by using OSC. Is this correct?
Are you sending low-rate data or are you planning to send full-bandwidth? For low-rate data, you could use MIDI if you prefer. With the new v0.3 image, Bela shows up as a MIDI device on your computer, so data sent from the board to the port hw:0,0,0
will be received on the host computer. However, I think the OSC approach is better, as it scales more easily if you use a Wireless or wired connection other than the regular USB.
OSC would also potentially allow you to send audio-rate data, and I have done it in the past, however this poses some issues of bandwidth and clock-drift that could be difficult to address.
Back to basic OSC communication: the example consists of a bi-directional communication to an OSC server. The docs say:
In `setup()` an OSC message to address `/osc-setup`, it then waits
1 second for a reply on `/osc-setup-reply`.
if the response is not received within a second, then you get timeout
.
The docs go on:
in `render()` the code receives OSC messages, parses them, and sends
back an acknowledgment.
So in order for any message to be sent out at this point, the code expects a message to come in first.
For the above message/acknowledgment mechanism to work, the example expects properly configured server, hence the necessity to run node resources/osc/osc.js
alongside it. However, if you simply want to send messages to wekinator, then you do not need most of the above and your code could be something like:
#include <Bela.h>
#include <OSCServer.h>
#include <OSCClient.h>
OSCServer oscServer;
OSCClient oscClient;
int localPort = 7562;
int remotePort = 7563;
const char* remoteIp = "192.168.7.1";
bool setup(BelaContext *context, void *userData)
{
oscServer.setup(localPort);//this is not actually needed if you do not need to receive messages
oscClient.setup(remotePort, remoteIp);
return true;
}
void render(BelaContext *context, void *userData)
{
oscClient.queueMessage(oscClient.newMessage.to("/weka-address").add(4.2f).end());
}
void cleanup(BelaContext *context, void *userData)
{
}