| 1702 | } |
| 1703 | |
| 1704 | void FireAudioProcessor::splitBands(const juce::AudioBuffer<float>& inputBuffer, double sampleRate) |
| 1705 | { |
| 1706 | // This function encapsulates the entire multiband crossover logic. |
| 1707 | // The code is moved directly from your original processBlock. |
| 1708 | |
| 1709 | const int totalNumOutputChannels = getTotalNumOutputChannels(); |
| 1710 | const int numSamples = inputBuffer.getNumSamples(); |
| 1711 | |
| 1712 | if (sampleRate <= 0) |
| 1713 | return; |
| 1714 | const int lineNum = activeCrossovers; // Use the member variable updated in updateParameters() |
| 1715 | |
| 1716 | // Get the latest smoothed frequency values for the crossovers |
| 1717 | float freqValue1 = smoothedFreq1.getNextValue(); |
| 1718 | float freqValue2 = smoothedFreq2.getNextValue(); |
| 1719 | float freqValue3 = smoothedFreq3.getNextValue(); |
| 1720 | |
| 1721 | const float minFreq = 20.0f; |
| 1722 | float maxFreq = sampleRate / 2.0f; |
| 1723 | |
| 1724 | if (maxFreq < minFreq) |
| 1725 | { |
| 1726 | maxFreq = minFreq; |
| 1727 | } |
| 1728 | |
| 1729 | freqValue1 = juce::jlimit(minFreq, maxFreq, freqValue1); |
| 1730 | freqValue2 = juce::jlimit(minFreq, maxFreq, freqValue2); |
| 1731 | freqValue3 = juce::jlimit(minFreq, maxFreq, freqValue3); |
| 1732 | |
| 1733 | // Set up crossover filters with these frequencies |
| 1734 | lowpass1.setCutoffFrequency(freqValue1); |
| 1735 | highpass1.setCutoffFrequency(freqValue1); |
| 1736 | lowpass2.setCutoffFrequency(freqValue2); |
| 1737 | highpass2.setCutoffFrequency(freqValue2); |
| 1738 | lowpass3.setCutoffFrequency(freqValue3); |
| 1739 | highpass3.setCutoffFrequency(freqValue3); |
| 1740 | |
| 1741 | // Set up the all-pass coefficients for 3-band compensation |
| 1742 | if (lineNum == 2) |
| 1743 | { |
| 1744 | compensatorLP.setCutoffFrequency(freqValue1); |
| 1745 | compensatorHP.setCutoffFrequency(freqValue1); |
| 1746 | } |
| 1747 | |
| 1748 | // --- TREE-BASED SIGNAL SPLITTING --- |
| 1749 | if (lineNum == 0) |
| 1750 | { // 1 Band: No splitting, the signal just passes through |
| 1751 | mBuffer1.makeCopyOf(inputBuffer); |
| 1752 | } |
| 1753 | else if (lineNum == 1) |
| 1754 | { // 2 Bands: One split |
| 1755 | mBuffer1.makeCopyOf(inputBuffer); |
| 1756 | mBuffer2.makeCopyOf(inputBuffer); |
| 1757 | |
| 1758 | auto block1 = juce::dsp::AudioBlock<float>(mBuffer1); |
| 1759 | auto context1 = juce::dsp::ProcessContextReplacing<float>(block1); |
| 1760 | lowpass1.process(context1); |
| 1761 |
nothing calls this directly
no test coverage detected