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.

103 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. //==============================================================================
  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. Range<double> getTimeSelection();
  54. std::unique_ptr<AudioFormatManager> m_afm;
  55. StretchAudioSource* getStretchSource() { return m_stretch_source.get(); }
  56. double getPreBufferingPercent();
  57. private:
  58. bool m_ready_to_play = false;
  59. AudioBuffer<float> m_recbuffer;
  60. double m_max_reclen = 5;
  61. bool m_is_recording = false;
  62. int m_rec_pos = 0;
  63. void finishRecording(int lenrecorded);
  64. bool m_using_memory_buffer = true;
  65. int m_cur_num_out_chans = 2;
  66. std::mutex m_mutex;
  67. File m_current_file;
  68. TimeSliceThread m_bufferingthread;
  69. std::unique_ptr<StretchAudioSource> m_stretch_source;
  70. std::unique_ptr<MyBufferingAudioSource> m_buffering_source;
  71. int m_prebuffer_amount = 1;
  72. bool m_recreate_buffering_source = true;
  73. int m_fft_size_to_use = 1024;
  74. double m_last_outpos_pos = 0.0;
  75. double m_last_in_pos = 0.0;
  76. std::vector<int> m_bufamounts{ 4096,8192,16384,32768,65536,262144 };
  77. ProcessParameters m_ppar;
  78. void setPreBufferAmount(int x);
  79. void setFFTSize(double size);
  80. void startplay(Range<double> playrange, int numoutchans, String& err);
  81. //==============================================================================
  82. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
  83. };