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.

119 lines
5.2KB

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