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.

87 lines
3.0KB

  1. /* Copyright 2013-2019 Matt Tytel
  2. *
  3. * pylon is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * pylon is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with pylon. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include "JuceHeader.h"
  18. #include "synth_base.h"
  19. #include "value_bridge.h"
  20. class ValueBridge;
  21. class SynthPlugin : public SynthBase, public AudioProcessor, public ValueBridge::Listener {
  22. public:
  23. static constexpr int kSetProgramWaitMilliseconds = 500;
  24. SynthPlugin();
  25. virtual ~SynthPlugin();
  26. #if ! JUCE_AUDIOPROCESSOR_NO_GUI
  27. SynthGuiInterface* getGuiInterface() override;
  28. void beginChangeGesture(const std::string& name) override;
  29. void endChangeGesture(const std::string& name) override;
  30. void setValueNotifyHost(const std::string& name, vital::mono_float value) override;
  31. #endif
  32. const CriticalSection& getCriticalSection() override;
  33. void pauseProcessing(bool pause) override;
  34. void prepareToPlay(double sample_rate, int buffer_size) override;
  35. void releaseResources() override;
  36. void processBlock(AudioSampleBuffer&, MidiBuffer&) override;
  37. #if ! JUCE_AUDIOPROCESSOR_NO_GUI
  38. AudioProcessorEditor* createEditor() override;
  39. bool hasEditor() const override;
  40. #endif
  41. const String getName() const override;
  42. bool supportsMPE() const override { return true; }
  43. const String getInputChannelName(int channel_index) const override;
  44. const String getOutputChannelName(int channel_index) const override;
  45. bool isInputChannelStereoPair(int index) const override;
  46. bool isOutputChannelStereoPair(int index) const override;
  47. bool acceptsMidi() const override;
  48. bool producesMidi() const override;
  49. bool silenceInProducesSilenceOut() const override;
  50. double getTailLengthSeconds() const override;
  51. int getNumPrograms() override { return 1; }
  52. int getCurrentProgram() override { return 0; }
  53. void setCurrentProgram(int index) override { }
  54. const String getProgramName(int index) override;
  55. void changeProgramName(int index, const String& new_name) override { }
  56. void getStateInformation(MemoryBlock& destData) override;
  57. void setStateInformation(const void* data, int size_in_bytes) override;
  58. AudioProcessorParameter* getBypassParameter() const override { return bypass_parameter_; }
  59. void parameterChanged(std::string name, vital::mono_float value) override;
  60. private:
  61. ValueBridge* bypass_parameter_;
  62. double last_seconds_time_;
  63. AudioPlayHead::CurrentPositionInfo position_info_;
  64. std::map<std::string, ValueBridge*> bridge_lookup_;
  65. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SynthPlugin)
  66. };