17#define MIN(A, B) ((A) < (B) ? (A) : (B))
42static const char*
RxTxModeNames[4] = {
"UNDEFINED_MODE",
"TX_MODE",
"RX_MODE",
125 virtual void logInfo(
const char* source =
"") {
126 LOGI(
"%s sample_rate: %d / channels: %d / bits_per_sample: %d", source,
160 if (pos < 0)
return false;
181 n->setAudioInfo(info);
228 int result = out->
write(data + written, open);
243 uint32_t result = 1000000l / samplingRate;
244 if (1000000l % samplingRate != 0) {
247 if (result <= limit) {
248 LOGW(
"Time for samplingRate %u -> %u is < %u μs - we rounded up",
249 (
unsigned int)samplingRate, (
unsigned int)result,
250 (
unsigned int)limit);
264 uint32_t result = 1000l / samplingRate;
265 if (1000000l % samplingRate != 0) {
268 if (result <= limit) {
269 LOGW(
"Time for samplingRate %u -> %u is < %u μs - we rounded up",
270 (
unsigned int)samplingRate, (
unsigned int)result,
271 (
unsigned int)limit);
316 template <
typename T>
322 return std::numeric_limits<T>::max();
328 template <
typename T>
334 return std::numeric_limits<T>::min();
341 template <
typename T>
346 }
else if (value < -
mv) {
357 }
else if (value < -
mv) {
364 template <
typename T>
370 template <
typename T>
377 return static_cast<float>(value) /
maxValue(bits);
386 template <
typename FromT,
typename ToT>
402 template <
typename FromT,
typename ToT>
407 for (
int j = 0;
j < samples;
j++) {
433 "I2S_PHILIPS_FORMAT",
434 "I2S_RIGHT_JUSTIFIED_FORMAT",
435 "I2S_LEFT_JUSTIFIED_FORMAT",
457 int open =
sizeof(
T);
473 int open = samples *
sizeof(
T);
491 return total /
sizeof(
T);
495template <
typename T,
class P>
498 int open = samples *
sizeof(
T);
508 return total /
sizeof(
T);
#define LOGW(...)
Definition AudioLoggerIDF.h:29
#define TRACED()
Definition AudioLoggerIDF.h:31
#define LOGI(...)
Definition AudioLoggerIDF.h:28
MemoryType
Memory types.
Definition AudioTypes.h:37
uint32_t sample_rate_t
Type alias for sample rate values.
Definition AudioTypes.h:23
void waitFor(bool &flag)
wait for flag to be active
Definition AudioTypes.h:525
RxTxMode
The Microcontroller is the Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Si...
Definition AudioTypes.h:30
TimeUnit
Time Units.
Definition AudioTypes.h:48
@ RAM
Definition AudioTypes.h:37
@ PS_RAM
Definition AudioTypes.h:37
@ FLASH_RAM
Definition AudioTypes.h:37
@ RXTX_MODE
Definition AudioTypes.h:30
@ TX_MODE
Definition AudioTypes.h:30
@ UNDEFINED_MODE
Definition AudioTypes.h:30
@ RX_MODE
Definition AudioTypes.h:30
@ US
Definition AudioTypes.h:48
@ HZ
Definition AudioTypes.h:48
@ MS
Definition AudioTypes.h:48