| 379 | } |
| 380 | |
| 381 | void LfoManager::assignLfoToTarget(int sourceLfoIndex, const juce::String& targetParameterID) |
| 382 | { |
| 383 | const juce::ScopedLock sl(dataAccessLock); |
| 384 | // 1. First, check if the target parameter is already being modulated. |
| 385 | // If so, just update its LFO source. |
| 386 | for (auto& routing : modulationRoutings) |
| 387 | { |
| 388 | if (routing.targetParameterID == targetParameterID) |
| 389 | { |
| 390 | routing.sourceLfoIndex = sourceLfoIndex; |
| 391 | return; // Assignment complete. |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | // 2. If the target is not modulated, find the first available empty slot. |
| 396 | for (auto& routing : modulationRoutings) |
| 397 | { |
| 398 | if (routing.targetParameterID.isEmpty()) |
| 399 | { |
| 400 | routing.sourceLfoIndex = sourceLfoIndex; |
| 401 | routing.targetParameterID = targetParameterID; |
| 402 | if (juce::approximatelyEqual(routing.depth, 0.0f)) |
| 403 | routing.depth = 0.5f; // Set a sensible default depth. |
| 404 | return; // Assignment complete. |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | // 3. If all existing slots are full, dynamically add a new one. |
| 409 | |
| 410 | // Step 1: Add a new, default-constructed ModulationRouting object to the array. |
| 411 | modulationRoutings.add({}); |
| 412 | |
| 413 | // Step 2: Get a reference to the last element. |
| 414 | auto& newRouting = modulationRoutings.getReference(modulationRoutings.size() - 1); |
| 415 | |
| 416 | // Step 3: Configure the new routing slot. |
| 417 | newRouting.sourceLfoIndex = sourceLfoIndex; |
| 418 | newRouting.targetParameterID = targetParameterID; |
| 419 | newRouting.depth = 0.5f; // Set a sensible default depth. |
| 420 | } |
| 421 | |
| 422 | void LfoManager::clearModulationForTarget(const juce::String& targetParameterID) |
| 423 | { |
no outgoing calls
no test coverage detected