Hi!
I'm new to Bela, and I'm trying to understand how to implement Auxiliary Tasks.
I'm building a synth which communicates with an arduino via a custom 8-bit parallel bus from the GPIO.. The arduino will then control some analog filters over SPI.
At present I have the audio out and the GPIO control all running from render() - and I need to add MIDI parsing via the serial. I'm aware that I need to create an auxiliary task to run some of the elements in a separate thread.
I tried to run the following code as a test.. However, the sensorLoop function runs, even after I stop the program, and even after I try to kill the aux processes in cleanup()
Could you help me get my auxiliary processes under control?
int gShouldStop = 0;
void sensorLoop(void* arg)
{
while(!gShouldStop)
{
rt_printf("test\n");
usleep(100000);
}
}
bool setup(BelaContext* context, void* userData)
{
// paste here the code from `setup()` in `MasterTest.cpp`
//
Bela_scheduleAuxiliaryTask(Bela_createAuxiliaryTask(sensorLoop, 50, "sensorLoop", NULL));
return true;
}
void render(BelaContext *context, void *userData)
{
}
void cleanup(BelaContext *context, void *userData)
{
Bela_stopAllAuxiliaryTasks();
Bela_deleteAllAuxiliaryTasks();
}
[\CODE]