Spectrum meter levels computed in the UAC pump task - #50
Merged
Merged
Conversation
uac_pump_meter(bands, lo_hz, hi_hz) turns on band levels computed where the sound card's bytes already pass: the C pump feeds each block it reads to usbif_meter.c, which runs two FFTs about 60 times a second (1024 points at the host rate for the upper bands, 512 points on a 700 Hz low-passed copy decimated by 16 for the bottom) and publishes one byte per band in half-dB steps. uac_pump_levels([buf]) reads them under a sequence lock; with no arguments uac_pump_meter() returns its cost counters. Also moves the audio receive path (TinyUSB's DWC2 driver, usbd, the audio class and its FIFO, and usbif's ISR hook) into IRAM with a linker fragment. On its own that made no measurable difference to delivery; it stays because the spike's numbers were taken with it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
uac_pump_meter(bands, lo_hz, hi_hz)anduac_pump_levels([buf]): band levels computed where the sound card's bytes already pass. The C pump feeds each block it reads tousbif_meter.c, which runs two FFTs about 60 times a second and publishes one byte per band in half-dB steps.uac_pump_meter()with no arguments returns its cost counters.It's the C half of the spectrum example (pydevices-examples
lib/examples/spectrum,pump_levels.py). Proven on the ESP32-P4 panel on 2026-09-25, beside the sound card: the pump costs about 1 % of a 360 MHz core for the feed, and meter-on and meter-off USB delivery match to within 0.03 % once the panel's cache writeback is sliced. That setting landed as micropython-pydevices#23.Not proven: an S3 build and run with the meter compiled in. The spike only ran on the P4.