2 #include "AudioTools/CoreAudio/AudioStreams.h"
19 int buffer_size = 512;
27 LOGI(
"gain: %d", gain);
28 LOGI(
"buffer_size: %d", buffer_size);
43 if (p_buffer !=
nullptr)
delete p_buffer;
48 if (mode != RX_MODE) {
49 LOGE(
"TX_MODE is not supported");
54 bool begin() {
return begin(config); }
60 if (p_buffer ==
nullptr) {
63 p_mic->setBufferSize(cfg.buffer_size);
64 p_mic->onReceive(onReceiveStatic);
70 LOGD(
"setGain: %d", cfg.gain);
71 p_mic->setGain(cfg.gain);
77 if (p_mic !=
nullptr) {
85 size_t readBytes(uint8_t *data,
size_t len)
override {
86 if (p_buffer ==
nullptr)
return 0;
90 int available()
override {
91 if (p_buffer ==
nullptr)
return 0;
96 PDMClass *p_mic = &PDM;
103 int bytesAvailable = p_mic->available();
105 uint8_t sampleBuffer[bytesAvailable]={0};
106 int read = PDM.read(sampleBuffer, bytesAvailable);
110 static void onReceiveStatic() { selfAudioMP34DT05->
onReceive(); }