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