filter-graph: add gain option to sofa

So that we can apply the gain to the IR. This is more efficient than
doing a volume after the convolution.

See #5098
This commit is contained in:
Wim Taymans 2026-02-02 16:21:03 +01:00
parent f60e03b4ef
commit 3c80f0fb3e
3 changed files with 50 additions and 21 deletions

View file

@ -19,6 +19,8 @@ context.modules = [
name = spFL
config = {
filename = "~/.config/hrtf-sofa/hrtf b_nh724.sofa"
# The gain depends on the .sofa file in use
gain = 0.5
}
control = {
"Azimuth" = 30.0
@ -32,6 +34,7 @@ context.modules = [
name = spFR
config = {
filename = "~/.config/hrtf-sofa/hrtf b_nh724.sofa"
gain = 0.5
}
control = {
"Azimuth" = 330.0
@ -45,6 +48,7 @@ context.modules = [
name = spFC
config = {
filename = "~/.config/hrtf-sofa/hrtf b_nh724.sofa"
gain = 0.5
}
control = {
"Azimuth" = 0.0
@ -58,6 +62,7 @@ context.modules = [
name = spRL
config = {
filename = "~/.config/hrtf-sofa/hrtf b_nh724.sofa"
gain = 0.5
}
control = {
"Azimuth" = 150.0
@ -71,6 +76,7 @@ context.modules = [
name = spRR
config = {
filename = "~/.config/hrtf-sofa/hrtf b_nh724.sofa"
gain = 0.5
}
control = {
"Azimuth" = 210.0
@ -84,6 +90,7 @@ context.modules = [
name = spSL
config = {
filename = "~/.config/hrtf-sofa/hrtf b_nh724.sofa"
gain = 0.5
}
control = {
"Azimuth" = 90.0
@ -97,6 +104,7 @@ context.modules = [
name = spSR
config = {
filename = "~/.config/hrtf-sofa/hrtf b_nh724.sofa"
gain = 0.5
}
control = {
"Azimuth" = 270.0
@ -110,6 +118,7 @@ context.modules = [
name = spLFE
config = {
filename = "~/.config/hrtf-sofa/hrtf b_nh724.sofa"
gain = 0.5
}
control = {
"Azimuth" = 0.0
@ -120,26 +129,28 @@ context.modules = [
{ type = builtin label = mixer name = mixL
control = {
"Gain 1" = 0.5
"Gain 2" = 0.5
"Gain 3" = 0.5
"Gain 4" = 0.5
"Gain 5" = 0.5
"Gain 6" = 0.5
"Gain 7" = 0.5
"Gain 8" = 0.5
# Set individual left mixer gain if needed
#"Gain 1" = 1.0
#"Gain 2" = 1.0
#"Gain 3" = 1.0
#"Gain 4" = 1.0
#"Gain 5" = 1.0
#"Gain 6" = 1.0
#"Gain 7" = 1.0
#"Gain 8" = 1.0
}
}
{ type = builtin label = mixer name = mixR
control = {
"Gain 1" = 0.5
"Gain 2" = 0.5
"Gain 3" = 0.5
"Gain 4" = 0.5
"Gain 5" = 0.5
"Gain 6" = 0.5
"Gain 7" = 0.5
"Gain 8" = 0.5
# Set individual right mixer gain if needed
#"Gain 1" = 1.0
#"Gain 2" = 1.0
#"Gain 3" = 1.0
#"Gain 4" = 1.0
#"Gain 5" = 1.0
#"Gain 6" = 1.0
#"Gain 7" = 1.0
#"Gain 8" = 1.0
}
}
]

View file

@ -717,6 +717,7 @@ extern struct spa_handle_factory spa_filter_graph_factory;
* blocksize = ...
* tailsize = ...
* filename = ...
* gain = ...
* }
* control = {
* "Azimuth" = ...
@ -733,9 +734,10 @@ extern struct spa_handle_factory spa_filter_graph_factory;
* - `blocksize` specifies the size of the blocks to use in the FFT. It is a value
* between 64 and 256. When not specified, this value is
* computed automatically from the number of samples in the file.
* - `tailsize` specifies the size of the tail blocks to use in the FFT.
* - `filename` The SOFA file to load. SOFA files usually end in the .sofa extension
* and contain the HRTF for the various spatial positions.
* - `tailsize` specifies the size of the tail blocks to use in the FFT.
* - `filename` The SOFA file to load. SOFA files usually end in the .sofa extension
* and contain the HRTF for the various spatial positions.
* - `gain` the overall gain to apply to the IR file.
*
* - `Azimuth` controls the azimuth, this is the direction the sound is coming from
* in degrees between 0 and 360. 0 is straight ahead. 90 is left, 180