-
Notifications
You must be signed in to change notification settings - Fork 3
/
omax_doc.c
148 lines (131 loc) · 4.28 KB
/
omax_doc.c
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
Written by John MacCallum, The Center for New Music and Audio Technologies,
University of California, Berkeley. Copyright (c) 2010-12, The Regents of
the University of California (Regents).
Permission to use, copy, modify, distribute, and distribute modified versions
of this software and its documentation without fee and without a signed
licensing agreement, is hereby granted, provided that the above copyright
notice, this paragraph and the following two paragraphs appear in all copies,
modifications, and distributions.
IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
/** \file omax_doc.c
\author John MacCallum
*/
#if defined(__linux__)
#else
#ifndef WIN_VERSION
// #include <Carbon/Carbon.h>
#include <CoreServices/CoreServices.h>
#endif
#endif
#include <inttypes.h>
#include "omax_doc.h"
#include "omax_util.h"
#include "osc.h"
#include "osc_mem.h"
#include "osc_bundle_u.h"
#include "osc_message_u.h"
void _omax_doc_outletDoc(void *outlet,
char *name,
char *short_desc,
char *long_desc,
int ninlets,
char **inlets_desc,
int noutlets,
char **outlets_desc,
int num_see_also_refs,
char **see_also)
{
t_osc_bndl_u *bndl = osc_bundle_u_alloc();
t_osc_msg_u *msg_name = osc_message_u_alloc();
osc_message_u_setAddress(msg_name, "/doc/name");
osc_message_u_appendString(msg_name, name);
osc_bundle_u_addMsg(bndl, msg_name);
t_osc_msg_u *msg_short_desc = osc_message_u_alloc();
osc_message_u_setAddress(msg_short_desc, "/doc/desc/short");
osc_message_u_appendString(msg_short_desc, short_desc);
osc_bundle_u_addMsg(bndl, msg_short_desc);
t_osc_msg_u *msg_long_desc = osc_message_u_alloc();
osc_message_u_setAddress(msg_long_desc, "/doc/desc/long");
osc_message_u_appendString(msg_long_desc, long_desc);
osc_bundle_u_addMsg(bndl, msg_long_desc);
t_osc_msg_u *msg_ninlets = osc_message_u_alloc();
osc_message_u_setAddress(msg_ninlets, "/doc/ninlets");
osc_message_u_appendInt32(msg_ninlets, ninlets);
osc_bundle_u_addMsg(bndl, msg_ninlets);
t_osc_msg_u *msg_noutlets = osc_message_u_alloc();
osc_message_u_setAddress(msg_noutlets, "/doc/noutlets");
osc_message_u_appendInt32(msg_noutlets, noutlets);
osc_bundle_u_addMsg(bndl, msg_noutlets);
int i;
for(i = 0; i < ninlets; i++){
if(inlets_desc[i]){
t_osc_msg_u *m = osc_message_u_alloc();
char buf[64];
sprintf(buf, "/doc/desc/inlet/%d", i + 1);
osc_message_u_setAddress(m, buf);
osc_message_u_appendString(m, inlets_desc[i]);
osc_bundle_u_addMsg(bndl, m);
}
}
for(i = 0; i < noutlets; i++){
if(outlets_desc[i]){
t_osc_msg_u *m = osc_message_u_alloc();
char buf[64];
sprintf(buf, "/doc/desc/outlet/%d", i + 1);
osc_message_u_setAddress(m, buf);
osc_message_u_appendString(m, outlets_desc[i]);
osc_bundle_u_addMsg(bndl, m);
}
}
t_osc_msg_u *msg_seealso = osc_message_u_alloc();
osc_message_u_setAddress(msg_seealso, "/doc/seealso");
for(i = 0; i < num_see_also_refs; i++){
osc_message_u_appendString(msg_seealso, see_also[i]);
}
osc_bundle_u_addMsg(bndl, msg_seealso);
//long len = 0;
//char *bndl_s = NULL;
t_osc_bndl_s *bs = osc_bundle_u_serialize(bndl);
if(bs){
omax_util_outletOSC(outlet, osc_bundle_s_getLen(bs), osc_bundle_s_getPtr(bs));
osc_bundle_s_deepFree(bs);
}
if(bndl){
osc_bundle_u_free(bndl);
}
}
#ifndef OMAX_PD_VERSION
void _omax_doc_assist(long io,
long num,
char *buf,
int ninlets,
char **inlet_assist_strings,
int noutlets,
char **outlet_assist_strings)
{
switch(io){
case ASSIST_INLET:
if(ninlets < num){
return;
}
sprintf(buf, "%s", inlet_assist_strings[num]);
break;
case ASSIST_OUTLET:
if(noutlets < num){
return;
}
sprintf(buf, "%s", outlet_assist_strings[num]);
break;
}
}
#endif