| 2149 | } |
| 2150 | |
| 2151 | void FireAudioProcessor::setModulationValue(const juce::String& targetParameterID, float newValue) |
| 2152 | { |
| 2153 | // Find the matching routing in the LFO manager. |
| 2154 | for (auto& routing : lfoManager->getModulationRoutings()) |
| 2155 | { |
| 2156 | if (routing.targetParameterID == targetParameterID) |
| 2157 | { |
| 2158 | // Get the parameter object to access its properties, especially the range. |
| 2159 | auto* parameter = treeState.getParameter(targetParameterID); |
| 2160 | if (parameter == nullptr) |
| 2161 | return; // Exit if the parameter is not found. |
| 2162 | |
| 2163 | const auto range = parameter->getNormalisableRange(); |
| 2164 | |
| 2165 | // Get the parameter's current base value (without modulation). |
| 2166 | float baseValue = *treeState.getRawParameterValue(targetParameterID); |
| 2167 | |
| 2168 | // Convert both the target value and the base value to the normalized [0, 1] range. |
| 2169 | float valueNormalized = range.convertTo0to1(newValue); |
| 2170 | float baseNormalized = range.convertTo0to1(baseValue); |
| 2171 | |
| 2172 | // The new depth is the difference between the target value's normalized position |
| 2173 | // and the base value's normalized position. |
| 2174 | float newDepth = valueNormalized - baseNormalized; |
| 2175 | |
| 2176 | // In Bipolar mode, the DSP logic effectively halves the depth's impact |
| 2177 | // to create a symmetrical swing. To make our `newValue` the actual extreme |
| 2178 | // of that swing, we must pre-emptively double the calculated depth. |
| 2179 | if (routing.isBipolar) |
| 2180 | { |
| 2181 | newDepth *= 2.0f; |
| 2182 | } |
| 2183 | |
| 2184 | // Clamp the final depth to the valid range [-1.0, 1.0] and update the routing. |
| 2185 | routing.depth = juce::jlimit(-1.0f, 1.0f, newDepth); |
| 2186 | |
| 2187 | // Notify that LFO data has changed to ensure UI and state are updated. |
| 2188 | lfoDataHasChanged(); |
| 2189 | |
| 2190 | // We've found and updated the routing, so we can exit the function. |
| 2191 | return; |
| 2192 | } |
| 2193 | } |
| 2194 | } |
| 2195 | |
| 2196 | void FireAudioProcessor::setModulationDepth(const juce::String& targetParameterID, float newDepth) |
| 2197 | { |
no outgoing calls
no test coverage detected