| 1230 | } |
| 1231 | |
| 1232 | void FireAudioProcessor::updateFilter(double sampleRate) |
| 1233 | { |
| 1234 | auto chainSettings = getChainSettings(treeState); |
| 1235 | const float minFreq = 20.0f; |
| 1236 | if (sampleRate <= 0) |
| 1237 | return; |
| 1238 | |
| 1239 | float maxFreq = sampleRate / 2.0f; |
| 1240 | |
| 1241 | if (maxFreq < minFreq) |
| 1242 | { |
| 1243 | maxFreq = minFreq; |
| 1244 | } |
| 1245 | |
| 1246 | chainSettings.lowCutFreq = juce::jlimit(minFreq, maxFreq, chainSettings.lowCutFreq); |
| 1247 | chainSettings.peakFreq = juce::jlimit(minFreq, maxFreq, chainSettings.peakFreq); |
| 1248 | chainSettings.highCutFreq = juce::jlimit(minFreq, maxFreq, chainSettings.highCutFreq); |
| 1249 | |
| 1250 | // Set the target values for all 9 smoothers |
| 1251 | lowcutFreqSmoother.setTargetValue(chainSettings.lowCutFreq); |
| 1252 | lowcutGainSmoother.setTargetValue(chainSettings.lowCutGainInDecibels); |
| 1253 | lowcutQualitySmoother.setTargetValue(chainSettings.lowCutQuality); |
| 1254 | |
| 1255 | peakFreqSmoother.setTargetValue(chainSettings.peakFreq); |
| 1256 | peakGainSmoother.setTargetValue(chainSettings.peakGainInDecibels); |
| 1257 | peakQualitySmoother.setTargetValue(chainSettings.peakQuality); |
| 1258 | |
| 1259 | highcutFreqSmoother.setTargetValue(chainSettings.highCutFreq); |
| 1260 | highcutGainSmoother.setTargetValue(chainSettings.highCutGainInDecibels); |
| 1261 | highcutQualitySmoother.setTargetValue(chainSettings.highCutQuality); |
| 1262 | |
| 1263 | // Create a new settings object with the smoothed values for this audio block |
| 1264 | ChainSettings smoothedSettings; |
| 1265 | smoothedSettings.lowCutFreq = lowcutFreqSmoother.getNextValue(); |
| 1266 | smoothedSettings.lowCutGainInDecibels = lowcutGainSmoother.getNextValue(); |
| 1267 | smoothedSettings.lowCutQuality = lowcutQualitySmoother.getNextValue(); |
| 1268 | |
| 1269 | smoothedSettings.peakFreq = peakFreqSmoother.getNextValue(); |
| 1270 | smoothedSettings.peakGainInDecibels = peakGainSmoother.getNextValue(); |
| 1271 | smoothedSettings.peakQuality = peakQualitySmoother.getNextValue(); |
| 1272 | |
| 1273 | // Get the smoothed high-cut frequency value. |
| 1274 | float highCutFreqValue = highcutFreqSmoother.getNextValue(); |
| 1275 | // Define the Nyquist frequency. |
| 1276 | const float nyquist = (float) sampleRate / 2.0f; |
| 1277 | // Clamp the high-cut frequency to ensure it never exceeds the Nyquist frequency. |
| 1278 | smoothedSettings.highCutFreq = juce::jmin(highCutFreqValue, nyquist); |
| 1279 | |
| 1280 | smoothedSettings.highCutGainInDecibels = highcutGainSmoother.getNextValue(); |
| 1281 | smoothedSettings.highCutQuality = highcutQualitySmoother.getNextValue(); |
| 1282 | |
| 1283 | // Slopes and bypass states don't need smoothing, use them directly |
| 1284 | smoothedSettings.lowCutSlope = chainSettings.lowCutSlope; |
| 1285 | smoothedSettings.highCutSlope = chainSettings.highCutSlope; |
| 1286 | smoothedSettings.lowCutBypassed = chainSettings.lowCutBypassed; |
| 1287 | smoothedSettings.peakBypassed = chainSettings.peakBypassed; |
| 1288 | smoothedSettings.highCutBypassed = chainSettings.highCutBypassed; |
| 1289 |
nothing calls this directly
no test coverage detected