giuliomoro I use the SparkFun ADMP401 MEMS microphones (Fig.1) and it has 3 pins (Vcc、GND、AUD), I think there are no problems of their connection. Then I try the example of "sample-load" to test the mics. Similarly, I make the "waves.wav" in front of the microphones and 4 mics are connected the expander (IN0-3). The result is also strange (Fig.2) . When I connect 2 mics on the Audio In pins of the Bela start kit, it can receive (audioRead) the some waves (Fig.3). What's the problem?
#include <Bela.h>
#include <libraries/AudioFile/AudioFile.h>
#include <vector>
#include <libraries/Scope/Scope.h>
std::string gFilename = "waves.wav";
int gStartFrame = 44100;
int gEndFrame = 88200;
Scope scope;
std::vector<std::vector<float> > gSampleData;
int gReadPtr; // Position of last read sample from file
bool setup(BelaContext *context, void *userData)
{
gSampleData = AudioFileUtilities::load(gFilename, gEndFrame - gStartFrame, gStartFrame);
scope.setup(2,context->audioSampleRate);
return true;
}
void render(BelaContext *context, void *userData)
{
for(unsigned int n = 0; n < context->audioFrames; n++) {
// Increment read pointer and reset to 0 when end of file is reached
if(++gReadPtr > gSampleData[0].size())
gReadPtr = 0;
for(unsigned int channel = 0; channel < context->audioOutChannels; channel++) {
// Wrap channel index in case there are more audio output channels than the file contains
float out = gSampleData[channel%gSampleData.size()][gReadPtr];
audioWrite(context, n, channel, out);
}
float input1 = analogRead(context, n, 0);
float input2 = analogRead(context, n, 1);
float input3 = analogRead(context, n, 2);
float input4 = analogRead(context, n, 3);
// float input1 = audioRead(context, n, 0);
// float input2 = audioRead(context, n, 1);
scope.log(input1,input2,input3,input4);
//scope.log(input1,input2);
}
}
void cleanup(BelaContext *context, void *userData)
{
}
Fig.1
Fig.2
Fig.3