Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Files Functions Variables Typedefs Macros Groups
OSCServer.h
1 /***** OSCServer.h *****/
2 #ifndef __OSCServer_H_INCLUDED__
3 #define __OSCServer_H_INCLUDED__
4 
5 #include <UdpServer.h>
6 #include <oscpkt.hh>
7 #include <Bela.h>
8 #include <queue>
9 
10 #define UDP_RECEIVE_TIMEOUT_MS 20
11 #define UDP_RECEIVE_MAX_LENGTH 16384
12 
27 class OSCServer{
28  public:
29  OSCServer();
30 
39  void setup(int port);
40 
50  bool messageWaiting();
51 
64  oscpkt::Message popMessage();
65 
78  void receiveMessageNow(int timeout);
79 
80  private:
81  int port;
82  UdpServer socket;
83 
84  AuxiliaryTask OSCReceiveTask;
85 
86  void createAuxTasks();
87  void messageCheck();
88 
89  static void checkMessages(void*);
90 
91  int inBuffer[UDP_RECEIVE_MAX_LENGTH];
92  std::queue<oscpkt::Message> inQueue;
93  oscpkt::Message poppedMessage;
94  oscpkt::PacketReader pr;
95 };
96 
97 
98 #endif
void receiveMessageNow(int timeout)
Blocks execution until an OSC message is received.
Definition: UdpServer.h:22
void setup(int port)
Sets the port used to receive OSC messages.
oscpkt::Message popMessage()
Removes and returns the oldest message from the queue.
bool messageWaiting()
Returns true if an OSC message has been received and queued.
OSCServer provides functions for receiving OSC messages in Bela.
Definition: OSCServer.h:27
Main Bela public API.
void * AuxiliaryTask
Definition: Bela.h:445