-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathosc_atom_array_s.c
More file actions
121 lines (110 loc) · 3.7 KB
/
osc_atom_array_s.c
File metadata and controls
121 lines (110 loc) · 3.7 KB
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
/*
Written by John MacCallum, The Center for New Music and Audio Technologies,
University of California, Berkeley. Copyright (c) 2009-ll, 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
#include "osc.h"
#include "osc_mem.h"
#include "osc_byteorder.h"
#include "osc_atom_s.h"
#include "osc_atom_s.r" // need ths to get the size of the struct
#include "osc_atom_array_s.h"
t_osc_array *osc_atom_array_s_alloc(long len){
return osc_array_allocWithSize(len, sizeof(t_osc_atom_s));
}
t_osc_err osc_atom_array_s_getDoubleArray(t_osc_atom_ar_s *array, double **out){
long len = osc_atom_array_s_getLen(array);
if(!(*out)){
*out = osc_mem_alloc(sizeof(double) * len);
}
int i;
for(i = 0; i < len; i++){
(*out)[i] = osc_atom_s_getDouble(osc_atom_array_s_get(array, i));
}
return OSC_ERR_NONE;
}
t_osc_err osc_atom_array_s_getFloatArray(t_osc_atom_ar_s *array, float **out){
long len = osc_atom_array_s_getLen(array);
if(!(*out)){
*out = osc_mem_alloc(sizeof(float) * len);
}
int i;
for(i = 0; i < len; i++){
(*out)[i] = osc_atom_s_getFloat(osc_atom_array_s_get(array, i));
}
return OSC_ERR_NONE;
}
t_osc_err osc_atom_array_s_getInt32Array(t_osc_atom_ar_s *array, int32_t **out){
long len = osc_atom_array_s_getLen(array);
if(!(*out)){
*out = osc_mem_alloc(sizeof(int32_t) * len);
}
int i;
for(i = 0; i < len; i++){
(*out)[i] = osc_atom_s_getInt32(osc_atom_array_s_get(array, i));
}
return OSC_ERR_NONE;
}
t_osc_err osc_atom_array_s_getInt64Array(t_osc_atom_ar_s *array, int64_t **out){
long len = osc_atom_array_s_getLen(array);
if(!(*out)){
*out = osc_mem_alloc(sizeof(int64_t) * len);
}
int i;
for(i = 0; i < len; i++){
(*out)[i] = osc_atom_s_getInt64(osc_atom_array_s_get(array, i));
}
return OSC_ERR_NONE;
}
t_osc_err osc_atom_array_s_getUInt32Array(t_osc_atom_ar_s *array, uint32_t **out){
long len = osc_atom_array_s_getLen(array);
if(!(*out)){
*out = osc_mem_alloc(sizeof(uint32_t) * len);
}
int i;
for(i = 0; i < len; i++){
(*out)[i] = osc_atom_s_getUInt32(osc_atom_array_s_get(array, i));
}
return OSC_ERR_NONE;
}
t_osc_err osc_atom_array_s_getUInt64Array(t_osc_atom_ar_s *array, uint64_t **out){
long len = osc_atom_array_s_getLen(array);
if(!(*out)){
*out = osc_mem_alloc(sizeof(uint64_t) * len);
}
int i;
for(i = 0; i < len; i++){
(*out)[i] = osc_atom_s_getUInt64(osc_atom_array_s_get(array, i));
}
return OSC_ERR_NONE;
}
t_osc_err osc_atom_array_s_getBoolArray(t_osc_atom_ar_s *array, char **out){
long len = osc_atom_array_s_getLen(array);
if(!(*out)){
*out = osc_mem_alloc(sizeof(char) * len);
}
int i;
for(i = 0; i < len; i++){
(*out)[i] = osc_atom_s_getBool(osc_atom_array_s_get(array, i));
}
return OSC_ERR_NONE;
}