annotate projects/heavy/hello-world/Heavy_bbb.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 /**
chris@160 3 * Copyright (c) 2014,2015 Enzien Audio, Ltd.
chris@160 4 *
chris@160 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
chris@160 6 * of this software and associated documentation files (the "Software"),
chris@160 7 * to deal in the Software without restriction, including without limitation
chris@160 8 * the rights to use, copy, modify, merge, publish, distribute, and/or
chris@160 9 * sublicense copies of the Software, strictly on a non-commercial basis,
chris@160 10 * and to permit persons to whom the Software is furnished to do so,
chris@160 11 * subject to the following conditions:
chris@160 12 *
chris@160 13 * The above copyright notice and this permission notice shall be included in
chris@160 14 * all copies or substantial portions of the Software.
chris@160 15 *
chris@160 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
chris@160 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
chris@160 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
chris@160 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
chris@160 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
chris@160 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
chris@160 22 * IN THE SOFTWARE.
chris@160 23 *
chris@160 24 * DO NOT MODIFY. THIS CODE IS MACHINE GENERATED BY THE SECTION6 HEAVY COMPILER.
chris@160 25 */
chris@160 26
chris@160 27 #ifdef __cplusplus
chris@160 28 extern "C" {
chris@160 29 #endif
chris@160 30
chris@160 31 #include "Utils.h"
chris@160 32
chris@160 33 #if !HV_MSVC
chris@160 34 #pragma mark - Heavy Table
chris@160 35 #endif
chris@160 36
chris@160 37 #ifndef _HEAVY_TABLE_H_
chris@160 38 #define _HEAVY_TABLE_H_
chris@160 39
chris@160 40 typedef struct HvTable HvTable;
chris@160 41
chris@160 42 /**
chris@160 43 * Resizes the table to the given length. Length must be positive.
chris@160 44 * Existing contents are copied to the new table. Remaining space is cleared.
chris@160 45 * The change in byte-size of the table is returned. A value of zero indicates error.
chris@160 46 */
chris@160 47 HV_EXPORT int hv_table_resize(HvTable *o, hv_uint32_t newLength);
chris@160 48
chris@160 49 /** Returns a pointer to the raw buffer backing this table. DO NOT free it. */
chris@160 50 HV_EXPORT float *hv_table_getBuffer(HvTable *o);
chris@160 51
chris@160 52 /** Returns the length of this table in samples. */
chris@160 53 HV_EXPORT int hv_table_getLength(HvTable *o);
chris@160 54
chris@160 55 #endif // _HEAVY_TABLE_H_
chris@160 56
chris@160 57
chris@160 58
chris@160 59 #if !HV_MSVC
chris@160 60 #pragma mark - Heavy Message
chris@160 61 #endif
chris@160 62
chris@160 63 #ifndef _HEAVY_MESSAGE_H_
chris@160 64 #define _HEAVY_MESSAGE_H_
chris@160 65
chris@160 66 HV_EXPORT typedef struct HvMessage HvMessage;
chris@160 67
chris@160 68 /** Returns the byte size of a HvMessage with a number of elements on the heap. */
chris@160 69 HV_EXPORT hv_size_t hv_msg_getByteSize(int numElements);
chris@160 70
chris@160 71 /** Create a HvMessage on the stack with a number of elements. This message MUST NOT be freed. */
chris@160 72 #define hv_msg_onStack(_n) ((HvMessage *) hv_alloca(hv_msg_getByteSize(_n)))
chris@160 73
chris@160 74 /** Initialise a message with the number of elements and a timestamp (in milliseconds). */
chris@160 75 HV_EXPORT void hv_msg_init(HvMessage *m, int numElements, double timestamp);
chris@160 76
chris@160 77 /** Returns the number of elements in this message. */
chris@160 78 HV_EXPORT int hv_msg_getNumElements(const HvMessage *const m);
chris@160 79
chris@160 80 /** Returns the time at which this message exists (in milliseconds). */
chris@160 81 HV_EXPORT hv_uint32_t hv_msg_getTimestamp(const HvMessage *const m);
chris@160 82
chris@160 83 /** Set the time at which this message should be executed (in milliseconds). */
chris@160 84 HV_EXPORT void hv_msg_setTimestamp(HvMessage *m, hv_uint32_t timestamp);
chris@160 85
chris@160 86 /** Returns true of the indexed element is a bang. False otherwise. Index is not bounds checked. */
chris@160 87 HV_EXPORT bool hv_msg_isBang(const HvMessage *const m, int i);
chris@160 88
chris@160 89 /** Sets the indexed element to a bang. Index is not bounds checked. */
chris@160 90 HV_EXPORT void hv_msg_setBang(HvMessage *m, int i);
chris@160 91
chris@160 92 /** Returns true of the indexed element is a float. False otherwise. Index is not bounds checked. */
chris@160 93 HV_EXPORT bool hv_msg_isFloat(const HvMessage *const m, int i);
chris@160 94
chris@160 95 /** Returns the indexed element as a float value. Index is not bounds checked. */
chris@160 96 HV_EXPORT float hv_msg_getFloat(const HvMessage *const m, int i);
chris@160 97
chris@160 98 /** Sets the indexed element to float value. Index is not bounds checked. */
chris@160 99 HV_EXPORT void hv_msg_setFloat(HvMessage *m, int i, float f);
chris@160 100
chris@160 101 /** Returns true of the indexed element is a symbol. False otherwise. Index is not bounds checked. */
chris@160 102 HV_EXPORT bool hv_msg_isSymbol(const HvMessage *const m, int i);
chris@160 103
chris@160 104 /** Returns the indexed element as a symbol value. Index is not bounds checked. */
chris@160 105 HV_EXPORT char *hv_msg_getSymbol(const HvMessage *const m, int i);
chris@160 106
chris@160 107 /** Returns true of the indexed element is a hash. False otherwise. Index is not bounds checked. */
chris@160 108 HV_EXPORT bool hv_msg_isHash(const HvMessage *const m, int i);
chris@160 109
chris@160 110 /** Returns the indexed element as a hash value. Index is not bounds checked. */
chris@160 111 HV_EXPORT unsigned int hv_msg_getHash(const HvMessage *const m, int i);
chris@160 112
chris@160 113 /** Sets the indexed element to symbol value. Index is not bounds checked. */
chris@160 114 HV_EXPORT void hv_msg_setSymbol(HvMessage *m, int i, const char *s);
chris@160 115
chris@160 116 /**
chris@160 117 * Returns true if the message has the given format, in number of elements and type. False otherwise.
chris@160 118 * Valid element types are:
chris@160 119 * 'b': bang
chris@160 120 * 'f': float
chris@160 121 * 's': symbol
chris@160 122 *
chris@160 123 * For example, a message with three floats would have a format of "fff". A single bang is "b".
chris@160 124 * A message with two symbols is "ss". These types can be mixed and matched in any way.
chris@160 125 */
chris@160 126 HV_EXPORT bool hv_msg_hasFormat(const HvMessage *const m, const char *fmt);
chris@160 127
chris@160 128 /**
chris@160 129 * Returns a basic string representation of the message.
chris@160 130 * The character array MUST be deallocated by the caller.
chris@160 131 */
chris@160 132 HV_EXPORT char *hv_msg_toString(const HvMessage *const m);
chris@160 133
chris@160 134 /** Copy a message onto the stack. The message persists. */
chris@160 135 HV_EXPORT HvMessage *hv_msg_copy(const HvMessage *const m);
chris@160 136
chris@160 137 /** Free a copied message. */
chris@160 138 HV_EXPORT void hv_msg_free(HvMessage *m);
chris@160 139
chris@160 140 #endif // _HEAVY_MESSAGE_H_
chris@160 141
chris@160 142
chris@160 143
chris@160 144 #if !HV_MSVC
chris@160 145 #pragma mark - Heavy Patch
chris@160 146 #endif
chris@160 147
chris@160 148 #ifndef _HEAVY_BBB_H_
chris@160 149 #define _HEAVY_BBB_H_
chris@160 150
chris@160 151 typedef struct Hv_bbb Hv_bbb;
chris@160 152
chris@160 153 /**
chris@160 154 * Creates a new patch instance.
chris@160 155 * Sample rate should be positive and in Hertz.
chris@160 156 */
chris@160 157 HV_EXPORT Hv_bbb *hv_bbb_new(double sampleRate);
chris@160 158
chris@160 159 /**
chris@160 160 * Creates a new patch instance.
chris@160 161 * Sample rate should be positive and in Hertz.
chris@160 162 * Pool size is in kilobytes, and determines the maximum amount of memory
chris@160 163 * allocated to messages at any time. By default this is 10.
chris@160 164 */
chris@160 165 HV_EXPORT Hv_bbb *hv_bbb_new_with_pool(double sampleRate, int poolKb);
chris@160 166
chris@160 167 /** Frees a patch instance. */
chris@160 168 HV_EXPORT void hv_bbb_free(Hv_bbb *c);
chris@160 169
chris@160 170 /** Processes one block of samples for a patch instance. The buffer format is an array of float channel arrays. */
chris@160 171 HV_EXPORT int hv_bbb_process(Hv_bbb *c, float **const inputBuffers, float **const outputBuffers, int n4);
chris@160 172
chris@160 173 /** Processes one block of samples for a patch instance. The buffer format is an uninterleaved float array of channels. */
chris@160 174 HV_EXPORT int hv_bbb_process_inline(Hv_bbb *c, float *const inputBuffers, float *const outputBuffers, int n4);
chris@160 175
chris@160 176 /** Processes one block of samples for a patch instance. The buffer format is an interleaved short array of channels. */
chris@160 177 HV_EXPORT int hv_bbb_process_inline_short(Hv_bbb *c, short *const inputBuffers, short *const outputBuffers, int n4);
chris@160 178 #endif // _HEAVY_BBB_H_
chris@160 179
chris@160 180
chris@160 181
chris@160 182 #if !HV_MSVC
chris@160 183 #pragma mark - Heavy Common
chris@160 184 #endif
chris@160 185
chris@160 186 #ifndef _HEAVY_COMMON_H_
chris@160 187 #define _HEAVY_COMMON_H_
chris@160 188
chris@160 189 typedef void Heavy;
chris@160 190
chris@160 191 /** Returns the sample rate with which this patch has been configured. */
chris@160 192 HV_EXPORT double hv_getSampleRate(Heavy *c);
chris@160 193
chris@160 194 /** Returns the number of input channels with which this patch has been configured. */
chris@160 195 HV_EXPORT int hv_getNumInputChannels(Heavy *c);
chris@160 196
chris@160 197 /** Returns the number of output channels with which this patch has been configured. */
chris@160 198 HV_EXPORT int hv_getNumOutputChannels(Heavy *c);
chris@160 199
chris@160 200 /** Set the print hook. The function is called whenever a message is sent to a print object. */
chris@160 201 HV_EXPORT void hv_setPrintHook(Heavy *c,
chris@160 202 void (*f)(double timestamp, const char *printName, const char *message, void *userData));
chris@160 203
chris@160 204 /**
chris@160 205 * Set the send hook. The function is called whenever a message is sent to any send object.
chris@160 206 * Messages returned by this function should NEVER be freed. If the message must persist, call
chris@160 207 * hv_msg_copy() first.
chris@160 208 */
chris@160 209 HV_EXPORT void hv_setSendHook(Heavy *c, void (*f)(double timestamp, const char *receiverName, const HvMessage *const m, void *userData));
chris@160 210
chris@160 211 HV_EXPORT void hv_vscheduleMessageForReceiver(
chris@160 212 Heavy *c, const char *receiverName, double delayMs, const char *format, ...);
chris@160 213
chris@160 214 HV_EXPORT void hv_scheduleMessageForReceiver(Heavy *c, const char *receiverName, double delayMs, HvMessage *m);
chris@160 215
chris@160 216 /** Cancels a previously scheduled message. */
chris@160 217 HV_EXPORT void hv_cancelMessage(Heavy *c, HvMessage *m);
chris@160 218
chris@160 219 /** Returns a table object given its name. NULL if no table with that name exists. */
chris@160 220 HV_EXPORT HvTable *hv_getTableForName(Heavy *c, const char *tableName);
chris@160 221
chris@160 222 /** Returns the current patch time in milliseconds. */
chris@160 223 HV_EXPORT double hv_getCurrentTime(Heavy *c);
chris@160 224
chris@160 225 /** Sets a user-definable value. This value is never manipulated by Heavy. */
chris@160 226 HV_EXPORT void hv_setUserData(Heavy *c, void *userData);
chris@160 227
chris@160 228 /** Returns the user-defined data. */
chris@160 229 HV_EXPORT void *hv_getUserData(Heavy *c);
chris@160 230
chris@160 231 /** Define the base path of the patch. Used as the root path to locate assets. */
chris@160 232 HV_EXPORT void hv_setBasePath(Heavy *c, const char *basePath);
chris@160 233
chris@160 234 /** Returns the read-only user-assigned name of this patch. */
chris@160 235 HV_EXPORT const char *hv_getName(Heavy *c);
chris@160 236
chris@160 237 #endif // _HEAVY_COMMON_H_
chris@160 238
chris@160 239 #ifdef __cplusplus
chris@160 240 } // extern "C"
chris@160 241 #endif