Skip to content

Sound module: Expression on every part, kept when a part's instrument is made again - #53

Merged
bdbarnett merged 1 commit into
mainfrom
fix/expression-kept
Nov 10, 2026
Merged

bdbarnett merged 1 commit into
mainfrom
fix/expression-kept

Conversation

@bdbarnett

Copy link
Copy Markdown
Contributor

Expression (CC11) now works on every part of the sound module and a part keeps it when its instrument is made again. Closes #52.

On a part playing one of audioinstruments' instruments (bank 80), CC11 did nothing, so a MIDI file that fades such a part with Expression did not fade. And a SoundFont part lost its Expression when its instrument was made again, by a bank change to another instrument and back or by All Sound Off, which should stop the sound and keep the controllers. The part now remembers Expression the way it remembers volume and pan. On an instrument part, volume and Expression multiply and the product is squared, as a SoundFont part plays them; a rebuilt SoundFont part is given its Expression before its first note; Reset All Controllers and GM System On put it back to 127 on every part. The module's docstring says so.

I rendered one held note through the module on the FluidR3_GM bank, with audioinstruments 0.5.2.dev2, RMS against CC11 = 127. Before and after this change:

CC11 SoundFont part instrument part (poly106), before instrument part, after square law
100 -4.2 dB 0.0 dB -4.2 dB -4.2 dB
64 -11.9 dB 0.0 dB -11.9 dB -11.9 dB
32 -23.9 dB 0.0 dB -24.0 dB -23.9 dB

A SoundFont part set to CC11 = 32 played 23.5 RMS before the rebuild and 371.4 after it (-23.9 dB, then 0 dB: Expression lost) both by a bank change and back and by All Sound Off. With this change it plays 23.6 after both.

New checks in tests/engine_contract.py cover the instrument part's level, Reset All Controllers, All Sound Off, a rebuilt SoundFont part and GM System On; each fails without the change, and three new plants break the module in the ways they guard against. Ran tests/test_engine.py (the contract on CPython and every plant) against audioinstruments main; it passes. I did not run the MicroPython or CircuitPython contract; CI does.

…ment is made again

CC11 only reached a SoundFont part, and a part forgot it when its instrument
was made again (a bank change to another instrument and back, or All Sound
Off). A part now keeps its Expression: on an instrument part it multiplies
with volume in the mixer level, squared as on a SoundFont part, and a rebuilt
SoundFont part has it before its first note.
@bdbarnett
bdbarnett merged commit 007066c into main Nov 10, 2026
6 checks passed
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.

Sound module: Expression (CC11) is ignored on instrument parts and forgotten when a part is rebuilt

1 participant