sure: (i used calfs exclusively, so you should be able to run it as well)
#include <Bela.h>
#include <vector>
#include "Lv2Host.h"
#include <libraries/OnePole/OnePole.h>
#include <libraries/Scope/Scope.h>
Lv2Host gLv2Host;
//Scope scope;
int gAudioFramesPerAnalogFrame;
int gLedPin = 0;
float gUpdateInterval = 0.05;
void Bela_userSettings(BelaInitSettings *settings)
{
settings->uniformSampleRate = 1;
settings->interleave = 0;
settings->analogOutputsPersist = 0;
}
bool setup(BelaContext* context, void* userData)
{
// these should be initialized by Bela_userSettings above
if((context->flags & BELA_FLAG_INTERLEAVED) || context->audioSampleRate != context->analogSampleRate)
{
fprintf(stderr, "Using Lv2Host requires non-interleaved buffers and uniform sample rate\n");
return false;
}
if(!gLv2Host.setup(context->audioSampleRate, context->audioFrames,
context->audioInChannels, context->audioOutChannels))
{
fprintf(stderr, "Unable to create Lv2 host\n");
return false;
}
std::vector<std::string> lv2Chain;
lv2Chain.emplace_back("http://calf.sourceforge.net/plugins/MonoCompressor");
lv2Chain.emplace_back("http://calf.sourceforge.net/plugins/VintageDelay");
lv2Chain.emplace_back("http://calf.sourceforge.net/plugins/Reverb");
for(auto &name : lv2Chain)
{
gLv2Host.add(name);
}
if(0 == gLv2Host.count())
{
fprintf(stderr, "No plugins were successfully instantiated\n");
return false;
}
if(context->analogFrames)
gAudioFramesPerAnalogFrame = context->audioFrames / context->analogFrames;
gLv2Host.setPort(1, 4, 40); //delay time
gLv2Host.setPort(1,9,0.9); //delay feedback
//comment the next 5 lines to have the normal chain working
//disconnect from reverb
gLv2Host.disconnect(2,0);
gLv2Host.disconnect(2,1);
gLv2Host.bypass(1,1);
// connect compressor to reverb (or try to set to -1 or 3 to bypass whole chain)
gLv2Host.connect(0,0,2,0);
gLv2Host.connect(0,1,2,1);
return true;
}
void render(BelaContext* context, void* userData)
{
// set inputs and outputs
const float* inputs[context->audioInChannels];
float* outputs[context->audioOutChannels];
for(unsigned int ch = 0; ch < context->audioInChannels; ++ch)
inputs[ch] = (float*)&context->audioIn[context->audioFrames * ch];
for(unsigned int ch = 0; ch < context->audioOutChannels; ++ch)
outputs[ch] = &context->audioOut[context->audioFrames * ch];
// do the actual processing on the buffers specified above
gLv2Host.render(context->audioFrames, inputs, outputs);
// Log input, output, compressor's threshold and compressor's gain reduction into scope
}
void cleanup(BelaContext* context, void* userData) {
}