I developt an application which receive the data of the microphone in C langauge with the function below :
AAudioStreamBuilder_setDirection(streamBuilder, AAUDIO_DIRECTION_INPUT);
AAudioStreamBuilder_setSharingMode(streamBuilder, AAUDIO_SHARING_MODE_EXCLUSIVE);
AAudioStreamBuilder_setSampleRate(streamBuilder, 20000);
AAudioStreamBuilder_setFormat(streamBuilder, AAUDIO_FORMAT_PCM_FLOAT);
AAudioStreamBuilder_setBufferCapacityInFrames(streamBuilder, 16);
AAudioStreamBuilder_setDataCallback(streamBuilder, myCallback, nullptr);
AAudioStreamBuilder_setPerformanceMode(streamBuilder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
// Opens the stream.
aaudio_result_t result = AAudioStreamBuilder_openStream(streamBuilder, &stream_);
if (result != AAUDIO_OK) {
__android_log_print(ANDROID_LOG_ERROR, "AudioEngine", "Error opening stream %s",
AAudio_convertResultToText(result));
return false;
}
// Retrieves the sample rate of the stream for our oscillator.
int32_t sampleRate = AAudioStream_getSampleRate(stream_);
result = AAudioStream_requestStart(stream_);
if (result != AAUDIO_OK) {
__android_log_print(ANDROID_LOG_ERROR, "AudioEngine", "Error starting stream %s",
AAudio_convertResultToText(result));
return false;
}
Do you know what's the unit receive by my callback function ?
Cause I want to determine the dB average and it didn't return the same value as another application with the below function :
10*log10(s_fifo.A)
s_fifo.A is the average in 1023 point
Library use : aaudio/AAudio.h
Best Regards.
The unit is abviously a decimal value that depends of the subsampling previously configured.