panzerschwein
New member
I am having trouble with recording an analog microphones output to a byte buffer. Right now I am not using the audio adapter board, but trying to use pin 14 (A0) as an analog input. This is a modified version of the audio board recorder example.
An example of the output is:
Elapsed usec: 100004
Available Packets in Queue: 34
4352
Buffer contents: 223 46 223 46 223 46 223 46 223 46 223 46 223 46 223 46 223
I am not sure what the buffer contents mean, if anything. The buffer contents do change with voltage, but always have a repeating pattern as such.
1. Is the audio board required to acheive 44100 Hz sampling?
2. Am I going about storing the samples in a queue and then reading them post sampling in the right manner?
Code:
#include "Bounce.h"
#include "Audio.h"
#include "Wire.h"
#include "SPI.h"
#include "SD.h"
// GUItool: begin automatically generated code
AudioInputAnalog analogPinInput(14);
AudioRecordQueue queue1;
AudioConnection patchCord1(analogPinInput, queue1);
const int nbyte = 128;
const int naudiomem = 12;
float y[4411];
void setup() {
// Audio connections require memory, and the record queue
// uses this memory to buffer incoming audio.
AudioMemory(naudiomem);
Serial.begin(9600);
delay(1000);
Serial.println("STARTING");
}
void loop() {
queue1.begin();
elapsedMicros timerec;
while (timerec < 100000) {
}
queue1.end();
Serial.print("Elapsed usec: ");
Serial.println(timerec);
int npac = queue1.available();
Serial.print("Available Packets in Queue: ");
Serial.println(npac);
Serial.println(npac*nbyte);
byte buffer[npac*nbyte];
for (int k1=0; k1<naudiomem; k1++) {
memcpy(buffer + k1*nbyte, queue1.readBuffer(), nbyte);
queue1.freeBuffer();
}
queue1.clear();
Serial.print("Buffer contents: ");
for (int k1=0; k1<50; k1++) {
Serial.print(buffer[k1]);
Serial.print(" ");
}
Serial.println();
delay(5000);
}
An example of the output is:
Elapsed usec: 100004
Available Packets in Queue: 34
4352
Buffer contents: 223 46 223 46 223 46 223 46 223 46 223 46 223 46 223 46 223
I am not sure what the buffer contents mean, if anything. The buffer contents do change with voltage, but always have a repeating pattern as such.
1. Is the audio board required to acheive 44100 Hz sampling?
2. Am I going about storing the samples in a queue and then reading them post sampling in the right manner?