Skip to content

audioeffects: AUDIOEFFECTS freezes only the effects you name - #355

Merged
bdbarnett merged 3 commits into
mainfrom
audioeffects-selection
Nov 9, 2026
Merged

bdbarnett merged 3 commits into
mainfrom
audioeffects-selection

Conversation

@bdbarnett

Copy link
Copy Markdown
Contributor

`AUDIOEFFECTS=chorus,reverb` freezes audioeffects' `init`, its shared base and the named effects, plus any effect they build on (a rack brings its parts). It works the way `AUDIOINSTRUMENTS` does: names are module or class names in any case, an unknown name stops the build and lists the effects, and unset or empty freezes the whole package.

It needs an audioeffects that loads each effect on first use (v0.5.2.dev0 on). An older one stops the build with a message that says so, rather than freezing a package whose import fails on the board.

Also: both packages' manifests now load their own `selection.py` by path. Under the same module name, the second manifest to run got the first one's helper.

Checked:

  • `tests/test_effects_selection.py`, 10 tests, in the build-mp unit job.
  • On an ESP32 Audio Kit, with chorus and reverb, `soundfont` and a General MIDI sound module's libraries, the image is 3,843 KB (0x3c0ad0), and it fits the kit's 0x3d0000 app slot. The whole package makes 4,095 KB, which doesn't fit.
  • That image on the kit: `audioeffects.ALL` is `('Chorus', 'Reverb')`, `create("Compressor", ...)` raises ImportError, and the sound module's engine opens a SoundFont, builds its Reverb and plays notes through the speaker, captured on a microphone.

The guide is now "Build with a few instruments and effects", and the links to it use the new title.

Like AUDIOINSTRUMENTS. The manifest hands the comma list to selection.py,
which follows the named effects' imports (a rack brings the effects it
builds on) and writes an __init__ whose class table, __all__ and ALL list
only them. An unknown name stops the build and lists the effects. An
audioeffects that imports every effect when it loads can't be frozen in
part, so the build stops there too rather than freeze a package that fails
to import on the board. Unset or empty freezes the whole package.
Both packages' helpers are named selection.py; a plain import found
whichever manifest ran first.
AUDIOEFFECTS, what it freezes, and what it saves on an ESP32 Audio Kit:
a 4,095 KB image with every effect, 3,843 KB with chorus and reverb.
@bdbarnett
bdbarnett merged commit a0cd6ac into main Nov 9, 2026
8 checks passed
@bdbarnett
bdbarnett deleted the audioeffects-selection branch November 9, 2026 09:18
@bdbarnett

Copy link
Copy Markdown
Contributor Author

Checked again on current main (afc3057) on the ESP32 Audio Kit: AUDIOEFFECTS=chorus,reverb with the modules pydevices, displayif, lvgl, btclassic, jpegio, audioif, audiodsp and audioeffects, AUDIO_KIT variant. The image is 0x394970 (3,754,352 bytes) in the 0x3d0000 slot, 0x3b690 (243 KB) free. Flashed app-only at 0x10000, files untouched.

On the board audioeffects.ALL is ('Chorus', 'Reverb'). Importing audioeffects loads only audioeffects and its _component; Chorus and Reverb resolve; Compressor, Limiter and Phaser raise AttributeError and import audioeffects.compressor raises ImportError. The phone reconnected to the music player app on its own, and two 35 s captures of music from the line out read no real dropouts (the first reported one 10 ms gap at 20.05 s, which the zoom shows is a continuous low-level stretch of the music with no phase break).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant