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.

113 lines
4.8KB

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