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.

104 lines
3.6KB

  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. class MyThumbCache;
  11. class PaulstretchpluginAudioProcessor : public AudioProcessor
  12. {
  13. public:
  14. //==============================================================================
  15. PaulstretchpluginAudioProcessor();
  16. ~PaulstretchpluginAudioProcessor();
  17. //==============================================================================
  18. void prepareToPlay (double sampleRate, int samplesPerBlock) override;
  19. void releaseResources() override;
  20. #ifndef JucePlugin_PreferredChannelConfigurations
  21. bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
  22. #endif
  23. void processBlock (AudioSampleBuffer&, MidiBuffer&) override;
  24. //==============================================================================
  25. AudioProcessorEditor* createEditor() override;
  26. bool hasEditor() const override;
  27. //==============================================================================
  28. const String getName() const override;
  29. bool acceptsMidi() const override;
  30. bool producesMidi() const override;
  31. bool isMidiEffect () const override;
  32. double getTailLengthSeconds() const override;
  33. //==============================================================================
  34. int getNumPrograms() override;
  35. int getCurrentProgram() override;
  36. void setCurrentProgram (int index) override;
  37. const String getProgramName (int index) override;
  38. void changeProgramName (int index, const String& newName) override;
  39. //==============================================================================
  40. void getStateInformation (MemoryBlock& destData) override;
  41. void setStateInformation (const void* data, int sizeInBytes) override;
  42. AudioParameterFloat* getFloatParameter(int index)
  43. {
  44. return dynamic_cast<AudioParameterFloat*>(getParameters()[index]);
  45. }
  46. void setRecordingEnabled(bool b);
  47. bool isRecordingEnabled() { return m_is_recording; }
  48. double getRecordingPositionPercent();
  49. String setAudioFile(File f);
  50. File getAudioFile() { return m_current_file; }
  51. Range<double> getTimeSelection();
  52. SharedResourcePointer<AudioFormatManager> m_afm;
  53. StretchAudioSource* getStretchSource() { return m_stretch_source.get(); }
  54. double getPreBufferingPercent();
  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 = true;
  63. int m_cur_num_out_chans = 2;
  64. std::mutex m_mutex;
  65. File m_current_file;
  66. TimeSliceThread m_bufferingthread;
  67. std::unique_ptr<StretchAudioSource> m_stretch_source;
  68. std::unique_ptr<MyBufferingAudioSource> m_buffering_source;
  69. int m_prebuffer_amount = 1;
  70. bool m_recreate_buffering_source = true;
  71. int m_fft_size_to_use = 1024;
  72. double m_last_outpos_pos = 0.0;
  73. double m_last_in_pos = 0.0;
  74. std::vector<int> m_bufamounts{ 4096,8192,16384,32768,65536,262144 };
  75. ProcessParameters m_ppar;
  76. void setPreBufferAmount(int x);
  77. void setFFTSize(double size);
  78. void startplay(Range<double> playrange, int numoutchans, String& err);
  79. SharedResourcePointer<MyThumbCache> m_thumbcache;
  80. //==============================================================================
  81. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
  82. };