Skip to content

Instantly share code, notes, and snippets.

@diplojocus
Last active August 29, 2015 14:14
Show Gist options
  • Save diplojocus/5e1a9e0df1c09cfcc0dd to your computer and use it in GitHub Desktop.
Save diplojocus/5e1a9e0df1c09cfcc0dd to your computer and use it in GitHub Desktop.
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;
int blockSize = 256; // should be a multiple of 8
// sample buffers should be allocated on (ideally 32) byte boundaries
float **outBuffers = (float **) _mm_malloc(numOutputChannels * sizeof(float *), 32);
for (int i = 0; i < numOutputChannels; ++i) {
outBuffers[i] = (float *) _mm_malloc(blockSize * sizeof(float), 32);
}
// main processing loop
for (int i = 0; i < numIterations; ++i) {
hv_heavy_process(context, NULL, outBuffers, blockSize);
// do something with output here
}
hv_heavy_free(context);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment