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.

97 lines
3.2KB

  1. /*
  2. ==============================================================================
  3. This file was auto-generated!
  4. It contains the basic framework code for a JUCE plugin processor.
  5. ==============================================================================
  6. */
  7. #pragma once
  8. #include "../JuceLibraryCode/JuceHeader.h"
  9. #include "PS_Source/PaulStretchControl.h"
  10. //==============================================================================
  11. /**
  12. */
  13. class PaulstretchpluginAudioProcessor : public AudioProcessor
  14. {
  15. public:
  16. //==============================================================================
  17. PaulstretchpluginAudioProcessor();
  18. ~PaulstretchpluginAudioProcessor();
  19. //==============================================================================
  20. void prepareToPlay (double sampleRate, int samplesPerBlock) override;
  21. void releaseResources() override;
  22. #ifndef JucePlugin_PreferredChannelConfigurations
  23. bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
  24. #endif
  25. void processBlock (AudioSampleBuffer&, MidiBuffer&) override;
  26. //==============================================================================
  27. AudioProcessorEditor* createEditor() override;
  28. bool hasEditor() const override;
  29. //==============================================================================
  30. const String getName() const override;
  31. bool acceptsMidi() const override;
  32. bool producesMidi() const override;
  33. bool isMidiEffect () const override;
  34. double getTailLengthSeconds() const override;
  35. //==============================================================================
  36. int getNumPrograms() override;
  37. int getCurrentProgram() override;
  38. void setCurrentProgram (int index) override;
  39. const String getProgramName (int index) override;
  40. void changeProgramName (int index, const String& newName) override;
  41. //==============================================================================
  42. void getStateInformation (MemoryBlock& destData) override;
  43. void setStateInformation (const void* data, int sizeInBytes) override;
  44. AudioParameterFloat* getFloatParameter(int index)
  45. {
  46. return dynamic_cast<AudioParameterFloat*>(getParameters()[index]);
  47. }
  48. void setRecordingEnabled(bool b);
  49. bool isRecordingEnabled() { return m_is_recording; }
  50. double getRecordingPositionPercent();
  51. String setAudioFile(File f);
  52. File getAudioFile() { return m_current_file; }
  53. std::unique_ptr<AudioFormatManager> m_afm;
  54. std::unique_ptr<Control> m_control;
  55. private:
  56. bool m_ready_to_play = false;
  57. AudioBuffer<float> m_recbuffer;
  58. double m_max_reclen = 5;
  59. bool m_is_recording = false;
  60. int m_rec_pos = 0;
  61. void finishRecording(int lenrecorded);
  62. bool m_using_memory_buffer = false;
  63. int m_cur_num_out_chans = 2;
  64. std::mutex m_mutex;
  65. File m_current_file;
  66. template<typename F>
  67. void callGUI(F&& f, bool async)
  68. {
  69. auto ed = dynamic_cast<PaulstretchpluginAudioProcessorEditor*>(getActiveEditor());
  70. if (ed)
  71. {
  72. if (async == false)
  73. f(ed);
  74. else
  75. MessageManager::callAsync([ed,f]() { f(ed); });
  76. }
  77. }
  78. //==============================================================================
  79. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
  80. };