chris@162: chris@162: /** chris@162: * Copyright (c) 2014,2015 Enzien Audio, Ltd. chris@162: * chris@162: * Permission is hereby granted, free of charge, to any person obtaining a copy chris@162: * of this software and associated documentation files (the "Software"), chris@162: * to deal in the Software without restriction, including without limitation chris@162: * the rights to use, copy, modify, merge, publish, distribute, and/or chris@162: * sublicense copies of the Software, strictly on a non-commercial basis, chris@162: * and to permit persons to whom the Software is furnished to do so, chris@162: * subject to the following conditions: chris@162: * chris@162: * The above copyright notice and this permission notice shall be included in chris@162: * all copies or substantial portions of the Software. chris@162: * chris@162: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR chris@162: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, chris@162: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE chris@162: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER chris@162: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING chris@162: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS chris@162: * IN THE SOFTWARE. chris@162: * chris@162: * DO NOT MODIFY. THIS CODE IS MACHINE GENERATED BY THE SECTION6 HEAVY COMPILER. chris@162: */ chris@162: chris@162: #ifdef __cplusplus chris@162: extern "C" { chris@162: #endif chris@162: chris@162: #include "Utils.h" chris@162: chris@162: #if !HV_MSVC chris@162: #pragma mark - Heavy Table chris@162: #endif chris@162: chris@162: #ifndef _HEAVY_TABLE_H_ chris@162: #define _HEAVY_TABLE_H_ chris@162: chris@162: typedef struct HvTable HvTable; chris@162: chris@162: /** chris@162: * Resizes the table to the given length. Length must be positive. chris@162: * Existing contents are copied to the new table. Remaining space is cleared. chris@162: * The change in byte-size of the table is returned. A value of zero indicates error. chris@162: */ chris@162: HV_EXPORT int hv_table_resize(HvTable *o, hv_uint32_t newLength); chris@162: chris@162: /** Returns a pointer to the raw buffer backing this table. DO NOT free it. */ chris@162: HV_EXPORT float *hv_table_getBuffer(HvTable *o); chris@162: chris@162: /** Returns the length of this table in samples. */ chris@162: HV_EXPORT int hv_table_getLength(HvTable *o); chris@162: chris@162: #endif // _HEAVY_TABLE_H_ chris@162: chris@162: chris@162: chris@162: #if !HV_MSVC chris@162: #pragma mark - Heavy Message chris@162: #endif chris@162: chris@162: #ifndef _HEAVY_MESSAGE_H_ chris@162: #define _HEAVY_MESSAGE_H_ chris@162: chris@162: HV_EXPORT typedef struct HvMessage HvMessage; chris@162: chris@162: /** Returns the byte size of a HvMessage with a number of elements on the heap. */ chris@162: HV_EXPORT hv_size_t hv_msg_getByteSize(int numElements); chris@162: chris@162: /** Create a HvMessage on the stack with a number of elements. This message MUST NOT be freed. */ chris@162: #define hv_msg_onStack(_n) ((HvMessage *) hv_alloca(hv_msg_getByteSize(_n))) chris@162: chris@162: /** Initialise a message with the number of elements and a timestamp (in milliseconds). */ chris@162: HV_EXPORT void hv_msg_init(HvMessage *m, int numElements, double timestamp); chris@162: chris@162: /** Returns the number of elements in this message. */ chris@162: HV_EXPORT int hv_msg_getNumElements(const HvMessage *const m); chris@162: chris@162: /** Returns the time at which this message exists (in milliseconds). */ chris@162: HV_EXPORT hv_uint32_t hv_msg_getTimestamp(const HvMessage *const m); chris@162: chris@162: /** Set the time at which this message should be executed (in milliseconds). */ chris@162: HV_EXPORT void hv_msg_setTimestamp(HvMessage *m, hv_uint32_t timestamp); chris@162: chris@162: /** Returns true of the indexed element is a bang. False otherwise. Index is not bounds checked. */ chris@162: HV_EXPORT bool hv_msg_isBang(const HvMessage *const m, int i); chris@162: chris@162: /** Sets the indexed element to a bang. Index is not bounds checked. */ chris@162: HV_EXPORT void hv_msg_setBang(HvMessage *m, int i); chris@162: chris@162: /** Returns true of the indexed element is a float. False otherwise. Index is not bounds checked. */ chris@162: HV_EXPORT bool hv_msg_isFloat(const HvMessage *const m, int i); chris@162: chris@162: /** Returns the indexed element as a float value. Index is not bounds checked. */ chris@162: HV_EXPORT float hv_msg_getFloat(const HvMessage *const m, int i); chris@162: chris@162: /** Sets the indexed element to float value. Index is not bounds checked. */ chris@162: HV_EXPORT void hv_msg_setFloat(HvMessage *m, int i, float f); chris@162: chris@162: /** Returns true of the indexed element is a symbol. False otherwise. Index is not bounds checked. */ chris@162: HV_EXPORT bool hv_msg_isSymbol(const HvMessage *const m, int i); chris@162: chris@162: /** Returns the indexed element as a symbol value. Index is not bounds checked. */ chris@162: HV_EXPORT char *hv_msg_getSymbol(const HvMessage *const m, int i); chris@162: chris@162: /** Returns true of the indexed element is a hash. False otherwise. Index is not bounds checked. */ chris@162: HV_EXPORT bool hv_msg_isHash(const HvMessage *const m, int i); chris@162: chris@162: /** Returns the indexed element as a hash value. Index is not bounds checked. */ chris@162: HV_EXPORT unsigned int hv_msg_getHash(const HvMessage *const m, int i); chris@162: chris@162: /** Sets the indexed element to symbol value. Index is not bounds checked. */ chris@162: HV_EXPORT void hv_msg_setSymbol(HvMessage *m, int i, const char *s); chris@162: chris@162: /** chris@162: * Returns true if the message has the given format, in number of elements and type. False otherwise. chris@162: * Valid element types are: chris@162: * 'b': bang chris@162: * 'f': float chris@162: * 's': symbol chris@162: * chris@162: * For example, a message with three floats would have a format of "fff". A single bang is "b". chris@162: * A message with two symbols is "ss". These types can be mixed and matched in any way. chris@162: */ chris@162: HV_EXPORT bool hv_msg_hasFormat(const HvMessage *const m, const char *fmt); chris@162: chris@162: /** chris@162: * Returns a basic string representation of the message. chris@162: * The character array MUST be deallocated by the caller. chris@162: */ chris@162: HV_EXPORT char *hv_msg_toString(const HvMessage *const m); chris@162: chris@162: /** Copy a message onto the stack. The message persists. */ chris@162: HV_EXPORT HvMessage *hv_msg_copy(const HvMessage *const m); chris@162: chris@162: /** Free a copied message. */ chris@162: HV_EXPORT void hv_msg_free(HvMessage *m); chris@162: chris@162: #endif // _HEAVY_MESSAGE_H_ chris@162: chris@162: chris@162: chris@162: #if !HV_MSVC chris@162: #pragma mark - Heavy Patch chris@162: #endif chris@162: chris@162: #ifndef _HEAVY_BBB_H_ chris@162: #define _HEAVY_BBB_H_ chris@162: chris@162: typedef struct Hv_bbb Hv_bbb; chris@162: chris@162: /** chris@162: * Creates a new patch instance. chris@162: * Sample rate should be positive and in Hertz. chris@162: */ chris@162: HV_EXPORT Hv_bbb *hv_bbb_new(double sampleRate); chris@162: chris@162: /** chris@162: * Creates a new patch instance. chris@162: * Sample rate should be positive and in Hertz. chris@162: * Pool size is in kilobytes, and determines the maximum amount of memory chris@162: * allocated to messages at any time. By default this is 10. chris@162: */ chris@162: HV_EXPORT Hv_bbb *hv_bbb_new_with_pool(double sampleRate, int poolKb); chris@162: chris@162: /** Frees a patch instance. */ chris@162: HV_EXPORT void hv_bbb_free(Hv_bbb *c); chris@162: chris@162: /** Processes one block of samples for a patch instance. The buffer format is an array of float channel arrays. */ chris@162: HV_EXPORT int hv_bbb_process(Hv_bbb *c, float **const inputBuffers, float **const outputBuffers, int n4); chris@162: chris@162: /** Processes one block of samples for a patch instance. The buffer format is an uninterleaved float array of channels. */ chris@162: HV_EXPORT int hv_bbb_process_inline(Hv_bbb *c, float *const inputBuffers, float *const outputBuffers, int n4); chris@162: chris@162: /** Processes one block of samples for a patch instance. The buffer format is an interleaved short array of channels. */ chris@162: HV_EXPORT int hv_bbb_process_inline_short(Hv_bbb *c, short *const inputBuffers, short *const outputBuffers, int n4); chris@162: #endif // _HEAVY_BBB_H_ chris@162: chris@162: chris@162: chris@162: #if !HV_MSVC chris@162: #pragma mark - Heavy Common chris@162: #endif chris@162: chris@162: #ifndef _HEAVY_COMMON_H_ chris@162: #define _HEAVY_COMMON_H_ chris@162: chris@162: typedef void Heavy; chris@162: chris@162: /** Returns the sample rate with which this patch has been configured. */ chris@162: HV_EXPORT double hv_getSampleRate(Heavy *c); chris@162: chris@162: /** Returns the number of input channels with which this patch has been configured. */ chris@162: HV_EXPORT int hv_getNumInputChannels(Heavy *c); chris@162: chris@162: /** Returns the number of output channels with which this patch has been configured. */ chris@162: HV_EXPORT int hv_getNumOutputChannels(Heavy *c); chris@162: chris@162: /** Set the print hook. The function is called whenever a message is sent to a print object. */ chris@162: HV_EXPORT void hv_setPrintHook(Heavy *c, chris@162: void (*f)(double timestamp, const char *printName, const char *message, void *userData)); chris@162: chris@162: /** chris@162: * Set the send hook. The function is called whenever a message is sent to any send object. chris@162: * Messages returned by this function should NEVER be freed. If the message must persist, call chris@162: * hv_msg_copy() first. chris@162: */ chris@162: HV_EXPORT void hv_setSendHook(Heavy *c, void (*f)(double timestamp, const char *receiverName, const HvMessage *const m, void *userData)); chris@162: chris@162: HV_EXPORT void hv_vscheduleMessageForReceiver( chris@162: Heavy *c, const char *receiverName, double delayMs, const char *format, ...); chris@162: chris@162: HV_EXPORT void hv_scheduleMessageForReceiver(Heavy *c, const char *receiverName, double delayMs, HvMessage *m); chris@162: chris@162: /** Cancels a previously scheduled message. */ chris@162: HV_EXPORT void hv_cancelMessage(Heavy *c, HvMessage *m); chris@162: chris@162: /** Returns a table object given its name. NULL if no table with that name exists. */ chris@162: HV_EXPORT HvTable *hv_getTableForName(Heavy *c, const char *tableName); chris@162: chris@162: /** Returns the current patch time in milliseconds. */ chris@162: HV_EXPORT double hv_getCurrentTime(Heavy *c); chris@162: chris@162: /** Sets a user-definable value. This value is never manipulated by Heavy. */ chris@162: HV_EXPORT void hv_setUserData(Heavy *c, void *userData); chris@162: chris@162: /** Returns the user-defined data. */ chris@162: HV_EXPORT void *hv_getUserData(Heavy *c); chris@162: chris@162: /** Define the base path of the patch. Used as the root path to locate assets. */ chris@162: HV_EXPORT void hv_setBasePath(Heavy *c, const char *basePath); chris@162: chris@162: /** Returns the read-only user-assigned name of this patch. */ chris@162: HV_EXPORT const char *hv_getName(Heavy *c); chris@162: chris@162: #endif // _HEAVY_COMMON_H_ chris@162: chris@162: #ifdef __cplusplus chris@162: } // extern "C" chris@162: #endif