| 579 | } |
| 580 | |
| 581 | void FireAudioProcessorEditor::timerCallback() |
| 582 | { |
| 583 | if (isLfoAssignMode) |
| 584 | { |
| 585 | // Increment the angle for the sine wave animation |
| 586 | assignModePulseAngle += 0.05f; |
| 587 | if (assignModePulseAngle > juce::MathConstants<float>::twoPi) |
| 588 | assignModePulseAngle -= juce::MathConstants<float>::twoPi; |
| 589 | |
| 590 | // Calculate a smooth alpha value using a sine wave, mapped to a pleasant range (e.g., 0.1 to 0.4) |
| 591 | float minAlpha = 0.1f; |
| 592 | float maxAlpha = 0.4f; |
| 593 | assignModePulseAlpha = minAlpha + (maxAlpha - minAlpha) * ((std::sin(assignModePulseAngle) + 1.0f) / 2.0f); |
| 594 | |
| 595 | // Pass the new alpha value to all modulatable sliders |
| 596 | for (auto* slider : bandPanel.getModulatableSliders()) |
| 597 | slider->assignModeGlowAlpha = assignModePulseAlpha; |
| 598 | for (auto* slider : globalPanel.getModulatableSliders()) |
| 599 | slider->assignModeGlowAlpha = assignModePulseAlpha; |
| 600 | |
| 601 | // Repaint the panels on every frame to ensure smooth animation |
| 602 | bandPanel.repaint(); |
| 603 | globalPanel.repaint(); |
| 604 | } |
| 605 | |
| 606 | auto updateSliderState = [&](ModulatableSlider& slider) |
| 607 | { |
| 608 | if (slider.parameterID.isEmpty()) |
| 609 | return; |
| 610 | |
| 611 | auto modInfo = processor.getModulationInfoForParameter(slider.parameterID); |
| 612 | slider.isModulated = modInfo.isModulated; |
| 613 | |
| 614 | // Always update the values. If not modulated, depth will be 0 from getModulationInfoForParameter. |
| 615 | slider.lfoSource = modInfo.sourceLfoIndex; |
| 616 | slider.lfoAmount = modInfo.depth; |
| 617 | slider.lfoValue = modInfo.currentValue; |
| 618 | slider.isBipolar = modInfo.isBipolar; |
| 619 | }; |
| 620 | |
| 621 | // Loop through the public list of modulatable sliders from the bandPanel. |
| 622 | // This is much cleaner and automatically adapts to any new sliders you add. |
| 623 | for (auto* slider : bandPanel.getModulatableSliders()) |
| 624 | { |
| 625 | if (slider != nullptr) // A good safety check |
| 626 | { |
| 627 | updateSliderState(*slider); |
| 628 | } |
| 629 | } |
| 630 | // Repaint the entire panel once, which is more efficient than repainting individual sliders. |
| 631 | bandPanel.repaint(); |
| 632 | |
| 633 | for (auto* slider : globalPanel.getModulatableSliders()) |
| 634 | { |
| 635 | if (slider != nullptr) |
| 636 | { |
| 637 | updateSliderState(*slider); |
| 638 | } |
nothing calls this directly
no test coverage detected