Hi Guys,
I want to send audio data captured by XIAO BLE Sense mic to Studio using Data Forwarder. Do you have an Arduino Sketch example that I can use? For accelerometer data, I adapted the Nano BLE Sense example, but I did not find one for audio data.
For audio, I am using the code below (the same I used for the microphone test), but the studio does not recognize it as audio (what I understand). Should I convert it to .wav?
#include <PDM.h>
short sampleBuffer[2048];
volatile int samplesRead;
void setup() {
Serial.begin(115200);
while (!Serial);
PDM.onReceive(onPDMdata);
PDM.setBufferSize(4096);
PDM.setGain(127);
if (!PDM.begin(1, 16000)) {
Serial.println("Failed to start PDM!");
while (1);
}
}
void loop() {
if (samplesRead) {
for (int i = 0; i < samplesRead; i++) {
Serial.println(sampleBuffer[i]);
}
samplesRead = 0;
}
}
void onPDMdata() {
int bytesAvailable = PDM.available();
PDM.read(sampleBuffer, bytesAvailable);
samplesRead = bytesAvailable / 2;
}
thanks.
Marcelo