CMLSProcessorChain.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. ==============================================================================
  3. CMLSProcessorChain.cpp
  4. Created: 12 May 2025 10:05:40am
  5. Author: Luigi
  6. ==============================================================================
  7. */
  8. #include "CMLSProcessorChain.h"
  9. CMLSProcessorChain::CMLSProcessorChain()
  10. {}
  11. CMLSProcessorChain::~CMLSProcessorChain()
  12. {}
  13. void CMLSProcessorChain::reset()
  14. {
  15. for (auto& processor : chain)
  16. {
  17. if (processor)
  18. processor->reset();
  19. }
  20. }
  21. void CMLSProcessorChain::prepare(const juce::dsp::ProcessSpec& spec)
  22. {
  23. for (auto& processor : chain)
  24. {
  25. if (processor)
  26. processor->prepare(spec);
  27. }
  28. }
  29. void CMLSProcessorChain::process(const juce::dsp::ProcessContextReplacing<float>& context)
  30. {
  31. for (int i = 0; i < this->chain.size(); ++i)
  32. {
  33. if (this->chain[i] && this->slots[i] == true)
  34. this->chain[i]->process(context);
  35. }
  36. }
  37. int CMLSProcessorChain::pushProcessor(juce::dsp::ProcessorBase& processor)
  38. {
  39. chain.push_back(&processor);
  40. slots.push_back(true);
  41. return chain.size() - 1;
  42. }
  43. void CMLSProcessorChain::muteProcessrInSlot(int slot)
  44. {
  45. slots[slot] = false;
  46. }
  47. void CMLSProcessorChain::unmuteProcessorInSlot(int slot)
  48. {
  49. slots[slot] = true;
  50. }
  51. void CMLSProcessorChain::swapPlaces(int slot1, int slot2)
  52. {
  53. if (slot1 < 0 || slot2 < 0 || slot1 >= chain.size() || slot2 >= chain.size())
  54. return;
  55. std::swap(chain[slot1], chain[slot2]);
  56. std::swap(slots[slot1], slots[slot2]);
  57. }