Automatic silence generation when I2S input clock/ws stops #1324
-
I have a fairly complex project but have distilled it down into the attached example code which has the same issue. I have two I2S inputs, one from a WM8782 ADC and one from a CP2615 (USB->I2S interface). I can see functions for generating silence but I haven't found any examples where these are used and I'm not sure how to determine when silence needs to be generated, or even if that is a sensible solution to explore.
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 13 replies
-
To keep things simple, I am using blocking reads and writes for I2S and just provide a fixed value as result for available() and availableForWrite(). The ESP32 API does not provide any functionality to read the available bytes in the buffer. I don't see any easy, portable way to resolve this: But you can try to use the following approach:
Please note that this is a kind of hack and will only work on the ESP32. Compiling this sketch on an other platform will give compile errors... |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help so far. Just wanted to provide an update as I haven't got this working properly yet but am making progress. I now have: And my loop is now:
With a CsvOutput it looks good and continues to stream indefinitely so I wanted to see if it sounds right... I tried removing I will continue to investigate myself but wanted to check if you had any ideas as I'm sinking a lot of time into troubleshooting this. Thanks again, |
Beta Was this translation helpful? Give feedback.
-
I think you need to make sure that the non reliable data source provides WMBytesCopied bytes if it is active... |
Beta Was this translation helpful? Give feedback.
-
Here is the related test case: #include "AudioTools.h"
I2SStream i2s;
FormatConverterStream fc(i2s);
AudioInfo to{22000, 2, 16};
uint8_t tmp[1024];
void setup() {
Serial.begin(114200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
auto cfg = i2s.defaultConfig(RX_MODE);
cfg.is_master = false;
i2s.driver()->setWaitTimeReadMs(8);
i2s.begin(cfg);
fc.setBuffered(false);
fc.begin(cfg, to);
}
void loop() {
auto rc = fc.readBytes(tmp, 1024);
Serial.println(rc);
} The FormatConverterStream was waiting for the requested data to be available. I changed the logic a bit to make it non blocking and committed a correction ps. |
Beta Was this translation helpful? Give feedback.
To keep things simple, I am using blocking reads and writes for I2S and just provide a fixed value as result for available() and availableForWrite(). The ESP32 API does not provide any functionality to read the available bytes in the buffer.
I don't see any easy, portable way to resolve this: But you can try to use the following approach: