-
Notifications
You must be signed in to change notification settings - Fork 8
/
Pattern.cpp
68 lines (50 loc) · 1.31 KB
/
Pattern.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
ArdOSC 2.1 - OSC Library for Arduino.
-------- Lisence -----------------------------------------------------------
ArdOSC
The MIT License
Copyright (c) 2009 - 2011 recotana( http://recotana.com ) All right reserved
*/
#include <stdlib.h>
#include <string.h>
#include "OSCcommon/OSCServer.h"
#include "OSCcommon/OSCcommon.h"
#include "OSCCommon/OSCMessage.h"
#include "OSCCommon/Pattern.h"
Pattern::Pattern(){
patternNum=0;
sinkNum=0;
}
Pattern::~Pattern(){
}
void Pattern::addOscAddress(char *_adr , AdrFunc _func){
adrFunc[patternNum] = _func;
addr[patternNum] = _adr;
patternNum++;
}
void Pattern::addOscMessageSink(OscMessageSink* sink ){
sinks[sinkNum]=sink;
sinkNum++;
}
void Pattern::execFunc(uint8_t _index,OSCMessage *_mes){
adrFunc[_index](_mes);
}
void Pattern::paternComp(OSCMessage *_mes){
/*
Serial.print("got message, adress:_");
Serial.print(_mes->_oscAddress );
Serial.println("_");
*/
for (uint8_t i=0 ; i<patternNum ; i++) {
if ( strcmp( addr[i] , _mes->_oscAddress ) == 0 ) execFunc( i , _mes );
}
for (uint8_t i=0 ; i<sinkNum ; i++) {
/*
Serial.print("sending message to sink: _");
Serial.print(sinks[i]-> getAdress());
Serial.print("_: ");
//Serial.println("triggering sink");
*/
sinks[i]->digestMessage(_mes);
}
}