The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. namespace dsp
  16. {
  17. /**
  18. Acts as a polymorphic base class for processors.
  19. This exposes the same set of methods that a processor must implement as virtual
  20. methods, so that you can use the ProcessorWrapper class to wrap an instance of
  21. a subclass, and then pass that around using ProcessorBase as a base class.
  22. @see ProcessorWrapper
  23. @tags{DSP}
  24. */
  25. struct ProcessorBase
  26. {
  27. ProcessorBase() = default;
  28. virtual ~ProcessorBase() = default;
  29. virtual void prepare (const ProcessSpec&) = 0;
  30. virtual void process (const ProcessContextReplacing<float>&) = 0;
  31. virtual void reset() = 0;
  32. };
  33. //==============================================================================
  34. /**
  35. Wraps an instance of a given processor class, and exposes it through the
  36. ProcessorBase interface.
  37. @see ProcessorBase
  38. @tags{DSP}
  39. */
  40. template <typename ProcessorType>
  41. struct ProcessorWrapper : public ProcessorBase
  42. {
  43. void prepare (const ProcessSpec& spec) override
  44. {
  45. processor.prepare (spec);
  46. }
  47. void process (const ProcessContextReplacing<float>& context) override
  48. {
  49. processor.process (context);
  50. }
  51. void reset() override
  52. {
  53. processor.reset();
  54. }
  55. ProcessorType processor;
  56. };
  57. } // namespace dsp
  58. } // namespace juce