Repository navigation
fix(audio): resample mixer and router inputs to one configurable sample rate - #946
Merged
Merged
Conversation
A bus mixer with no input yet fixates to audiomixer's default of 44100, while main settles at whatever its consumer pins (48000 for an encoder or the vision mixer). The buses feed one another (aux and group AFL into solo, solo and main into monitor) and audiomixer cannot resample, so once two of them disagree every channel's caps query comes back empty and an input that links after startup, as every WHIP input does, fails with Noformat. Pin every bus mixer to 48 kHz with a capsfilter on its output, and add audioresample to each channel input so a source at another rate is converted instead of refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The live buses emit silence with no input, so counting buffers on main and aux passed even when the input reached neither. Measure the tone's level on main and aux instead, and open the channel's aux send, which defaults to 0. Run the same test with a 44.1 kHz input, which only links because each channel resamples to the buses' rate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without the pins an idle aux bus fixates to 44100. Checking the rate directly fails on every run, where the late link failed only when the buses happened to negotiate in the wrong order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ypes The audio format block carried its own list of sample rates. Move it to strom-types as COMMON_AUDIO_SAMPLE_RATES, with an EnumValue helper, a parser that accepts only listed rates, and DEFAULT_AUDIO_SAMPLE_RATE (48 kHz) for blocks that run all their audio at one rate. The audio format block builds its enum from the shared list; its behaviour is unchanged, and two new tests pin it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rate pins and channel capsfilters used a hardcoded 48 kHz. Add a construction-time `sample_rate` enum property (the common rates from strom-types, default 48000) and use it for every bus's rate pin and for each channel's capsfilter: every input is resampled to it, every output runs at it. Flows saved without the property keep 48 kHz. The late-input tests take the mixer rate as a parameter. A new guard builds the mixer at 44100 with a 44.1 kHz main consumer, checks every bus negotiates 44100, then links a 48 kHz input late and requires it on main and an aux bus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each output bus is an audiomixer, which holds every sink pad to the rate of the first one with caps. With no resampler in the router, a second source at another rate was refused: not-negotiated when both were there at start, not-linked when it joined a running bus. Each input now passes through audioresample and a rate capsfilter before deinterleave, and caps_out_O pins every bus to a new construction-time `sample_rate` property (the common rates from strom-types, default 48000). The capsfilter is needed because deinterleave has no source pads when it answers the caps query, so the buses' rate never reaches the resampler through it. Tests, on the real block: a 48 kHz and a 44.1 kHz input both heard when connected at start, a 44.1 kHz input heard when it joins a running bus, and sample_rate=44100 negotiating the bus at 44100 with 48 kHz inputs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 2, 2026
Closed
…-property # Conflicts: # backend/src/blocks/builtin/mixer/tests.rs
This was referenced Oct 2, 2026
This was referenced Oct 6, 2026
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.
Description
Supersedes #919 and closes #886. #919's three commits by @wagenet are included unchanged (rebased onto main, same patch ids). On top of them, the common rate is no longer locked to 48 kHz, and the live audio router gets the same treatment.
From #919 (unchanged)
audioresample. A source at another rate is now converted instead of refused. Before, the bus that negotiated first decided the rate, and a late input such as a WHIP guest failed withNoformat. See fix(mixer): run every bus at one sample rate so late inputs can link #919 for the full analysis and the real-flow verification.New
strom-types(COMMON_AUDIO_SAMPLE_RATES,DEFAULT_AUDIO_SAMPLE_RATE= 48000, with an enum helper and a parser). The Audio Format block builds its list from them, and its behaviour is unchanged.sample_rateproperty: any of the common rates, default 48000, set when the flow is built. It replaces the hardcodedMIXER_SAMPLE_RATE. Every input is resampled to it and every output runs at it.liveaudiorouterinput now runs throughaudioresampleand a rate capsfilter beforedeinterleave, and every output bus is pinned to asample_rateproperty with the same values and default. Before, a second source at another rate was refused:not-negotiatedwhen both were linked at start,not-linkedwhen it joined a running bus. The capsfilter is needed becausedeinterleavehas no src pads when it answers the caps query, so the bus rate never reached the resampler through it.Behaviour changes
sample_rate. Before, it followed whatever rate downstream negotiated. A downstream consumer that needs another rate and cannot resample will fail to link until the operator sets the property.sample_ratethat is not in the list (for example sent through the API) falls back to 48 kHz with a warning instead of being refused.Type of Change
Testing
Ran locally (macOS):
cargo test --lib mixer::tests: 47 passed, 1 ignored (the LV2 test, which needslsp-plugins-lv2).cargo test --test liveaudiorouter_test: 40 passed.cargo test --lib audioformat,cargo test --lib liveaudiorouter, thestrom-typestests,cargo test --test block_properties_persist_test: passed.cargo test --test openapi_test: passed. Block definitions are not part ofopenapi.json.cargo fmt --all --check,cargo clippy --all-targets -- -D warnings: clean.New guards, each checked to fail when its fix is reverted:
test_sample_rate_property_sets_every_bus_rate(mixer): withsample_rate=44100, every bus negotiates 44100 and a late 48 kHz input is heard on main and on an aux. With the property ignored, the 44.1 kHz main consumer cannot link.inputs_at_two_rates_connected_at_start_are_both_heard,an_input_at_another_rate_joining_a_running_bus_is_heard,the_sample_rate_property_sets_the_bus_rate. With the fix removed, all three fail withnot-linked(2 of 2 runs). With the property ignored, the rate test fails.Not run: the full
cargo test --workspace, anything on Linux, or a real flow with the new property. The real-flow verification in #919 covers the 48 kHz default.Merge order: #919 noted textual conflicts with #920 and #898 (both touch the mixer). Whichever lands second gets rebased.
🤖 Generated with Claude Code