here is the code i used :
#include <Bela.h>
#include <cmath>
float gFrequency = 440.0;
float gPhase;
float gFrequency2 = 660.0;
float gPhase2;
float gInverseSampleRate;
bool setup(BelaContext *context, void *userData)
{
gInverseSampleRate = 1.0 / context->audioSampleRate;
gPhase = 0.0;
return true;
}
void render(BelaContext *context, void *userData)
{
for(unsigned int n = 0; n < context->audioFrames; n++) {
float out[2]= {0};
out[0]= 0.8f * sinf(gPhase);
gPhase += 2.0f * (float)M_PI * gFrequency * gInverseSampleRate;
out[1] = 0.8f * sinf(gPhase2);
gPhase2 += 2.0f * (float)M_PI * gFrequency2 * gInverseSampleRate;
if(gPhase > M_PI)
gPhase -= 2.0f * (float)M_PI;
for(unsigned int channel = 0; channel < context->audioOutChannels; channel++) {
audioWrite(context, n, channel, out[channel]);
}
}
}
void cleanup(BelaContext *context, void *userData)
{
}