Merge branch 'master' into optimizations

This commit is contained in:
George Norton 2023-08-18 17:48:18 +01:00
commit d2bb88a9fb
1 changed files with 16 additions and 10 deletions

View File

@ -146,14 +146,6 @@ static void __no_inline_not_in_flash_func(_as_audio_packet)(struct usb_endpoint
// Signal to core 1 that we have processed our samples, so it can write to I2S
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);
@ -162,6 +154,7 @@ static void __no_inline_not_in_flash_func(_as_audio_packet)(struct usb_endpoint
void __no_inline_not_in_flash_func(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);
@ -190,8 +183,21 @@ void __no_inline_not_in_flash_func(core1_entry)() {
out[i] = (int32_t) norm_fix3_28_to_s16sample(x_f16);
}
// Wait for Core 0 to finish running its filtering before we write to I2S
multicore_fifo_pop_blocking();
// 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);
i2s_stream_write(&i2s_write_obj, userbuf, samples * 4);
}