mixer-dsp: add support for fade-in and fade-out

When the port IO_Buffers is set, do a fade-in of the next buffer data
into the final mixed output.

When the port IO Buffers in cleared, do a fade-out of that last sample.

Add a zeroramp.duration property that controls the length in seconds of
the fade-in/out curve. By default, set this to 5ms.

The fade-in and fade-outs avoid popping noise from sudden DC voltage
changes when ports a linked and unlinked.

It will also trigger when the upstream peer is paused, because that will
also remove the IO Buffers from the mixer ports.
This commit is contained in:
Wim Taymans 2026-06-17 16:56:53 +02:00
parent 9a19091ac7
commit 214b9f6daa
2 changed files with 136 additions and 45 deletions

View file

@ -54,7 +54,7 @@ static int setup_context(struct context *ctx)
size_t size;
int res;
struct spa_support support[1];
struct spa_dict_item items[9];
struct spa_dict_item items[11];
const struct spa_handle_factory *factory;
void *iface;
@ -79,10 +79,12 @@ static int setup_context(struct context *ctx)
items[6] = SPA_DICT_ITEM_INIT("channelmix.center-level", "0.707106781");
items[7] = SPA_DICT_ITEM_INIT("channelmix.surround-level", "0.707106781");
items[8] = SPA_DICT_ITEM_INIT("channelmix.lfe-level", "0.5");
items[9] = SPA_DICT_ITEM_INIT("zeroramp.gap", "0");
items[10] = SPA_DICT_ITEM_INIT("zeroramp.duration", "0.0");
res = spa_handle_factory_init(factory,
ctx->convert_handle,
&SPA_DICT_INIT(items, 9),
&SPA_DICT_INIT(items, 11),
support, 1);
spa_assert_se(res >= 0);