Skip to content

Instantly share code, notes, and snippets.

@diplojocus
Last active August 29, 2015 14:14
Show Gist options
  • Save diplojocus/20603f4ed20586a2d0db to your computer and use it in GitHub Desktop.
Save diplojocus/20603f4ed20586a2d0db to your computer and use it in GitHub Desktop.
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");
hv_msg_setFloat(msg, 1, 0.5f);
// send a message to receiver '#param-one' to be processed straight away
double delayMs = 0.0;
hv_scheduleMessageForReceiver(context, "#param-one", delayMs, msg);
// messages can also be defined and scheduled inline as in the example below
// where "sf" is the message format (symbol float)
// hv_vscheduleMessageForReceiver(context, "#param-one", delayMs, "sf", "test-value", 0.5f);
hv_heavy_process_inline(context, NULL, NULL, 64);
hv_heavy_free(context);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment