Please paste your code and not a screenshot, so that we can see everything that is happening and browse and search through it .
I shall assume that rece_sw
and trans_sw
are objects of the WriteFile
class. If that is the case, then you should call log()
from within the audio thread, and not from another thread as you are doing now. So you should call writeReceSoundwave()
and writeTransSoundwave()
from within render()
.
See if that fixes it.
If that does not fix it, then I suggest you use a different approach to debugging: simply log the four input channels to the Bela built-in oscilloscope, open the scope window and monitor the input signals. Then generate some signals so that the microphones can pick it up: does it come up on the correct channel?
Here's the code:
#include <Bela.h>
#include <Scope.h>
Scope scope;
bool setup(BelaContext *context, void *userData)
{
if(context->audioSampleRate != context->analogSampleRate)
{
fprintf(stderr, "This program shoud run with 4 analog ins\n");
}
scope.setup(4, context->audioSampleRate);
return true;
}
void render(BelaContext *context, void *userData)
{
for(unsigned int n = 0; n < context->analogFrames; n++) {
float in0 = analogRead(context, n, 0);
float in1 = analogRead(context, n, 1);
float in2 = analogRead(context, n, 2);
float in3 = analogRead(context, n, 3);
scope.log(in0, in1, in2, in3);
}
}
void cleanup(BelaContext *context, void *userData)
{}
Does this show that the channels are in the correct order (you will see in the scope "controls" panel that different colors correspond to different channels)?