mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
channelmix: add option to filter FC
Add an option to do a lowpass filter on the FC channel to isolate the voices better and move the higher frequencies to the stereo channels. See #861
This commit is contained in:
parent
5b3388e4ac
commit
23db50630d
7 changed files with 26 additions and 4 deletions
|
|
@ -456,8 +456,11 @@ done:
|
|||
}
|
||||
maxsum = SPA_MAX(maxsum, sum);
|
||||
if (i == _CH(LFE) && mix->lfe_cutoff > 0.0f) {
|
||||
spa_log_debug(mix->log, "channel %d is LFE", ic);
|
||||
spa_log_debug(mix->log, "channel %d is LFE cutoff:%f", ic, mix->lfe_cutoff);
|
||||
lr4_set(&mix->lr4[ic], BQ_LOWPASS, mix->lfe_cutoff / mix->freq);
|
||||
} else if (i == _CH(FC) && mix->fc_cutoff > 0.0f) {
|
||||
spa_log_debug(mix->log, "channel %d is FC cutoff:%f", ic, mix->fc_cutoff);
|
||||
lr4_set(&mix->lr4[ic], BQ_LOWPASS, mix->fc_cutoff / mix->freq);
|
||||
} else {
|
||||
mix->lr4[ic].active = false;
|
||||
}
|
||||
|
|
@ -556,7 +559,7 @@ int channelmix_init(struct channelmix *mix)
|
|||
mix->options);
|
||||
|
||||
if (mix->hilbert_taps > 0) {
|
||||
mix->n_taps = SPA_CLAMP(mix->hilbert_taps, 15, 255) | 1;
|
||||
mix->n_taps = SPA_CLAMP(mix->hilbert_taps, 15u, 255u) | 1;
|
||||
blackman_window(mix->taps, mix->n_taps);
|
||||
hilbert_generate(mix->taps, mix->n_taps);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ struct channelmix {
|
|||
|
||||
float freq; /* sample frequency */
|
||||
float lfe_cutoff; /* in Hz, 0 is disabled */
|
||||
float fc_cutoff; /* in Hz, 0 is disabled */
|
||||
float rear_delay; /* in ms, 0 is disabled */
|
||||
float widen; /* stereo widen. 0 is disabled */
|
||||
uint32_t hilbert_taps; /* to phase shift, 0 disabled */
|
||||
|
|
|
|||
|
|
@ -510,6 +510,15 @@ static int impl_node_enum_params(void *object, int seq,
|
|||
SPA_PROP_INFO_params, SPA_POD_Bool(true));
|
||||
break;
|
||||
case 13:
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_PropInfo, id,
|
||||
SPA_PROP_INFO_name, SPA_POD_String("channelmix.fc-cutoff"),
|
||||
SPA_PROP_INFO_description, SPA_POD_String("FC cutoff frequency (Hz)"),
|
||||
SPA_PROP_INFO_type, SPA_POD_CHOICE_RANGE_Float(
|
||||
this->mix.fc_cutoff, 0.0, 48000.0),
|
||||
SPA_PROP_INFO_params, SPA_POD_Bool(true));
|
||||
break;
|
||||
case 14:
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_PropInfo, id,
|
||||
SPA_PROP_INFO_name, SPA_POD_String("channelmix.rear-delay"),
|
||||
|
|
@ -518,7 +527,7 @@ static int impl_node_enum_params(void *object, int seq,
|
|||
this->mix.rear_delay, 0.0, 1000.0),
|
||||
SPA_PROP_INFO_params, SPA_POD_Bool(true));
|
||||
break;
|
||||
case 14:
|
||||
case 15:
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_PropInfo, id,
|
||||
SPA_PROP_INFO_name, SPA_POD_String("channelmix.stereo-widen"),
|
||||
|
|
@ -527,7 +536,7 @@ static int impl_node_enum_params(void *object, int seq,
|
|||
this->mix.widen, 0.0, 1.0),
|
||||
SPA_PROP_INFO_params, SPA_POD_Bool(true));
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_PropInfo, id,
|
||||
SPA_PROP_INFO_name, SPA_POD_String("channelmix.hilbert-taps"),
|
||||
|
|
@ -587,6 +596,8 @@ static int impl_node_enum_params(void *object, int seq,
|
|||
CHANNELMIX_OPTION_UPMIX));
|
||||
spa_pod_builder_string(&b, "channelmix.lfe-cutoff");
|
||||
spa_pod_builder_float(&b, this->mix.lfe_cutoff);
|
||||
spa_pod_builder_string(&b, "channelmix.fc-cutoff");
|
||||
spa_pod_builder_float(&b, this->mix.fc_cutoff);
|
||||
spa_pod_builder_string(&b, "channelmix.rear-delay");
|
||||
spa_pod_builder_float(&b, this->mix.rear_delay);
|
||||
spa_pod_builder_string(&b, "channelmix.stereo-widen");
|
||||
|
|
@ -628,6 +639,8 @@ static int channelmix_set_param(struct impl *this, const char *k, const char *s)
|
|||
SPA_FLAG_UPDATE(this->mix.options, CHANNELMIX_OPTION_UPMIX, spa_atob(s));
|
||||
else if (spa_streq(k, "channelmix.lfe-cutoff"))
|
||||
spa_atof(s, &this->mix.lfe_cutoff);
|
||||
else if (spa_streq(k, "channelmix.fc-cutoff"))
|
||||
spa_atof(s, &this->mix.fc_cutoff);
|
||||
else if (spa_streq(k, "channelmix.rear-delay"))
|
||||
spa_atof(s, &this->mix.rear_delay);
|
||||
else if (spa_streq(k, "channelmix.stereo-widen"))
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ stream.properties = {
|
|||
#channelmix.mix-lfe = true
|
||||
#channelmix.upmix = false
|
||||
#channelmix.lfe-cutoff = 0
|
||||
#channelmix.fc-cutoff = 0
|
||||
#channelmix.rear-delay = 12.0
|
||||
#channelmix.stereo-widen = 0.0
|
||||
#channelmix.hilbert-taps = 0
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ stream.properties = {
|
|||
#channelmix.mix-lfe = false
|
||||
#channelmix.upmix = false
|
||||
#channelmix.lfe-cutoff = 0
|
||||
#channelmix.fc-cutoff = 0
|
||||
#channelmix.rear-delay = 12.0
|
||||
#channelmix.stereo-widen = 0.0
|
||||
#channelmix.hilbert-taps = 0
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ context.objects = [
|
|||
#channelmix.mix-lfe = false
|
||||
#channelmix.upmix = false
|
||||
#channelmix.lfe-cutoff = 0
|
||||
#channelmix.fc-cutoff = 0
|
||||
#channelmix.rear-delay = 12.0
|
||||
#channelmix.stereo-widen = 0.0
|
||||
#channelmix.hilbert-taps = 0
|
||||
|
|
@ -264,6 +265,7 @@ context.objects = [
|
|||
#channelmix.mix-lfe = false
|
||||
#channelmix.upmix = false
|
||||
#channelmix.lfe-cutoff = 0
|
||||
#channelmix.fc-cutoff = 0
|
||||
#channelmix.rear-delay = 12.0
|
||||
#channelmix.stereo-widen = 0.0
|
||||
#channelmix.hilbert-taps = 0
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ stream.properties = {
|
|||
#channelmix.mix-lfe = false
|
||||
#channelmix.upmix = false
|
||||
#channelmix.lfe-cutoff = 0
|
||||
#channelmix.fc-cutoff = 0
|
||||
#channelmix.rear-delay = 12.0
|
||||
#channelmix.stereo-widen = 0.0
|
||||
#channelmix.hilbert-taps = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue