Mercurial > hg > beaglert
comparison projects/heavy/hello-world/HvTable.h @ 160:5bcf04234f80 heavy-updated
- added -std=c99 to Makefile for user-supplied C files (required for heavy files)
- changed heavy core render.cpp file to use latest API and removed all redundant functions (e.g. foleyDesigner/touchkey stuff)
- use build_pd.sh to compile and run pd files (-h for usage instructions)
author | chnrx <chris.heinrichs@gmail.com> |
---|---|
date | Thu, 05 Nov 2015 18:58:26 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
159:1e7db6610600 | 160:5bcf04234f80 |
---|---|
1 /** | |
2 * Copyright (c) 2014, 2015, Enzien Audio Ltd. | |
3 * | |
4 * Permission to use, copy, modify, and/or distribute this software for any | |
5 * purpose with or without fee is hereby granted, provided that the above | |
6 * copyright notice and this permission notice appear in all copies. | |
7 * | |
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | |
13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |
14 * PERFORMANCE OF THIS SOFTWARE. | |
15 */ | |
16 | |
17 #ifndef _HEAVY_TABLE_H_ | |
18 #define _HEAVY_TABLE_H_ | |
19 | |
20 #include "HvBase.h" | |
21 #include "HvMessage.h" | |
22 #include "Utils.h" | |
23 | |
24 typedef struct HvTable { | |
25 float *buffer; | |
26 // the number of values that the table is requested to have | |
27 hv_uint32_t length; | |
28 | |
29 // the number of usable values that the table actually has | |
30 // this is always an even multiple of HV_N_SIMD | |
31 hv_uint32_t size; | |
32 | |
33 // Note that the true size of the table is (size + HV_N_SIMD), | |
34 // with the trailing values used by the system, e.g. to create a circular | |
35 // buffer | |
36 hv_uint32_t allocated; | |
37 | |
38 hv_uint32_t head; // the most recently written point | |
39 } HvTable; | |
40 | |
41 hv_size_t hTable_init(HvTable *o, int length); | |
42 | |
43 hv_size_t hTable_initWithData(HvTable *o, int length, const float *const data); | |
44 | |
45 hv_size_t hTable_initWithFinalData(HvTable *o, int length, float *data); | |
46 | |
47 void hTable_free(HvTable *o); | |
48 | |
49 int hTable_resize(HvTable *o, hv_uint32_t newLength); | |
50 | |
51 void hTable_onMessage(HvBase *_c, HvTable *o, int letIn, const HvMessage *const m, | |
52 void (*sendMessage)(HvBase *, int, const HvMessage *const)); | |
53 | |
54 static inline float *hTable_getBuffer(HvTable *o) { | |
55 return o->buffer; | |
56 } | |
57 | |
58 // the user-requested length of the table (number of floats) | |
59 static inline hv_uint32_t hTable_getLength(HvTable *o) { | |
60 return o->length; | |
61 } | |
62 | |
63 // the usable length of the table (an even multiple of HV_N_SIMD) | |
64 static inline hv_uint32_t hTable_getSize(HvTable *o) { | |
65 return o->size; | |
66 } | |
67 | |
68 // the number of floats allocated to this table (usually size + HV_N_SIMD) | |
69 static inline hv_uint32_t hTable_getAllocated(HvTable *o) { | |
70 return o->allocated; | |
71 } | |
72 | |
73 static inline hv_uint32_t hTable_getHead(HvTable *o) { | |
74 return o->head; | |
75 } | |
76 | |
77 static inline void hTable_setHead(HvTable *o, hv_uint32_t head) { | |
78 o->head = head; | |
79 } | |
80 | |
81 #endif // _HEAVY_TABLE_H_ |