Skip to content

Instantly share code, notes, and snippets.

@dromer
Last active June 27, 2025 15:18
Show Gist options
  • Save dromer/e29e1c39ce73b4787bd4957d3755593a to your computer and use it in GitHub Desktop.
Save dromer/e29e1c39ce73b4787bd4957d3755593a to your computer and use it in GitHub Desktop.
LDSP Heavy wrapper
#include "LDSP.h"
#include "Heavy_noise.h"
HeavyContextInterface *gHeavyContext;
float *gHvInputBuffers = NULL;
unsigned int gHvInputChannels = 0;
bool setup(LDSPcontext *context, void *userData)
{
gHeavyContext = hv_noise_new_with_options(context->audioSampleRate, 10, 2, 0);
gHvInputChannels = hv_getNumInputChannels(gHeavyContext);
if(gHvInputChannels != 0) {
gHvInputBuffers = (float *)calloc(gHvInputChannels * context->audioFrames,sizeof(float));
}
return true;
}
void render(LDSPcontext *context, void *userData)
{
memcpy(gHvInputBuffers, context->audioIn, gHvInputChannels * context->audioFrames * sizeof(float));
hv_processInline(gHeavyContext, gHvInputBuffers, context->audioOut, context->audioFrames);
}
void cleanup(LDSPcontext *context, void *userData)
{
hv_noise_free(gHeavyContext);
free(gHvInputBuffers);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment