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.

562 lines
19KB

  1. /*
  2. ==============================================================================
  3. This file was auto-generated!
  4. It contains the basic framework code for a JUCE plugin processor.
  5. ==============================================================================
  6. */
  7. #include "PluginProcessor.h"
  8. #include "PluginEditor.h"
  9. #include <set>
  10. #ifdef WIN32
  11. #undef min
  12. #undef max
  13. #endif
  14. std::set<PaulstretchpluginAudioProcessor*> g_activeprocessors;
  15. template<typename F>
  16. void callGUI(AudioProcessor* ap, F&& f, bool async)
  17. {
  18. auto ed = dynamic_cast<PaulstretchpluginAudioProcessorEditor*>(ap->getActiveEditor());
  19. if (ed)
  20. {
  21. if (async == false)
  22. f(ed);
  23. else
  24. MessageManager::callAsync([ed,f]() { f(ed); });
  25. }
  26. }
  27. int get_optimized_updown(int n, bool up) {
  28. int orig_n = n;
  29. while (true) {
  30. n = orig_n;
  31. while (!(n % 11)) n /= 11;
  32. while (!(n % 7)) n /= 7;
  33. while (!(n % 5)) n /= 5;
  34. while (!(n % 3)) n /= 3;
  35. while (!(n % 2)) n /= 2;
  36. if (n<2) break;
  37. if (up) orig_n++;
  38. else orig_n--;
  39. if (orig_n<4) return 4;
  40. };
  41. return orig_n;
  42. };
  43. int optimizebufsize(int n) {
  44. int n1 = get_optimized_updown(n, false);
  45. int n2 = get_optimized_updown(n, true);
  46. if ((n - n1)<(n2 - n)) return n1;
  47. else return n2;
  48. };
  49. //==============================================================================
  50. PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
  51. : m_bufferingthread("pspluginprebufferthread")
  52. #ifndef JucePlugin_PreferredChannelConfigurations
  53. : AudioProcessor (BusesProperties()
  54. #if ! JucePlugin_IsMidiEffect
  55. #if ! JucePlugin_IsSynth
  56. .withInput ("Input", AudioChannelSet::stereo(), true)
  57. #endif
  58. .withOutput ("Output", AudioChannelSet::stereo(), true)
  59. #endif
  60. )
  61. #endif
  62. {
  63. g_activeprocessors.insert(this);
  64. m_recbuffer.setSize(2, 44100);
  65. m_recbuffer.clear();
  66. if (m_afm->getNumKnownFormats()==0)
  67. m_afm->registerBasicFormats();
  68. m_stretch_source = std::make_unique<StretchAudioSource>(2, m_afm);
  69. setPreBufferAmount(2);
  70. m_ppar.pitch_shift.enabled = true;
  71. m_ppar.freq_shift.enabled = true;
  72. m_ppar.filter.enabled = true;
  73. m_ppar.compressor.enabled = true;
  74. m_stretch_source->setOnsetDetection(0.0);
  75. m_stretch_source->setLoopingEnabled(true);
  76. m_stretch_source->setFFTWindowingType(1);
  77. addParameter(new AudioParameterFloat("mainvolume0", "Main volume", -24.0f, 12.0f, -3.0f)); // 0
  78. addParameter(new AudioParameterFloat("stretchamount0", "Stretch amount",
  79. NormalisableRange<float>(0.1f, 128.0f, 0.01f, 0.5),1.0f)); // 1
  80. addParameter(new AudioParameterFloat("fftsize0", "FFT size", 0.0f, 1.0f, 0.7f)); // 2
  81. addParameter(new AudioParameterFloat("pitchshift0", "Pitch shift", -24.0f, 24.0f, 0.0f)); // 3
  82. addParameter(new AudioParameterFloat("freqshift0", "Frequency shift", -1000.0f, 1000.0f, 0.0f)); // 4
  83. addParameter(new AudioParameterFloat("playrange_start0", "Sound start", 0.0f, 1.0f, 0.0f)); // 5
  84. addParameter(new AudioParameterFloat("playrange_end0", "Sound end", 0.0f, 1.0f, 1.0f)); // 6
  85. addParameter(new AudioParameterBool("freeze0", "Freeze", false)); // 7
  86. addParameter(new AudioParameterFloat("spread0", "Frequency spread", 0.0f, 1.0f, 0.0f)); // 8
  87. addParameter(new AudioParameterFloat("compress0", "Compress", 0.0f, 1.0f, 0.0f)); // 9
  88. addParameter(new AudioParameterFloat("loopxfadelen0", "Loop xfade length", 0.0f, 1.0f, 0.0f)); // 10
  89. addParameter(new AudioParameterFloat("numharmonics0", "Num harmonics", 0.0f, 100.0f, 0.0f)); // 11
  90. addParameter(new AudioParameterFloat("harmonicsfreq0", "Harmonics base freq",
  91. NormalisableRange<float>(1.0f, 5000.0f, 1.00f, 0.5), 128.0f)); // 12
  92. addParameter(new AudioParameterFloat("harmonicsbw0", "Harmonics bandwidth", 0.1f, 200.0f, 25.0f)); // 13
  93. addParameter(new AudioParameterBool("harmonicsgauss0", "Gaussian harmonics", false)); // 14
  94. addParameter(new AudioParameterFloat("octavemixm2_0", "2 octaves down level", 0.0f, 1.0f, 0.0f)); // 15
  95. addParameter(new AudioParameterFloat("octavemixm1_0", "Octave down level", 0.0f, 1.0f, 0.0f)); // 16
  96. addParameter(new AudioParameterFloat("octavemix0_0", "Normal pitch level", 0.0f, 1.0f, 1.0f)); // 17
  97. addParameter(new AudioParameterFloat("octavemix1_0", "1 octave up level", 0.0f, 1.0f, 0.0f)); // 18
  98. addParameter(new AudioParameterFloat("octavemix15_0", "1 octave and fifth up level", 0.0f, 1.0f, 0.0f)); // 19
  99. addParameter(new AudioParameterFloat("octavemix2_0", "2 octaves up level", 0.0f, 1.0f, 0.0f)); // 20
  100. addParameter(new AudioParameterFloat("tonalvsnoisebw_0", "Tonal vs Noise BW", 0.74f, 1.0f, 0.74f)); // 21
  101. addParameter(new AudioParameterFloat("tonalvsnoisepreserve_0", "Tonal vs Noise preserve", -1.0f, 1.0f, 0.5f)); // 22
  102. addParameter(new AudioParameterFloat("filter_low_0", "Filter low", 20.0f, 10000.0f, 20.0f)); // 23
  103. addParameter(new AudioParameterFloat("filter_high_0", "Filter high", 20.0f, 20000.0f, 20000.0f)); // 24
  104. addParameter(new AudioParameterFloat("onsetdetect_0", "Onset detection", 0.0f, 1.0f, 0.0f)); // 25
  105. addParameter(new AudioParameterBool("capture_enabled0", "Capture", false)); // 26
  106. m_outchansparam = new AudioParameterInt("numoutchans0", "Num output channels", 2, 8, 2);
  107. addParameter(m_outchansparam); // 27
  108. startTimer(1, 50);
  109. }
  110. PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
  111. {
  112. g_activeprocessors.erase(this);
  113. m_bufferingthread.stopThread(1000);
  114. }
  115. void PaulstretchpluginAudioProcessor::setPreBufferAmount(int x)
  116. {
  117. int temp = jlimit(0, 5, x);
  118. if (temp != m_prebuffer_amount)
  119. {
  120. m_prebuffer_amount = temp;
  121. m_recreate_buffering_source = true;
  122. }
  123. }
  124. //==============================================================================
  125. const String PaulstretchpluginAudioProcessor::getName() const
  126. {
  127. return JucePlugin_Name;
  128. }
  129. bool PaulstretchpluginAudioProcessor::acceptsMidi() const
  130. {
  131. #if JucePlugin_WantsMidiInput
  132. return true;
  133. #else
  134. return false;
  135. #endif
  136. }
  137. bool PaulstretchpluginAudioProcessor::producesMidi() const
  138. {
  139. #if JucePlugin_ProducesMidiOutput
  140. return true;
  141. #else
  142. return false;
  143. #endif
  144. }
  145. bool PaulstretchpluginAudioProcessor::isMidiEffect() const
  146. {
  147. #if JucePlugin_IsMidiEffect
  148. return true;
  149. #else
  150. return false;
  151. #endif
  152. }
  153. double PaulstretchpluginAudioProcessor::getTailLengthSeconds() const
  154. {
  155. return (double)m_bufamounts[m_prebuffer_amount]/getSampleRate();
  156. }
  157. int PaulstretchpluginAudioProcessor::getNumPrograms()
  158. {
  159. return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
  160. // so this should be at least 1, even if you're not really implementing programs.
  161. }
  162. int PaulstretchpluginAudioProcessor::getCurrentProgram()
  163. {
  164. return 0;
  165. }
  166. void PaulstretchpluginAudioProcessor::setCurrentProgram (int index)
  167. {
  168. }
  169. const String PaulstretchpluginAudioProcessor::getProgramName (int index)
  170. {
  171. return {};
  172. }
  173. void PaulstretchpluginAudioProcessor::changeProgramName (int index, const String& newName)
  174. {
  175. }
  176. void PaulstretchpluginAudioProcessor::setFFTSize(double size)
  177. {
  178. if (m_prebuffer_amount == 5)
  179. m_fft_size_to_use = pow(2, 7.0 + size * 14.5);
  180. else m_fft_size_to_use = pow(2, 7.0 + size * 10.0); // chicken out from allowing huge FFT sizes if not enough prebuffering
  181. int optim = optimizebufsize(m_fft_size_to_use);
  182. m_fft_size_to_use = optim;
  183. m_stretch_source->setFFTSize(optim);
  184. //Logger::writeToLog(String(m_fft_size_to_use));
  185. }
  186. void PaulstretchpluginAudioProcessor::startplay(Range<double> playrange, int numoutchans, int maxBlockSize, String& err)
  187. {
  188. m_stretch_source->setPlayRange(playrange, true);
  189. int bufamt = m_bufamounts[m_prebuffer_amount];
  190. if (m_buffering_source != nullptr && numoutchans != m_buffering_source->getNumberOfChannels())
  191. m_recreate_buffering_source = true;
  192. if (m_recreate_buffering_source == true)
  193. {
  194. m_buffering_source = std::make_unique<MyBufferingAudioSource>(m_stretch_source.get(),
  195. m_bufferingthread, false, bufamt, numoutchans, false);
  196. m_recreate_buffering_source = false;
  197. }
  198. if (m_bufferingthread.isThreadRunning() == false)
  199. m_bufferingthread.startThread();
  200. m_stretch_source->setNumOutChannels(numoutchans);
  201. m_stretch_source->setFFTSize(m_fft_size_to_use);
  202. m_stretch_source->setProcessParameters(&m_ppar);
  203. m_last_outpos_pos = 0.0;
  204. m_last_in_pos = playrange.getStart()*m_stretch_source->getInfileLengthSeconds();
  205. m_buffering_source->prepareToPlay(maxBlockSize, getSampleRate());
  206. };
  207. void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
  208. {
  209. ScopedLock locker(m_cs);
  210. m_curmaxblocksize = samplesPerBlock;
  211. int numoutchans = *m_outchansparam;
  212. if (numoutchans != m_cur_num_out_chans)
  213. m_ready_to_play = false;
  214. if (m_using_memory_buffer == true)
  215. {
  216. int len = jlimit(100,m_recbuffer.getNumSamples(), m_rec_pos);
  217. m_stretch_source->setAudioBufferAsInputSource(&m_recbuffer,
  218. getSampleRate(),
  219. len);
  220. callGUI(this,[this,len](auto ed) { ed->setAudioBuffer(&m_recbuffer, getSampleRate(), len); },false);
  221. }
  222. if (m_ready_to_play == false)
  223. {
  224. setFFTSize(*getFloatParameter(2));
  225. m_stretch_source->setProcessParameters(&m_ppar);
  226. String err;
  227. startplay({ *getFloatParameter(5),*getFloatParameter(6) },
  228. numoutchans, samplesPerBlock, err);
  229. m_cur_num_out_chans = numoutchans;
  230. m_ready_to_play = true;
  231. }
  232. }
  233. void PaulstretchpluginAudioProcessor::releaseResources()
  234. {
  235. //m_control->stopplay();
  236. //m_ready_to_play = false;
  237. }
  238. #ifndef JucePlugin_PreferredChannelConfigurations
  239. bool PaulstretchpluginAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
  240. {
  241. #if JucePlugin_IsMidiEffect
  242. ignoreUnused (layouts);
  243. return true;
  244. #else
  245. // This is the place where you check if the layout is supported.
  246. // In this template code we only support mono or stereo.
  247. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
  248. && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
  249. return false;
  250. // This checks if the input layout matches the output layout
  251. #if ! JucePlugin_IsSynth
  252. if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
  253. return false;
  254. #endif
  255. return true;
  256. #endif
  257. }
  258. #endif
  259. void copyAudioBufferWrappingPosition(const AudioBuffer<float>& src, AudioBuffer<float>& dest, int destbufpos, int maxdestpos)
  260. {
  261. for (int i = 0; i < dest.getNumChannels(); ++i)
  262. {
  263. int channel_to_copy = i % src.getNumChannels();
  264. if (destbufpos + src.getNumSamples() > maxdestpos)
  265. {
  266. int wrappos = (destbufpos + src.getNumSamples()) % maxdestpos;
  267. int partial_len = src.getNumSamples() - wrappos;
  268. dest.copyFrom(channel_to_copy, destbufpos, src, channel_to_copy, 0, partial_len);
  269. dest.copyFrom(channel_to_copy, partial_len, src, channel_to_copy, 0, wrappos);
  270. }
  271. else
  272. {
  273. dest.copyFrom(channel_to_copy, destbufpos, src, channel_to_copy, 0, src.getNumSamples());
  274. }
  275. }
  276. }
  277. void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
  278. {
  279. ScopedLock locker(m_cs);
  280. ScopedNoDenormals noDenormals;
  281. const int totalNumInputChannels = getTotalNumInputChannels();
  282. const int totalNumOutputChannels = getTotalNumOutputChannels();
  283. for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
  284. buffer.clear (i, 0, buffer.getNumSamples());
  285. if (m_ready_to_play == false)
  286. return;
  287. if (m_is_recording == true)
  288. {
  289. int recbuflenframes = m_max_reclen * getSampleRate();
  290. copyAudioBufferWrappingPosition(buffer, m_recbuffer, m_rec_pos, recbuflenframes);
  291. callGUI(this,[this, &buffer](PaulstretchpluginAudioProcessorEditor*ed)
  292. {
  293. ed->addAudioBlock(buffer, getSampleRate(), m_rec_pos);
  294. }, false);
  295. m_rec_pos = (m_rec_pos + buffer.getNumSamples()) % recbuflenframes;
  296. return;
  297. }
  298. jassert(m_buffering_source != nullptr);
  299. jassert(m_bufferingthread.isThreadRunning());
  300. m_stretch_source->setMainVolume(*getFloatParameter(0));
  301. m_stretch_source->setRate(*getFloatParameter(1));
  302. setFFTSize(*getFloatParameter(cpi_fftsize));
  303. m_ppar.pitch_shift.cents = *getFloatParameter(cpi_pitchshift) * 100.0;
  304. m_ppar.freq_shift.Hz = *getFloatParameter(cpi_frequencyshift);
  305. m_ppar.spread.enabled = *getFloatParameter(cpi_spreadamount) > 0.0f;
  306. m_ppar.spread.bandwidth = *getFloatParameter(cpi_spreadamount);
  307. m_ppar.compressor.enabled = *getFloatParameter(cpi_compress)>0.0f;
  308. m_ppar.compressor.power = *getFloatParameter(cpi_compress);
  309. m_ppar.harmonics.enabled = *getFloatParameter(cpi_numharmonics)>=1.0;
  310. m_ppar.harmonics.nharmonics = *getFloatParameter(cpi_numharmonics);
  311. m_ppar.harmonics.freq = *getFloatParameter(cpi_harmonicsfreq);
  312. m_ppar.harmonics.bandwidth = *getFloatParameter(cpi_harmonicsbw);
  313. m_ppar.harmonics.gauss = getParameter(cpi_harmonicsgauss);
  314. m_ppar.octave.om2 = *getFloatParameter(cpi_octavesm2);
  315. m_ppar.octave.om1 = *getFloatParameter(cpi_octavesm1);
  316. m_ppar.octave.o0 = *getFloatParameter(cpi_octaves0);
  317. m_ppar.octave.o1 = *getFloatParameter(cpi_octaves1);
  318. m_ppar.octave.o15 = *getFloatParameter(cpi_octaves15);
  319. m_ppar.octave.o2 = *getFloatParameter(cpi_octaves2);
  320. m_ppar.octave.enabled = true;
  321. m_ppar.filter.low = *getFloatParameter(cpi_filter_low);
  322. m_ppar.filter.high = *getFloatParameter(cpi_filter_high);
  323. m_ppar.tonal_vs_noise.enabled = (*getFloatParameter(cpi_tonalvsnoisebw)) > 0.75;
  324. m_ppar.tonal_vs_noise.bandwidth = *getFloatParameter(cpi_tonalvsnoisebw);
  325. m_ppar.tonal_vs_noise.preserve = *getFloatParameter(cpi_tonalvsnoisepreserve);
  326. m_stretch_source->setOnsetDetection(*getFloatParameter(cpi_onsetdetection));
  327. m_stretch_source->setLoopXFadeLength(*getFloatParameter(cpi_loopxfadelen));
  328. double t0 = *getFloatParameter(cpi_soundstart);
  329. double t1 = *getFloatParameter(cpi_soundend);
  330. if (t0 > t1)
  331. std::swap(t0, t1);
  332. if (t1 - t0 < 0.001)
  333. t1 = t0 + 0.001;
  334. m_stretch_source->setPlayRange({ t0,t1 }, true);
  335. m_stretch_source->setFreezing(getParameter(cpi_freeze));
  336. m_stretch_source->setProcessParameters(&m_ppar);
  337. AudioSourceChannelInfo aif(buffer);
  338. m_buffering_source->getNextAudioBlock(aif);
  339. }
  340. //==============================================================================
  341. bool PaulstretchpluginAudioProcessor::hasEditor() const
  342. {
  343. return true; // (change this to false if you choose to not supply an editor)
  344. }
  345. AudioProcessorEditor* PaulstretchpluginAudioProcessor::createEditor()
  346. {
  347. return new PaulstretchpluginAudioProcessorEditor (*this);
  348. }
  349. //==============================================================================
  350. void PaulstretchpluginAudioProcessor::getStateInformation (MemoryBlock& destData)
  351. {
  352. ValueTree paramtree("paulstretch3pluginstate");
  353. for (int i=0;i<getNumParameters();++i)
  354. {
  355. auto par = getFloatParameter(i);
  356. if (par != nullptr)
  357. {
  358. paramtree.setProperty(par->paramID, (double)*par, nullptr);
  359. }
  360. }
  361. paramtree.setProperty(m_outchansparam->paramID, (int)*m_outchansparam, nullptr);
  362. if (m_current_file != File())
  363. {
  364. paramtree.setProperty("importedfile", m_current_file.getFullPathName(), nullptr);
  365. }
  366. MemoryOutputStream stream(destData,true);
  367. paramtree.writeToStream(stream);
  368. }
  369. void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
  370. {
  371. ValueTree tree = ValueTree::readFromData(data, sizeInBytes);
  372. if (tree.isValid())
  373. {
  374. {
  375. ScopedLock locker(m_cs);
  376. for (int i = 0; i < getNumParameters(); ++i)
  377. {
  378. auto par = getFloatParameter(i);
  379. if (par != nullptr)
  380. {
  381. double parval = tree.getProperty(par->paramID, (double)*par);
  382. *par = parval;
  383. }
  384. }
  385. if (tree.hasProperty(m_outchansparam->paramID))
  386. *m_outchansparam = tree.getProperty(m_outchansparam->paramID, 2);
  387. }
  388. String fn = tree.getProperty("importedfile");
  389. if (fn.isEmpty() == false)
  390. {
  391. File f(fn);
  392. setAudioFile(f);
  393. }
  394. }
  395. }
  396. void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b)
  397. {
  398. ScopedLock locker(m_cs);
  399. int lenbufframes = getSampleRate()*m_max_reclen;
  400. if (b == true)
  401. {
  402. m_using_memory_buffer = true;
  403. m_current_file = File();
  404. m_recbuffer.setSize(2, m_max_reclen*getSampleRate()+4096,false,false,true);
  405. m_recbuffer.clear();
  406. m_rec_pos = 0;
  407. callGUI(this,[this,lenbufframes](PaulstretchpluginAudioProcessorEditor* ed)
  408. {
  409. ed->beginAddingAudioBlocks(2, getSampleRate(), lenbufframes);
  410. },false);
  411. m_is_recording = true;
  412. }
  413. else
  414. {
  415. if (m_is_recording == true)
  416. {
  417. finishRecording(lenbufframes);
  418. }
  419. }
  420. }
  421. double PaulstretchpluginAudioProcessor::getRecordingPositionPercent()
  422. {
  423. if (m_is_recording==false)
  424. return 0.0;
  425. return 1.0 / m_recbuffer.getNumSamples()*m_rec_pos;
  426. }
  427. String PaulstretchpluginAudioProcessor::setAudioFile(File f)
  428. {
  429. auto ai = unique_from_raw(m_afm->createReaderFor(f));
  430. if (ai != nullptr)
  431. {
  432. if (ai->numChannels > 32)
  433. {
  434. //MessageManager::callAsync([cb, file]() { cb("Too many channels in file " + file.getFullPathName()); });
  435. return "Too many channels in file "+f.getFullPathName();
  436. }
  437. if (ai->bitsPerSample>32)
  438. {
  439. //MessageManager::callAsync([cb, file]() { cb("Too high bit depth in file " + file.getFullPathName()); });
  440. return "Too high bit depth in file " + f.getFullPathName();
  441. }
  442. ScopedLock locker(m_cs);
  443. m_stretch_source->setAudioFile(f);
  444. m_current_file = f;
  445. m_using_memory_buffer = false;
  446. return String();
  447. //MessageManager::callAsync([cb, file]() { cb(String()); });
  448. }
  449. return "Could not open file " + f.getFullPathName();
  450. }
  451. Range<double> PaulstretchpluginAudioProcessor::getTimeSelection()
  452. {
  453. return { *getFloatParameter(5),*getFloatParameter(6) };
  454. }
  455. double PaulstretchpluginAudioProcessor::getPreBufferingPercent()
  456. {
  457. if (m_buffering_source==nullptr)
  458. return 0.0;
  459. return m_buffering_source->getPercentReady();
  460. }
  461. void PaulstretchpluginAudioProcessor::timerCallback(int id)
  462. {
  463. if (id == 1)
  464. {
  465. bool capture = getParameter(cpi_capture_enabled);
  466. if (capture == true && m_is_recording == false)
  467. {
  468. setRecordingEnabled(true);
  469. return;
  470. }
  471. if (capture == false && m_is_recording == true)
  472. {
  473. setRecordingEnabled(false);
  474. return;
  475. }
  476. if (m_cur_num_out_chans != *m_outchansparam)
  477. {
  478. jassert(m_curmaxblocksize > 0);
  479. ScopedLock locker(m_cs);
  480. m_ready_to_play = false;
  481. m_cur_num_out_chans = *m_outchansparam;
  482. //Logger::writeToLog("Switching to use " + String(m_cur_num_out_chans) + " out channels");
  483. String err;
  484. startplay({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) },
  485. m_cur_num_out_chans, m_curmaxblocksize, err);
  486. m_ready_to_play = true;
  487. }
  488. }
  489. }
  490. void PaulstretchpluginAudioProcessor::finishRecording(int lenrecording)
  491. {
  492. m_is_recording = false;
  493. m_stretch_source->setAudioBufferAsInputSource(&m_recbuffer, getSampleRate(), lenrecording);
  494. m_stretch_source->setPlayRange({ *getFloatParameter(5),*getFloatParameter(6) }, true);
  495. auto ed = dynamic_cast<PaulstretchpluginAudioProcessorEditor*>(getActiveEditor());
  496. if (ed)
  497. {
  498. //ed->setAudioBuffer(&m_recbuffer, getSampleRate(), lenrecording);
  499. }
  500. }
  501. //==============================================================================
  502. // This creates new instances of the plugin..
  503. AudioProcessor* JUCE_CALLTYPE createPluginFilter()
  504. {
  505. return new PaulstretchpluginAudioProcessor();
  506. }