Skip to content

Instantly share code, notes, and snippets.

CC = clang
CXX = clang++
MKDIR = mkdir -p
SRC_DIR = ../source
WWISE_SDK_DIR = /home/osiris/Desktop/Wwise/SDK/include
PATCH_NAME = sine
OUT_DIR = ../build/unix
BASEFLAGS = -I$(WWISE_SDK_DIR) -I$(SRC_DIR) -I$(SRC_DIR)/include -I$(SRC_DIR)/heavy -DNDEBUG -msse4.1 -O3 -ffast-math -std=c11 -fPIC -Werror -Wno-unused-function -Wno-\#warnings
CFLAGS = $(BASEFLAGS) -std=c11
CXXFLAGS = $(BASEFLAGS) -std=c++11 -Wno-deprecated-writable-strings -fno-exceptions -fno-rtti
@diplojocus
diplojocus / heavy_api_tables.c
Created February 2, 2015 00:04
Table specific Heavy API methods
/**
* Resizes the table to the given length. Length must be positive.
* Existing contents are copied to the new table. Remaining space is cleared.
*/
void hv_table_resize(PdTable *o, hv_uint32_t newLength);
/** Returns a pointer to the raw buffer backing this table. DO NOT free it. */
float *hv_table_getBuffer(PdTable *o);
/** Returns the length of this table in samples. */
@diplojocus
diplojocus / heavy_api_messages.c
Last active August 29, 2015 14:14
Message specific Heavy API methods
/** Returns the byte size of a HvMessage with a number of elements on the heap. */
hv_size_t hv_msg_getByteSize(int numElements);
/** Create a HvMessage on the stack with a number of elements. This message does MUST NOT be freed. */
HvMessage *hv_msg_onStack(hv_uint32_t numElements) {
return (HvMessage *) hv_alloca(hv_msg_getByteSize(numElements)); // this will not work until Utils.h is included
}
/** Initialise a message with the number of elements and a timestamp (in milliseconds). */
void hv_msg_init(HvMessage *m, int numElements, double timestamp);
@diplojocus
diplojocus / heavy_api_common.c
Created February 1, 2015 23:59
Commons Heavy API methods
/** Returns the sample rate with which this patch has been configured. */
double hv_getSampleRate(Heavy *c);
/** Returns the number of input channels with which this patch has been configured. */
int hv_getNumInputChannels(Heavy *c);
/** Returns the number of output channels with which this patch has been configured. */
int hv_getNumOutputChannels(Heavy *c);
/** Set the print hook. The function is called whenever a message is sent to a print object. */
@diplojocus
diplojocus / heavy_api_patch.c
Last active August 29, 2015 14:14
Patch specific Heavy API methods
/**
* Creates a new patch instance.
* Sample rate should be positive and in Hertz.
*/
Hv_heavy *hv_heavy_new(double sampleRate);
/** Frees a patch instance. */
void hv_heavy_free(Hv_heavy *c);
/** Processes one block of samples for a patch instance. The buffer format is an array of arrays. */
@diplojocus
diplojocus / debug.c
Last active August 29, 2015 14:14
Heavy - Print Debugging
#include <stdio.h>
#include "Heavy_heavy.h"
void printHook(double timestampSecs, const char *printLabel, const char *msgString, void *userData) {
printf("[@ %.3f] %s: %s\n", timestampSecs, printLabel, msgString);
}
int main(int argc, const char *argv[]) {
Hv_heavy *context = hv_heavy_new(0, 0, 44100.0);
@diplojocus
diplojocus / sending_messages.c
Last active August 29, 2015 14:14
Heavy - Sending Messages
#include "Heavy_heavy.h"
int main(int argc, const char *argv[]) {
Hv_heavy *context = hv_heavy_new(44100.0);
// create a message with the contents 'test-value 0.5f'
int numElements = 2;
HvMessage *msg = (HvMessage *) hv_alloca(hv_msg_getByteSize(numElements));
hv_msg_init(msg, numElements, 0.0);
hv_msg_setSymbol(msg, 0, "test-value");
@diplojocus
diplojocus / process.c
Last active August 29, 2015 14:14
Heavy - Processing Buffers
#include <mm_malloc.h>
#include "Heavy_heavy.h"
int main(int argc, const char *argv[]) {
double sampleRate = 44100.0;
Hv_heavy *context = hv_heavy_new(sampleRate);
int numOutputChannels = hv_getNumOutputChannels(context);
int numIterations = 100;
@diplojocus
diplojocus / inline_process.c
Last active August 29, 2015 14:14
Heavy - Processing Inline Buffers
#include <mm_malloc.h>
#include "Heavy_heavy.h"
int main(int argc, const char *argv[]) {
double sampleRate = 44100.0;
Hv_heavy *context = hv_heavy_new(sampleRate);
int numOutputChannels = hv_getNumOutputChannels(context);
int numIterations = 100;
@diplojocus
diplojocus / basic_setup.c
Last active August 29, 2015 14:14
Heavy - Getting Started
#include "Heavy_heavy.h"
int main(int argc, const char *argv[]) {
double sampleRate = 44100.0;
Hv_heavy *context = hv_heavy_new(sampleRate);
int numInputChannels = hv_getNumInputChannels(context);
int numOutputChannels = hv_getNumOutputChannels(context);