Skip to content

fix filters: a bus's parameter read, faded or oscillated with a sound handle missed the bus - #623

Merged
alnitak merged 1 commit into
alnitak:mainfrom
Kunstderfug:pr/bus-filter-params
Nov 28, 2026
Merged

alnitak merged 1 commit into
alnitak:mainfrom
Kunstderfug:pr/bus-filter-params

Conversation

@Kunstderfug

Copy link
Copy Markdown
Contributor

What

A bus's filter parameter can be given a soundHandle, for example
bus.filters.echoFilter.wet(soundHandle: h) where h is a sound playing on
the bus. The four parameter operations did not agree on which voice that
addresses:

  • set swapped in the bus's own voice (Filters::setFilterParams), so it
    changed the bus's filter;
  • get, fade and oscillate used the handle they were given, so they
    addressed the sound's voice, which has no filter in that slot. SoLoud then
    returns its error value as the parameter: get read 1 with noError.
    Fade and oscillate silently did nothing and also returned noError.

What the native exports return on main:

setFilterParams(voice, bus, echo, wet, 0.5) -> noError
getFilterParams(0, bus, echo, wet)          -> noError, 0.5   (the bus changed)
getFilterParams(voice, bus, echo, wet)      -> noError, 1     (wrong value)
fadeFilterParameter(voice, bus, ..., 1.0)   -> noError, the bus stays at 0.5
oscillateFilterParameter(voice, bus, ...)   -> noError, the bus stays at 0.5

The fix moves the swap into Filters::findParam, which all four operations
(and the custom-filter exports) go through. On a bus they now act on the
bus's voice, whatever handle comes with it. A bus that has not been played
still reports soundHandleNotFound. setCustomFilterParamDefinition passes
handle 0 for a bus, which already got the bus's voice through set, so its
behaviour does not change.

Changes

  • src/filters/filters.cpp, filters.h: findParam takes the handle by
    reference and replaces it with the bus's voice on a bus. The swap in
    setFilterParams is removed. The comments say so.
  • test/common/filter_params_test.cpp: new scenario voice. It plays a
    sound on a bus that has an echo, then sets, reads, fades and oscillates
    the bus's wet through the sound's handle, and checks the bus's value.
  • CHANGELOG.md: a Fixes entry under a new 5.4.1 (XX Xxx 2026).

Testing

macOS (arm64), from the repository root:

./test/common/filter_params_test.sh voice
  • Without the fix: 11 assertions, 3 failures.
    • "the bus's echo wet reads back with the voice's handle as error 0,
      value 1"
    • "the bus's echo wet fades to 1 with the voice's handle, it is 0.5"
    • "the bus's echo wet oscillates in [0.1, 0.2] with the voice's handle, it
      is 0.5"
  • With the fix: 11 assertions, 0 failures.

With the fix:

Command Result
./test/common/filter_params_test.sh 88 assertions, 0 failures
./test/common/filter_params_test.sh --asan 88 assertions, 0 failures
./test/common/bus_destroy_filter_test.sh 12, 0
./test/common/filter_ops_test.sh 19, 0
./test/common/custom_filter_test.sh PASS
./test/common/bus_annex_test.sh 13, 0
./test/common/bus_visualization_test.sh 74, 0
./test/common/realtime_and_custom_dsp_test.sh 518, 0
./test/common/bus_samplerate_test.sh 12, 0
flutter test test/common/filters_api_test.dart test/common/mixing_bus_test.dart 359 passed
python3 test/support/gen_cmake.py test/CMakeLists.txt unchanged

Not run: Linux, Windows, Android and iOS. Web: built only, not run.

web/compile_wasm.sh builds this branch (both the single- and the
multi-threaded library). The rebuilt WASM libraries are left out of this PR,
so it carries no binary changes: they can go in your next update wasm libs
commit. On web, every filter parameter operation with a soundHandle
already throws in Dart before it reaches native code, so web users were not
affected.

Follow-ups

  • filterParamTarget in bindings.cpp still picks the handle before it
    calls Filters. On a bus that choice no longer matters. It could be
    simplified in a later cleanup.

🤖 Generated with Claude Code

@alnitak

alnitak commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Thanks for catching this and for the thorough write-up and test!

Merging now!

@alnitak
alnitak merged commit f033794 into alnitak:main Nov 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants