diff --git a/src/AudioOutputI2S.cpp b/src/AudioOutputI2S.cpp index 2e8419f..cd696e4 100644 --- a/src/AudioOutputI2S.cpp +++ b/src/AudioOutputI2S.cpp @@ -270,6 +270,19 @@ bool AudioOutputI2S::ConsumeSample(int16_t sample[2]) { #endif } +#ifdef ARDUINO_ARCH_RP2040 +uint16_t AudioOutputI2S::ConsumeSamples(int16_t *samples, uint16_t count) { + // We special case the normal stereo, no gain case. OTW just use the regular full-fat path + if (this->mono || (gainF2P6 != 1<<6)) { + return AudioOutput::ConsumeSamples(samples, count); + } + auto ret = i2s.write((const uint8_t *)samples, count * 4); + ret /= 4; + return ret; +} +#endif + + void AudioOutputI2S::flush() { #ifdef ESP32 // makes sure that all stored DMA samples are consumed / played diff --git a/src/AudioOutputI2S.h b/src/AudioOutputI2S.h index 4f23966..ccdc6de 100644 --- a/src/AudioOutputI2S.h +++ b/src/AudioOutputI2S.h @@ -61,6 +61,10 @@ public: virtual bool SetChannels(int channels) override; virtual bool begin() override; virtual bool ConsumeSample(int16_t sample[2]) override; +#ifdef ARDUINO_ARCH_RP2040 + // Have an optimized block pass-through for the Pico + virtual uint16_t ConsumeSamples(int16_t *samples, uint16_t count) override; +#endif virtual void flush() override; virtual bool stop() override;