class library: Volume - remove debug message
[supercollider.git] / platform / mac / SuperColliderAU / Source / OSCMessages.cpp
bloba4081d1d4fc074033445a4d96e8935a0a6f88af5
1 /*
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){
24 packet->reset();
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");
31 packet->maketags(4);
32 packet->addtag(',');
33 packet->addtag('i');
34 packet->addi(kDefaultNodeId);
35 packet->addtag('s');
36 packet->adds(buf);
37 packet->addtag('f');
38 packet->addf(value);
39 free (buf);
40 return messageSize;
44 small_scpacket OSCMessages::sendTickMessage(int64 oscTime, int bus){
45 small_scpacket packet;
46 packet.OpenBundle(oscTime);
47 packet.BeginMsg();
48 packet.adds("/c_set");
49 packet.maketags(3);
50 packet.addtag(',');
51 packet.addtag('i');
52 packet.addi(bus);
53 packet.addtag('f');
54 packet.addf(1.0);
55 packet.EndMsg();
56 packet.CloseBundle();
57 return packet;
61 small_scpacket OSCMessages::initTreeMessage(){
62 small_scpacket packet;
63 packet.adds("/g_new");
64 packet.maketags(2);
65 packet.addtag(',');
66 packet.addtag('i');
67 packet.addi(1);
68 return packet;
71 small_scpacket OSCMessages::quitMessage(){
72 small_scpacket packet;
73 packet.adds("/quit");
74 return packet;
78 size_t OSCMessages::createSynthMessage(small_scpacket *packet, CFStringRef name){
79 packet->reset();
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");
86 packet->maketags(3);
87 packet->addtag(',');
88 packet->addtag('s');
89 packet->adds(buf);
90 packet->addtag('i');
91 packet->addi(kDefaultNodeId);
92 free (buf);
93 return messageSize;
96 small_scpacket OSCMessages::noteMessage(int64 oscTime, int note, int velocity){
97 small_scpacket packet;
98 packet.OpenBundle(oscTime);
100 packet.BeginMsg();
101 packet.adds("/n_set");
102 packet.maketags(4);
103 packet.addtag(',');
104 packet.addtag('i');
105 packet.addi(kDefaultNodeId);
106 packet.addtag('s');
107 packet.adds("/note");
108 packet.addtag('i');
109 packet.addi(note);
110 packet.EndMsg();
112 packet.BeginMsg();
113 packet.adds("/n_set");
114 packet.maketags(4);
115 packet.addtag(',');
116 packet.addtag('i');
117 packet.addi(kDefaultNodeId);
118 packet.addtag('s');
119 packet.adds("/velocity");
120 packet.addtag('i');
121 packet.addi(velocity);
122 packet.EndMsg();
124 packet.CloseBundle();
125 return packet;