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.

101 lines
3.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. #include "../JuceLibraryCode/JuceHeader.h"
  21. #include <array>
  22. // A simple Inter-App Audio plug-in with a gain control and some meters.
  23. class IAAEffectProcessor : public AudioProcessor
  24. {
  25. public:
  26. IAAEffectProcessor();
  27. ~IAAEffectProcessor();
  28. //==============================================================================
  29. void prepareToPlay (double sampleRate, int samplesPerBlock) override;
  30. void releaseResources() override;
  31. bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
  32. void processBlock (AudioSampleBuffer&, MidiBuffer&) override;
  33. //==============================================================================
  34. AudioProcessorEditor* createEditor() override;
  35. bool hasEditor() const override;
  36. //==============================================================================
  37. const String getName() const override;
  38. bool acceptsMidi() const override;
  39. bool producesMidi() const override;
  40. double getTailLengthSeconds() const override;
  41. //==============================================================================
  42. int getNumPrograms() override;
  43. int getCurrentProgram() override;
  44. void setCurrentProgram (int index) override;
  45. const String getProgramName (int index) override;
  46. void changeProgramName (int index, const String& newName) override;
  47. //==============================================================================
  48. void getStateInformation (MemoryBlock& destData) override;
  49. void setStateInformation (const void* data, int sizeInBytes) override;
  50. //==============================================================================
  51. bool updateCurrentTimeInfoFromHost (AudioPlayHead::CurrentPositionInfo&);
  52. // Allow an IAAAudioProcessorEditor to register as a listener to receive new
  53. // meter values directly from the audio thread.
  54. struct MeterListener
  55. {
  56. virtual ~MeterListener() {};
  57. virtual void handleNewMeterValue (int, float) = 0;
  58. };
  59. void addMeterListener (MeterListener& listener) { meterListeners.add (&listener); };
  60. void removeMeterListener (MeterListener& listener) { meterListeners.remove (&listener); };
  61. private:
  62. //==============================================================================
  63. AudioProcessorValueTreeState parameters;
  64. float previousGain = 0.0;
  65. std::array <float, 2> meterValues = { { 0, 0 } };
  66. // This keeps a copy of the last set of timing info that was acquired during an
  67. // audio callback - the UI component will display this.
  68. AudioPlayHead::CurrentPositionInfo lastPosInfo;
  69. ListenerList<MeterListener> meterListeners;
  70. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (IAAEffectProcessor)
  71. };