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.

139 lines
4.7KB

  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. const int cpi_main_volume = 0;
  12. const int cpi_stretchamount = 1;
  13. const int cpi_fftsize = 2;
  14. const int cpi_pitchshift = 3;
  15. const int cpi_frequencyshift = 4;
  16. const int cpi_soundstart = 5;
  17. const int cpi_soundend = 6;
  18. const int cpi_freeze = 7;
  19. const int cpi_spreadamount = 8;
  20. const int cpi_compress = 9;
  21. const int cpi_loopxfadelen = 10;
  22. const int cpi_numharmonics = 11;
  23. const int cpi_harmonicsfreq = 12;
  24. const int cpi_harmonicsbw = 13;
  25. const int cpi_harmonicsgauss = 14;
  26. const int cpi_octavesm2 = 15;
  27. const int cpi_octavesm1 = 16;
  28. const int cpi_octaves0 = 17;
  29. const int cpi_octaves1 = 18;
  30. const int cpi_octaves15 = 19;
  31. const int cpi_octaves2 = 20;
  32. const int cpi_tonalvsnoisebw = 21;
  33. const int cpi_tonalvsnoisepreserve = 22;
  34. const int cpi_filter_low = 23;
  35. const int cpi_filter_high = 24;
  36. const int cpi_onsetdetection = 25;
  37. const int cpi_capture_enabled = 26;
  38. const int cpi_num_outchans = 27;
  39. const int cpi_pause_enabled = 28;
  40. class PaulstretchpluginAudioProcessor : public AudioProcessor, public MultiTimer
  41. {
  42. public:
  43. //==============================================================================
  44. PaulstretchpluginAudioProcessor();
  45. ~PaulstretchpluginAudioProcessor();
  46. //==============================================================================
  47. void prepareToPlay (double sampleRate, int samplesPerBlock) override;
  48. void releaseResources() override;
  49. #ifndef JucePlugin_PreferredChannelConfigurations
  50. bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
  51. #endif
  52. void processBlock (AudioSampleBuffer&, MidiBuffer&) override;
  53. //==============================================================================
  54. AudioProcessorEditor* createEditor() override;
  55. bool hasEditor() const override;
  56. //==============================================================================
  57. const String getName() const override;
  58. bool acceptsMidi() const override;
  59. bool producesMidi() const override;
  60. bool isMidiEffect () const override;
  61. double getTailLengthSeconds() const override;
  62. //==============================================================================
  63. int getNumPrograms() override;
  64. int getCurrentProgram() override;
  65. void setCurrentProgram (int index) override;
  66. const String getProgramName (int index) override;
  67. void changeProgramName (int index, const String& newName) override;
  68. //==============================================================================
  69. void getStateInformation (MemoryBlock& destData) override;
  70. void setStateInformation (const void* data, int sizeInBytes) override;
  71. AudioParameterFloat* getFloatParameter(int index)
  72. {
  73. return dynamic_cast<AudioParameterFloat*>(getParameters()[index]);
  74. }
  75. void setRecordingEnabled(bool b);
  76. bool isRecordingEnabled() { return m_is_recording; }
  77. double getRecordingPositionPercent();
  78. String setAudioFile(File f);
  79. File getAudioFile() { return m_current_file; }
  80. Range<double> getTimeSelection();
  81. SharedResourcePointer<AudioFormatManager> m_afm;
  82. StretchAudioSource* getStretchSource() { return m_stretch_source.get(); }
  83. double getPreBufferingPercent();
  84. void timerCallback(int id) override;
  85. double getSampleRateChecked();
  86. private:
  87. bool m_ready_to_play = false;
  88. AudioBuffer<float> m_recbuffer;
  89. double m_max_reclen = 10.0;
  90. bool m_is_recording = false;
  91. int m_rec_pos = 0;
  92. void finishRecording(int lenrecorded);
  93. bool m_using_memory_buffer = true;
  94. int m_cur_num_out_chans = 2;
  95. CriticalSection m_cs;
  96. File m_current_file;
  97. Time m_current_file_date;
  98. TimeSliceThread m_bufferingthread;
  99. std::unique_ptr<StretchAudioSource> m_stretch_source;
  100. std::unique_ptr<MyBufferingAudioSource> m_buffering_source;
  101. int m_prebuffer_amount = 1;
  102. bool m_recreate_buffering_source = true;
  103. int m_fft_size_to_use = 1024;
  104. double m_last_outpos_pos = 0.0;
  105. double m_last_in_pos = 0.0;
  106. std::vector<int> m_bufamounts{ 4096,8192,16384,32768,65536,262144 };
  107. ProcessParameters m_ppar;
  108. void setPreBufferAmount(int x);
  109. void setFFTSize(double size);
  110. void startplay(Range<double> playrange, int numoutchans, int maxBlockSize, String& err);
  111. SharedResourcePointer<MyThumbCache> m_thumbcache;
  112. AudioParameterInt* m_outchansparam = nullptr;
  113. int m_curmaxblocksize = 0;
  114. double m_cur_sr = 0.0;
  115. //==============================================================================
  116. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
  117. };