@@ -27,11 +27,12 @@ void Config::parseBasic() {
27
27
const unordered_map<Channel, SpeakerType> channelsMap = parseChannels (pBasicNode, stereoBass, subs, subLs, subRs, smalls, path);
28
28
const bool useSubwoofers = getUseSubwoofers (subs, subLs, subRs);
29
29
const double lfeGain = getLfeGain (pBasicNode, useSubwoofers, smalls.size (), path);
30
+ const double centerGain = tryGetDoubleValue (pBasicNode, " centerGain" , path);
30
31
31
32
// Parse crossover config
32
33
parseBasicCrossovers (pBasicNode, channelsMap, path);
33
34
// Route input to output channels
34
- routeChannels (channelsMap, stereoBass, subs, subLs, subRs, lfeGain);
35
+ routeChannels (channelsMap, stereoBass, subs, subLs, subRs, lfeGain, centerGain );
35
36
// Add conditional routing to surrounds
36
37
parseExpandSurround (pBasicNode, channelsMap, path);
37
38
}
@@ -83,7 +84,7 @@ void Config::parseExpandSurround(const shared_ptr<JsonNode>& pBasicNode, const u
83
84
}
84
85
}
85
86
86
- void Config::routeChannels (const unordered_map<Channel, SpeakerType>& channelsMap, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain) {
87
+ void Config::routeChannels (const unordered_map<Channel, SpeakerType>& channelsMap, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain, const double centerGain ) {
87
88
for (size_t i = 0 ; i < _numChannelsIn; ++i) {
88
89
const Channel channel = (Channel)i;
89
90
Input input (channel);
@@ -100,15 +101,15 @@ void Config::routeChannels(const unordered_map<Channel, SpeakerType>& channelsMa
100
101
break ;
101
102
// Downmix
102
103
case SpeakerType::OFF:
103
- downmix (channelsMap, input, stereoBass, subs, subLs, subRs, lfeGain);
104
+ downmix (channelsMap, input, stereoBass, subs, subLs, subRs, lfeGain, centerGain );
104
105
break ;
105
106
// Sub or downmix
106
107
case SpeakerType::SUB:
107
108
if (channel == Channel::SW) {
108
109
addSwRoute (input, stereoBass, subs, subLs, subRs, lfeGain);
109
110
}
110
111
else {
111
- downmix (channelsMap, input, stereoBass, subs, subLs, subRs, lfeGain);
112
+ downmix (channelsMap, input, stereoBass, subs, subLs, subRs, lfeGain, centerGain );
112
113
}
113
114
break ;
114
115
default :
@@ -118,7 +119,7 @@ void Config::routeChannels(const unordered_map<Channel, SpeakerType>& channelsMa
118
119
}
119
120
}
120
121
121
- void Config::downmix (const unordered_map<Channel, SpeakerType>& channelsMap, Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain) const {
122
+ void Config::downmix (const unordered_map<Channel, SpeakerType>& channelsMap, Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain, const double centerGain ) const {
122
123
SpeakerType type = SpeakerType::OFF;
123
124
switch (input.getChannel ()) {
124
125
case Channel::SL:
@@ -133,11 +134,13 @@ void Config::downmix(const unordered_map<Channel, SpeakerType>& channelsMap, Inp
133
134
case Channel::SBR:
134
135
type = addRoute (channelsMap, input, { Channel::SR , Channel::R });
135
136
break ;
136
- case Channel::C:
137
- addRoute (input, Channel::L, PHANTOM_CENTER_GAIN);
138
- addRoute (input, Channel::R, PHANTOM_CENTER_GAIN);
137
+ case Channel::C: {
138
+ const double gain = PHANTOM_CENTER_GAIN + centerGain;
139
+ addRoute (input, Channel::L, gain);
140
+ addRoute (input, Channel::R, gain);
139
141
type = channelsMap.at (Channel::L);
140
142
break ;
143
+ }
141
144
case Channel::SW:
142
145
type = SpeakerType::SMALL;
143
146
break ;
@@ -146,13 +149,22 @@ void Config::downmix(const unordered_map<Channel, SpeakerType>& channelsMap, Inp
146
149
}
147
150
// Downmixed a small speaker. Add to subs as well.
148
151
if (type == SpeakerType::SMALL) {
149
- addBassRoute (input, stereoBass, subs, subLs, subRs, lfeGain);
152
+ addBassRoute (input, stereoBass, subs, subLs, subRs, lfeGain, centerGain );
150
153
}
151
154
}
152
155
153
- void Config::addBassRoute (Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain) const {
154
- const Channel channel = input.getChannel ();
155
- const double gain = (channel == Channel::SW ? lfeGain : 0 );
156
+ void Config::addBassRoute (Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain, const double centerGain) const {
157
+ double gain;
158
+ switch (input.getChannel ()) {
159
+ case Channel::SW:
160
+ gain = lfeGain;
161
+ break ;
162
+ case Channel::C:
163
+ gain = centerGain;
164
+ break ;
165
+ default :
166
+ gain = 0 ;
167
+ }
156
168
if (getUseSubwoofers (subs, subLs, subRs)) {
157
169
addSwRoute (input, stereoBass, subs, subLs, subRs, gain);
158
170
}
@@ -370,11 +382,9 @@ const vector<Channel> Config::getChannelsByType(const unordered_map<Channel, Spe
370
382
371
383
const double Config::getLfeGain (const shared_ptr<JsonNode>& pBasicNode, const bool useSubwoofers, const bool hasSmalls, const string& path) const {
372
384
const double lfeGain = tryGetDoubleValue (pBasicNode, " lfeGain" , path);
373
- if (useSubwoofers) {
374
- // Playing subwoofer and no small speakers. IE LFE is not going to get mixed with other channels.
375
- if (!hasSmalls) {
376
- return 0 ;
377
- }
385
+ // Playing subwoofer and no small speakers. IE LFE is not going to get mixed with other channels.
386
+ if (useSubwoofers && !hasSmalls) {
387
+ return 0 ;
378
388
}
379
389
return lfeGain + LFE_GAIN;
380
390
}
0 commit comments