From 73ef79509c9d3baf87e450de352dec2c65dc6308 Mon Sep 17 00:00:00 2001 From: xenakios Date: Fri, 24 Nov 2017 01:44:30 +0200 Subject: [PATCH] Use shared audioformatmanager between plugin instances --- Source/PluginEditor.cpp | 2 +- Source/PluginProcessor.cpp | 6 +++--- Source/PluginProcessor.h | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index ca8f4c4..5ca5007 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -15,7 +15,7 @@ //============================================================================== PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor (PaulstretchpluginAudioProcessor& p) : AudioProcessorEditor (&p), - m_wavecomponent(p.m_afm.get()), + m_wavecomponent(p.m_afm), processor (p) { diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 81b7e42..b550f62 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -73,9 +73,9 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor() g_activeprocessors.insert(this); m_recbuffer.setSize(2, 44100); m_recbuffer.clear(); - m_afm = std::make_unique(); - m_afm->registerBasicFormats(); - m_stretch_source = std::make_unique(2, m_afm.get()); + if (m_afm->getNumKnownFormats()==0) + m_afm->registerBasicFormats(); + m_stretch_source = std::make_unique(2, m_afm); setPreBufferAmount(2); m_ppar.pitch_shift.enabled = true; diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 7e147e5..34b77f6 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -15,6 +15,7 @@ class MyThumbCache; + class PaulstretchpluginAudioProcessor : public AudioProcessor { public: @@ -64,7 +65,7 @@ public: String setAudioFile(File f); File getAudioFile() { return m_current_file; } Range getTimeSelection(); - std::unique_ptr m_afm; + SharedResourcePointer m_afm; StretchAudioSource* getStretchSource() { return m_stretch_source.get(); } double getPreBufferingPercent(); private: