From 34a6303695812f40d369b3530d76170b67eff5ae Mon Sep 17 00:00:00 2001 From: Liz <23021834+BlitzCityDIY@users.noreply.github.com> Date: Tue, 17 Nov 2026 17:58:59 -0500 Subject: [PATCH 1/4] enable audio filters in mpconfigboard.mk metro esp32-p4 --- ports/espressif/boards/adafruit_metro_esp32p4/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/espressif/boards/adafruit_metro_esp32p4/mpconfigboard.mk b/ports/espressif/boards/adafruit_metro_esp32p4/mpconfigboard.mk index 39bab74e4f9..74eadc8f7b9 100644 --- a/ports/espressif/boards/adafruit_metro_esp32p4/mpconfigboard.mk +++ b/ports/espressif/boards/adafruit_metro_esp32p4/mpconfigboard.mk @@ -11,6 +11,7 @@ CIRCUITPY_AUDIOFILEWRITER = 1 CIRCUITPY_USB_HOST = 1 CIRCUITPY_USB_HOST_AUDIO = 1 CIRCUITPY_AUDIOTAP = 1 +CIRCUITPY_AUDIOFILTERS = 1 CIRCUITPY_ESP_HOSTED = 1 CIRCUITPY_ESP_FLASH_SIZE = 16MB From 3d68a7991b2bce66a22e138cd68a72452083faf6 Mon Sep 17 00:00:00 2001 From: Liz <23021834+BlitzCityDIY@users.noreply.github.com> Date: Tue, 17 Nov 2026 20:51:34 -0500 Subject: [PATCH 2/4] update filters for p4 --- shared-module/audiofilters/Distortion.c | 8 ++++++++ shared-module/audiofilters/Filter.c | 8 ++++++++ shared-module/audiofilters/Phaser.c | 10 +++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/shared-module/audiofilters/Distortion.c b/shared-module/audiofilters/Distortion.c index 1498c402ea0..d235de59614 100644 --- a/shared-module/audiofilters/Distortion.c +++ b/shared-module/audiofilters/Distortion.c @@ -174,7 +174,11 @@ audioio_get_buffer_result_t audiofilters_distortion_get_buffer(audiofilters_dist self->last_buf_idx = !self->last_buf_idx; // If we are using 16 bit samples we need a 16 bit pointer, 8 bit needs an 8 bit pointer + // buffer[] was allocated on the heap, so it is aligned for 16-bit access. + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" int16_t *word_buffer = (int16_t *)self->buffer[self->last_buf_idx]; + #pragma GCC diagnostic pop int8_t *hword_buffer = self->buffer[self->last_buf_idx]; uint32_t length = self->buffer_len / (self->base.bits_per_sample / 8); @@ -231,7 +235,11 @@ audioio_get_buffer_result_t audiofilters_distortion_get_buffer(audiofilters_dist // Determine how many bytes we can process to our buffer, the less of the sample we have left and our buffer remaining uint32_t n = MIN(MIN(self->sample_buffer_length, length), SYNTHIO_MAX_DUR * self->base.channel_count); + // The source's buffer is aligned, and it is only advanced in whole samples. + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" int16_t *sample_src = (int16_t *)self->sample_remaining_buffer; // for 16-bit samples + #pragma GCC diagnostic pop int8_t *sample_hsrc = (int8_t *)self->sample_remaining_buffer; // for 8-bit samples // get the effect values we need from the BlockInput. These may change at run time so you need to do bounds checking if required diff --git a/shared-module/audiofilters/Filter.c b/shared-module/audiofilters/Filter.c index 37deaa06b58..ae907e365b4 100644 --- a/shared-module/audiofilters/Filter.c +++ b/shared-module/audiofilters/Filter.c @@ -130,7 +130,11 @@ audioio_get_buffer_result_t audiofilters_filter_get_buffer(audiofilters_filter_o self->last_buf_idx = !self->last_buf_idx; // If we are using 16 bit samples we need a 16 bit pointer, 8 bit needs an 8 bit pointer + // buffer[] was allocated on the heap, so it is aligned for 16-bit access. + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" int16_t *word_buffer = (int16_t *)self->buffer[self->last_buf_idx]; + #pragma GCC diagnostic pop int8_t *hword_buffer = self->buffer[self->last_buf_idx]; uint32_t length = self->buffer_len / (self->base.bits_per_sample / 8); @@ -188,7 +192,11 @@ audioio_get_buffer_result_t audiofilters_filter_get_buffer(audiofilters_filter_o // Determine how many bytes we can process to our buffer, the less of the sample we have left and our buffer remaining uint32_t n = MIN(MIN(self->sample_buffer_length, length), SYNTHIO_MAX_DUR * self->base.channel_count); + // The source's buffer is aligned, and it is only advanced in whole samples. + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" int16_t *sample_src = (int16_t *)self->sample_remaining_buffer; // for 16-bit samples + #pragma GCC diagnostic pop int8_t *sample_hsrc = (int8_t *)self->sample_remaining_buffer; // for 8-bit samples // get the effect values we need from the BlockInput. These may change at run time so you need to do bounds checking if required diff --git a/shared-module/audiofilters/Phaser.c b/shared-module/audiofilters/Phaser.c index 368824b4b43..b72dc130920 100644 --- a/shared-module/audiofilters/Phaser.c +++ b/shared-module/audiofilters/Phaser.c @@ -164,7 +164,11 @@ audioio_get_buffer_result_t audiofilters_phaser_get_buffer(audiofilters_phaser_o self->last_buf_idx = !self->last_buf_idx; // If we are using 16 bit samples we need a 16 bit pointer, 8 bit needs an 8 bit pointer + // buffer[] was allocated on the heap, so it is aligned for 16-bit access. + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" int16_t *word_buffer = (int16_t *)self->buffer[self->last_buf_idx]; + #pragma GCC diagnostic pop int8_t *hword_buffer = self->buffer[self->last_buf_idx]; uint32_t length = self->buffer_len / (self->base.bits_per_sample / 8); @@ -221,7 +225,11 @@ audioio_get_buffer_result_t audiofilters_phaser_get_buffer(audiofilters_phaser_o // Determine how many bytes we can process to our buffer, the less of the sample we have left and our buffer remaining uint32_t n = MIN(MIN(self->sample_buffer_length, length), SYNTHIO_MAX_DUR * self->base.channel_count); + // The source's buffer is aligned, and it is only advanced in whole samples. + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" int16_t *sample_src = (int16_t *)self->sample_remaining_buffer; // for 16-bit samples + #pragma GCC diagnostic pop int8_t *sample_hsrc = (int8_t *)self->sample_remaining_buffer; // for 8-bit samples // get the effect values we need from the BlockInput. These may change at run time so you need to do bounds checking if required @@ -305,4 +313,4 @@ audioio_get_buffer_result_t audiofilters_phaser_get_buffer(audiofilters_phaser_o // Phaser always returns more data but some effects may return GET_BUFFER_DONE or GET_BUFFER_ERROR (see audiocore/__init__.h) return GET_BUFFER_MORE_DATA; -} +} \ No newline at end of file From f2ac3e865b7b72a61c3cd6e27b2ef4dfb9378cc0 Mon Sep 17 00:00:00 2001 From: Liz <23021834+BlitzCityDIY@users.noreply.github.com> Date: Tue, 17 Nov 2026 20:59:36 -0500 Subject: [PATCH 3/4] new line --- shared-module/audiofilters/Phaser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/audiofilters/Phaser.c b/shared-module/audiofilters/Phaser.c index b72dc130920..367bc4b3f84 100644 --- a/shared-module/audiofilters/Phaser.c +++ b/shared-module/audiofilters/Phaser.c @@ -313,4 +313,4 @@ audioio_get_buffer_result_t audiofilters_phaser_get_buffer(audiofilters_phaser_o // Phaser always returns more data but some effects may return GET_BUFFER_DONE or GET_BUFFER_ERROR (see audiocore/__init__.h) return GET_BUFFER_MORE_DATA; -} \ No newline at end of file +} From 445f9c15fc20b2df7f4be287289ad34be613d9e9 Mon Sep 17 00:00:00 2001 From: Liz <23021834+BlitzCityDIY@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:04:04 -0500 Subject: [PATCH 4/4] enable for esp32-p4, not just metro --- ports/espressif/boards/adafruit_metro_esp32p4/mpconfigboard.mk | 2 -- ports/espressif/mpconfigport.mk | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ports/espressif/boards/adafruit_metro_esp32p4/mpconfigboard.mk b/ports/espressif/boards/adafruit_metro_esp32p4/mpconfigboard.mk index 74eadc8f7b9..bfce2e41c35 100644 --- a/ports/espressif/boards/adafruit_metro_esp32p4/mpconfigboard.mk +++ b/ports/espressif/boards/adafruit_metro_esp32p4/mpconfigboard.mk @@ -10,8 +10,6 @@ CIRCUITPY_USB_DEVICE_INSTANCE = FULL_SPEED_INSTANCE CIRCUITPY_AUDIOFILEWRITER = 1 CIRCUITPY_USB_HOST = 1 CIRCUITPY_USB_HOST_AUDIO = 1 -CIRCUITPY_AUDIOTAP = 1 -CIRCUITPY_AUDIOFILTERS = 1 CIRCUITPY_ESP_HOSTED = 1 CIRCUITPY_ESP_FLASH_SIZE = 16MB diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index 42457843c91..a1dc5179a00 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -376,6 +376,9 @@ else ifeq ($(IDF_TARGET),esp32p4) # No DAC CIRCUITPY_AUDIOIO = 0 +CIRCUITPY_AUDIOFILTERS ?= 1 +CIRCUITPY_AUDIOTAP ?= 1 +CIRCUITPY_USB_HOST_AUDIO ?= $(CIRCUITPY_USB_HOST) # MII is available on these targets with EMAC hardware. CIRCUITPY_MII ?= 1