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.

114 lines
4.9KB

  1. /*
  2. ==============================================================================
  3. This file was auto-generated by the Jucer!
  4. It contains the basic startup code for a Juce application.
  5. ==============================================================================
  6. */
  7. #ifndef __PLUGINPROCESSOR_H_526ED7A9__
  8. #define __PLUGINPROCESSOR_H_526ED7A9__
  9. #include "../JuceLibraryCode/JuceHeader.h"
  10. //==============================================================================
  11. /**
  12. As the name suggest, this class does the actual audio processing.
  13. */
  14. class JuceDemoPluginAudioProcessor : public AudioProcessor
  15. {
  16. public:
  17. //==============================================================================
  18. JuceDemoPluginAudioProcessor();
  19. ~JuceDemoPluginAudioProcessor();
  20. //==============================================================================
  21. bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
  22. void prepareToPlay (double sampleRate, int samplesPerBlock) override;
  23. void releaseResources() override;
  24. void reset() override;
  25. //==============================================================================
  26. void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) override
  27. {
  28. jassert (! isUsingDoublePrecision());
  29. process (buffer, midiMessages, delayBufferFloat);
  30. }
  31. void processBlock (AudioBuffer<double>& buffer, MidiBuffer& midiMessages) override
  32. {
  33. jassert (isUsingDoublePrecision());
  34. process (buffer, midiMessages, delayBufferDouble);
  35. }
  36. //==============================================================================
  37. bool hasEditor() const override { return true; }
  38. AudioProcessorEditor* createEditor() override;
  39. //==============================================================================
  40. const String getName() const override { return JucePlugin_Name; }
  41. bool acceptsMidi() const override { return true; }
  42. bool producesMidi() const override { return true; }
  43. double getTailLengthSeconds() const override { return 0.0; }
  44. //==============================================================================
  45. int getNumPrograms() override { return 0; }
  46. int getCurrentProgram() override { return 0; }
  47. void setCurrentProgram (int /*index*/) override {}
  48. const String getProgramName (int /*index*/) override { return String(); }
  49. void changeProgramName (int /*index*/, const String& /*name*/) override {}
  50. //==============================================================================
  51. void getStateInformation (MemoryBlock&) override;
  52. void setStateInformation (const void* data, int sizeInBytes) override;
  53. //==============================================================================
  54. // These properties are public so that our editor component can access them
  55. // A bit of a hacky way to do it, but it's only a demo! Obviously in your own
  56. // code you'll do this much more neatly..
  57. // this is kept up to date with the midi messages that arrive, and the UI component
  58. // registers with it so it can represent the incoming messages
  59. MidiKeyboardState keyboardState;
  60. // this keeps a copy of the last set of time info that was acquired during an audio
  61. // callback - the UI component will read this and display it.
  62. AudioPlayHead::CurrentPositionInfo lastPosInfo;
  63. // these are used to persist the UI's size - the values are stored along with the
  64. // filter's other parameters, and the UI component will update them when it gets
  65. // resized.
  66. int lastUIWidth, lastUIHeight;
  67. // Our parameters
  68. AudioParameterFloat* gainParam;
  69. AudioParameterFloat* delayParam;
  70. private:
  71. //==============================================================================
  72. template <typename FloatType>
  73. void process (AudioBuffer<FloatType>& buffer, MidiBuffer& midiMessages, AudioBuffer<FloatType>& delayBuffer);
  74. template <typename FloatType>
  75. void applyGain (AudioBuffer<FloatType>&, AudioBuffer<FloatType>& delayBuffer);
  76. template <typename FloatType>
  77. void applyDelay (AudioBuffer<FloatType>&, AudioBuffer<FloatType>& delayBuffer);
  78. AudioBuffer<float> delayBufferFloat;
  79. AudioBuffer<double> delayBufferDouble;
  80. int delayPosition;
  81. Synthesiser synth;
  82. void initialiseSynth();
  83. void updateCurrentTimeInfoFromHost();
  84. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceDemoPluginAudioProcessor)
  85. };
  86. #endif // __PLUGINPROCESSOR_H_526ED7A9__