I have enabled 4 analog inputs of the audio expander as audio inputs. I want to use 4 microphones (Type: Breakout Board for ADMP401 MEMS Microphone) to record the background noise at 44.1KHz sampling rate. The results were strange: when I set the Analog Sample Rate at 44100Hz, there are only 2 mics collects the noise while the others fail, but when I set the Analog Sample Rate at 22050Hz, all 4 mics can record the noise. I will upload the IDE seetings and the code. Please help to point out what my problem is?




Sample Rate = 22050Hz:
int mics = 4;
float input1,input2,input3,input4;
int gAudionperAnalog;
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);
gAudionperAnalog = context->audioFrames/context->analogFrames;
printf("Audio/Analog Frames: %d\n", gAudionperAnalog);
scope.setup(mics,context->audioSampleRate);
return true;
}
void render(BelaContext* context, void* userData)
{
for(unsigned int n = 0; n < context->audioFrames; ++n)
{
if((n%2) == 0){
input1 = analogRead(context, n/gAudionperAnalog, 3);
input2 = analogRead(context, n/gAudionperAnalog, 5);
input3 = analogRead(context, n/gAudionperAnalog, 6);
input4 = analogRead(context, n/gAudionperAnalog, 7);
}
scope.log(input1,input2,input3,input4);
}
}
void cleanup(BelaContext *context, void *userData) {
}
Sample Rate = 44100Hz:
bool setup(BelaContext* context, void* userData)
{
# same as the 22050Hz
}
void render(BelaContext* context, void* userData)
{
for(unsigned int n = 0; n < context->audioFrames; ++n)
{
input1 = analogRead(context, n/gAudionperAnalog, 3);
input2 = analogRead(context, n/gAudionperAnalog, 5);
input3 = analogRead(context, n/gAudionperAnalog, 6);
input4 = analogRead(context, n/gAudionperAnalog, 7);
scope.log(input1,input2,input3,input4);
}
}
void cleanup(BelaContext *context, void *userData) {
}