giuliomoro
Hi! I haven't used Bela for 2 years, and I am still a noob for using Bela. Recently, I want to use 4 mics to measure AoA for the reflected acoustic signals, as descirbed in this discussion before. When I start using the "Analog Input 0-3" of the Audio Expander Capelet as audio input, it seems that only channels 2-3 can receive signals normally, while channels 0-1 cannot work properly. Is there something wrong with pin 0-1?
Here is the testing code for the "Analog Input 0-3" of the audio expansion module:
#include <Bela.h>
#include <libraries/Scope/Scope.h>
float gFrequency = 2000;
float gAmplitude = 1.0; // Amplitude of the sine wave (1.0 is maximum)
unsigned int gTotalSamples = 0;
float gPhase;
float gInverseSampleRate;
int mics = 4;
float input1,input2,input3,input4;
int gAudioFramesPerAnalogFrame;
Scope scope;
bool setup(BelaContext* context, void* userData)
{
printf("Audio Sample Rate: %f\n", context->audioSampleRate);
printf("Audio Frames: %d\n", context->audioFrames);
printf("Audio Output Channels: %d\n", context->audioOutChannels);
printf("Audio Input Channels: %d\n", context->audioInChannels);
printf("Analog Sample Rate: %f\n", context->analogSampleRate);
printf("Analog Frames: %d\n", context->analogFrames);
printf("Analog Output Channels: %d\n", context->analogOutChannels);
printf("Analog Input Channels: %d\n", context->analogInChannels);
gAudioFramesPerAnalogFrame = context->audioFrames/context->analogFrames;
printf("Audio/Analog Frames: %d\n", gAudioFramesPerAnalogFrame);
gInverseSampleRate = 1.0 / context->audioSampleRate;
scope.setup(mics,context->audioSampleRate);
return true;
}
void render(BelaContext* context, void* userData)
{
for(unsigned int n = 0; n < context->audioFrames; ++n)
{
gPhase += 2.0 * M_PI * gFrequency * gInverseSampleRate;
if (gPhase >= 2.0 * M_PI)
gPhase -= 2.0 * M_PI;
float out = gAmplitude * sin(gPhase);
for (unsigned int ch = 0; ch < context->audioOutChannels; ch++){
audioWrite(context, n, ch, out);
}
input1 = analogRead(context, n/gAudioFramesPerAnalogFrame, 0);
input2 = analogRead(context, n/gAudioFramesPerAnalogFrame, 1);
input3 = analogRead(context, n/gAudioFramesPerAnalogFrame, 2);
input4 = analogRead(context, n/gAudioFramesPerAnalogFrame, 3);
scope.log(input1,input2,input3,input4);
}
}
void cleanup(BelaContext *context, void *userData) {
}
The Oscilloscope window shows as:


The system setting is:
