mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
filter-chain: add invert plugin
To invert the polarity of a signal. See #3008
This commit is contained in:
parent
fda829a1fa
commit
72242dc91f
2 changed files with 40 additions and 0 deletions
|
|
@ -273,6 +273,12 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
* - `max-delay` the maximum delay in seconds. The "Delay (s)" parameter will
|
||||
* be clamped to this value.
|
||||
*
|
||||
* ### Invert
|
||||
*
|
||||
* The invert plugin can be used to invert the phase of the signal.
|
||||
*
|
||||
* It has an input port "In" and an output port "Out".
|
||||
*
|
||||
* ## General options
|
||||
*
|
||||
* Options with well-known behavior. Most options can be added to the global
|
||||
|
|
|
|||
|
|
@ -978,6 +978,38 @@ static const struct fc_descriptor delay_desc = {
|
|||
.cleanup = delay_cleanup,
|
||||
};
|
||||
|
||||
static void invert_run(void * Instance, unsigned long SampleCount)
|
||||
{
|
||||
struct builtin *impl = Instance;
|
||||
float *in = impl->port[1], *out = impl->port[0];
|
||||
unsigned long n;
|
||||
for (n = 0; n < SampleCount; n++)
|
||||
out[n] = -in[n];
|
||||
}
|
||||
|
||||
static struct fc_port invert_ports[] = {
|
||||
{ .index = 0,
|
||||
.name = "Out",
|
||||
.flags = FC_PORT_OUTPUT | FC_PORT_AUDIO,
|
||||
},
|
||||
{ .index = 1,
|
||||
.name = "In",
|
||||
.flags = FC_PORT_INPUT | FC_PORT_AUDIO,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct fc_descriptor invert_desc = {
|
||||
.name = "invert",
|
||||
|
||||
.n_ports = 2,
|
||||
.ports = invert_ports,
|
||||
|
||||
.instantiate = builtin_instantiate,
|
||||
.connect_port = builtin_connect_port,
|
||||
.run = invert_run,
|
||||
.cleanup = builtin_cleanup,
|
||||
};
|
||||
|
||||
static const struct fc_descriptor * builtin_descriptor(unsigned long Index)
|
||||
{
|
||||
switch(Index) {
|
||||
|
|
@ -1005,6 +1037,8 @@ static const struct fc_descriptor * builtin_descriptor(unsigned long Index)
|
|||
return &convolve_desc;
|
||||
case 11:
|
||||
return &delay_desc;
|
||||
case 12:
|
||||
return &invert_desc;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue