channelmix: add option for stereo widen

When generating FC, add an option to subtract some of the generated
FC from the FL and FR channel to move the sound more to the center.

See #861
This commit is contained in:
Wim Taymans 2022-03-01 10:28:11 +01:00
parent 60b338d4cf
commit 5dd0a12875
7 changed files with 39 additions and 12 deletions

View file

@ -249,8 +249,9 @@ channelmix_f32_2_3p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
else if (v0 == 1.0f && v1 == 1.0f) {
for (n = 0; n < n_samples; n++) {
float c = s[0][n] + s[1][n];
d[0][n] = s[0][n];
d[1][n] = s[1][n];
float w = c * mix->widen;
d[0][n] = s[0][n] - w;
d[1][n] = s[1][n] - w;
d[2][n] = c;
}
lr4_process(&mix->lr4[3], d[3], d[2], v3, n_samples);
@ -259,8 +260,9 @@ channelmix_f32_2_3p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
else {
for (n = 0; n < n_samples; n++) {
float c = s[0][n] + s[1][n];
d[0][n] = s[0][n] * v0;
d[1][n] = s[1][n] * v1;
float w = c * mix->widen;
d[0][n] = (s[0][n] - w) * v0;
d[1][n] = (s[1][n] - w) * v1;
d[2][n] = c;
}
lr4_process(&mix->lr4[3], d[3], d[2], v3, n_samples);
@ -290,9 +292,10 @@ channelmix_f32_2_5p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
else if (v0 == 1.0f && v1 == 1.0f) {
for (n = 0; n < n_samples; n++) {
float c = s[0][n] + s[1][n];
float w = c * mix->widen;
float m = s[0][n] - s[1][n];
d[0][n] = s[0][n];
d[1][n] = s[1][n];
d[0][n] = s[0][n] - w;
d[1][n] = s[1][n] - w;
d[3][n] = c;
d[5][n] = m;
}
@ -307,9 +310,10 @@ channelmix_f32_2_5p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
else {
for (n = 0; n < n_samples; n++) {
float c = s[0][n] + s[1][n];
float w = c * mix->widen;
float m = s[0][n] - s[1][n];
d[0][n] = s[0][n] * v0;
d[1][n] = s[1][n] * v1;
d[0][n] = (s[0][n] - w) * v0;
d[1][n] = (s[1][n] - w) * v1;
d[3][n] = c;
d[5][n] = m;
}
@ -346,10 +350,13 @@ channelmix_f32_2_7p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
else if (v0 == 1.0f && v1 == 1.0f && v4 == 1.0f && v5 == 1.0f) {
for (n = 0; n < n_samples; n++) {
float c = s[0][n] + s[1][n];
float w = c * mix->widen;
float m = s[0][n] - s[1][n];
d[0][n] = d[4][n] = s[0][n];
d[1][n] = d[5][n] = s[1][n];
d[0][n] = s[0][n] - w;
d[1][n] = s[1][n] - w;
d[3][n] = c;
d[4][n] = s[0][n];
d[5][n] = s[1][n];
d[7][n] = m;
}
lr4_process(&mix->lr4[2], d[2], d[3], v2, n_samples);
@ -363,9 +370,10 @@ channelmix_f32_2_7p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
else {
for (n = 0; n < n_samples; n++) {
float c = s[0][n] + s[1][n];
float w = c * mix->widen;
float m = s[0][n] - s[1][n];
d[0][n] = s[0][n] * v0;
d[1][n] = s[1][n] * v1;
d[0][n] = (s[0][n] - w) * v0;
d[1][n] = (s[1][n] - w) * v1;
d[3][n] = c;
d[4][n] = s[0][n] * v4;
d[5][n] = s[1][n] * v5;