I'm trying to read samples from mic with audio shield. I'm using readBuffer() to do so, but the data that is displayed for each sample of 128 bit array doesnt make any sense to me. If i'm reading from microphone then shouldn't the sampled data be random? I've posted my code below and the Serial monitor capture of what i'm getting. Any help would be appreciated on what i'm doing wrong. Thank you!
serial output:
my code:
//
// Microphone to Speaker output
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S Mic; //microphone
AudioRecordQueue MicMem; //queue for microphone
AudioOutputI2S headphones; //output
AudioConnection patchCord1(Mic, 0, MicMem, 0);
AudioConnection patchCord2(Mic, 0, headphones,0);
AudioConnection patchCord3(Mic, 0, headphones,1);
AudioControlSGTL5000 sgtl5000_1; //xy=339.6666564941406,285.6666488647461
// GUItool: end automatically generated code
int16_t data1[128];
const int micInput = AUDIO_INPUT_MIC;
void setup() {
Serial.begin(9600);
AudioMemory(20);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sgtl5000_1.inputSelect(micInput);
sgtl5000_1.micGain(36);
delay(1000);
}
void loop() {
MicMem.begin();
int16_t *data = MicMem.readBuffer();
for(int i = 0; i < 128; i++) {
Serial.println(data);
}
MicMem.freeBuffer(); // do not use "data" after this!
MicMem.end();
delay(500);
}
serial output:
my code:
//
// Microphone to Speaker output
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S Mic; //microphone
AudioRecordQueue MicMem; //queue for microphone
AudioOutputI2S headphones; //output
AudioConnection patchCord1(Mic, 0, MicMem, 0);
AudioConnection patchCord2(Mic, 0, headphones,0);
AudioConnection patchCord3(Mic, 0, headphones,1);
AudioControlSGTL5000 sgtl5000_1; //xy=339.6666564941406,285.6666488647461
// GUItool: end automatically generated code
int16_t data1[128];
const int micInput = AUDIO_INPUT_MIC;
void setup() {
Serial.begin(9600);
AudioMemory(20);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sgtl5000_1.inputSelect(micInput);
sgtl5000_1.micGain(36);
delay(1000);
}
void loop() {
MicMem.begin();
int16_t *data = MicMem.readBuffer();
for(int i = 0; i < 128; i++) {
Serial.println(data);
}
MicMem.freeBuffer(); // do not use "data" after this!
MicMem.end();
delay(500);
}