2 SuperColliderAU Copyright (c) 2006 Gerard Roma.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "OSCMessages.h"
21 OSCMessages::OSCMessages(){ }
23 size_t OSCMessages::parameterMessage(small_scpacket
*packet
, CFStringRef name
, float value
){
25 CFIndex bufLength
= CFStringGetMaximumSizeForEncoding(CFStringGetLength(name
), kCFStringEncodingUTF8
) + 1;
26 char* buf
= (char*) malloc(bufLength
);
27 CFStringGetCString(name
, buf
, bufLength
, kCFStringEncodingUTF8
);
28 size_t nameSize
= ((strlen(buf
)+ 4) >> 2)*4;
29 size_t messageSize
= nameSize
+ 24;
30 packet
->adds("/n_set");
34 packet
->addi(kDefaultNodeId
);
44 small_scpacket
OSCMessages::sendTickMessage(int64 oscTime
, int bus
){
45 small_scpacket packet
;
46 packet
.OpenBundle(oscTime
);
48 packet
.adds("/c_set");
61 small_scpacket
OSCMessages::initTreeMessage(){
62 small_scpacket packet
;
63 packet
.adds("/g_new");
71 small_scpacket
OSCMessages::quitMessage(){
72 small_scpacket packet
;
78 size_t OSCMessages::createSynthMessage(small_scpacket
*packet
, CFStringRef name
){
80 CFIndex bufLength
= CFStringGetMaximumSizeForEncoding(CFStringGetLength(name
), kCFStringEncodingUTF8
) + 1;
81 char* buf
= (char*) malloc(bufLength
);
82 CFStringGetCString(name
, buf
, bufLength
, kCFStringEncodingUTF8
);
83 size_t nameSize
= ((strlen(buf
)+ 4) >> 2)*4;
84 size_t messageSize
= nameSize
+16;
85 packet
->adds("/s_new");
91 packet
->addi(kDefaultNodeId
);
96 small_scpacket
OSCMessages::noteMessage(int64 oscTime
, int note
, int velocity
){
97 small_scpacket packet
;
98 packet
.OpenBundle(oscTime
);
101 packet
.adds("/n_set");
105 packet
.addi(kDefaultNodeId
);
107 packet
.adds("/note");
113 packet
.adds("/n_set");
117 packet
.addi(kDefaultNodeId
);
119 packet
.adds("/velocity");
121 packet
.addi(velocity
);
124 packet
.CloseBundle();