From fd6cbf54d50ba38cd1d3ac8606a676754dc89562 Mon Sep 17 00:00:00 2001 From: ploopyco Date: Wed, 16 Aug 2023 13:31:56 -0400 Subject: [PATCH] refactored volume updates and filter configs to run on core 1 --- firmware/code/run.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/firmware/code/run.c b/firmware/code/run.c index 2f019a6..0920b1b 100644 --- a/firmware/code/run.c +++ b/firmware/code/run.c @@ -156,14 +156,6 @@ static void _as_audio_packet(struct usb_endpoint *ep) { uint32_t ready = multicore_fifo_pop_blocking(); multicore_fifo_push_blocking(CORE0_READY); - // Update the volume if required. We do this from core1 as - // core0 is more heavily loaded, doing this from core0 can - // lead to audio crackling. - update_volume(); - - // Update filters if required - apply_config_changes(); - // keep on truckin' usb_grow_transfer(ep->current_transfer, 1); usb_packet_done(ep); @@ -172,6 +164,7 @@ static void _as_audio_packet(struct usb_endpoint *ep) { void core1_entry() { uint8_t *userbuf = (uint8_t *) multicore_fifo_pop_blocking(); int32_t *out = (int32_t *) userbuf; + int limit_counter = 100; // Signal that the thread has started multicore_fifo_push_blocking(CORE1_READY); @@ -198,6 +191,19 @@ void core1_entry() { } } + // Update the volume and filter configs if required. We do this from + // core1 as core0 is more heavily loaded, doing this from core0 can + // lead to audio crackling. + // Use of a counter reduces the amount of crackling when changing + // volume. + if (limit_counter != 0) + limit_counter--; + else { + limit_counter = 100; + update_volume(); + apply_config_changes(); + } + // Signal to core 0 that the data has all been transformed multicore_fifo_push_blocking(CORE1_READY);