-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOscTransmitter.cpp
48 lines (37 loc) · 1.16 KB
/
OscTransmitter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* OscTransmitter.cpp
*
* Created on: Mar 12, 2014
* Author: edwinrietmeijer
*/
#include "OscTransmitter.h"
namespace osctransmitter {
OscTransmitter * OscTransmitter::Instance()
{
static OscTransmitter instance;
return &instance;
}
void OscTransmitter::transmit( std::string streamName, double freq, double dur, double vel ) {
// Wait until previous transmission is completed.
while ( isTransmitting ) {
}
isTransmitting = true;
std::string thisStreamName = '/' + streamName;
p.Clear();
p << osc::BeginBundleImmediate
<< osc::BeginMessage( streamName.c_str() )
<< freq << dur << vel << osc::EndMessage
<< osc::EndBundle;
transmitSocket.Send( p.Data(), p.Size() );
isTransmitting = false;
}
//void OscTransmitter::transmitFake( std::string streamName, double freq, double dur, double vel ) {
// std::string thisStreamName = '/' + streamName;
//
// std::cout << thisStreamName << " " << freq << " " << dur << " " << vel << std::endl;
//
//
//}
OscTransmitter::OscTransmitter() : isTransmitting( false ), transmitSocket( IpEndpointName( ADDRESS, SENDPORT ) ), p( buffer, OUTPUT_BUFFER_SIZE ) {
}
} /* namespace osctransmitter */