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.

120 lines
5.3KB

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