Skip to content

Commit 27ed6a9

Browse files
committed
0.1.1
1 parent 06d809f commit 27ed6a9

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

lib/atkaudio/src/atkaudio/PluginHost/JuceHostPlugin.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ class HostAudioProcessorImpl
1818
{
1919
public:
2020
HostAudioProcessorImpl()
21-
: AudioProcessor(BusesProperties()
22-
.withInput("Input", AudioChannelSet::stereo(), true)
23-
.withOutput("Output", AudioChannelSet::stereo(), true)
24-
.withInput("Sidechain", AudioChannelSet::stereo(), false))
21+
: AudioProcessor(
22+
BusesProperties()
23+
.withInput("Input", AudioChannelSet::stereo(), true)
24+
.withOutput("Output", AudioChannelSet::stereo(), true)
25+
.withInput("Sidechain", AudioChannelSet::stereo(), false)
26+
)
2527

2628
{
2729
appProperties.setStorageParameters(
@@ -249,9 +251,6 @@ class HostAudioProcessorImpl
249251

250252
editorStyle = where;
251253

252-
if (inner != nullptr && !mb.isEmpty())
253-
inner->setStateInformation(mb.getData(), (int)mb.getSize());
254-
255254
// In a 'real' plugin, we'd also need to set the bus configuration of the inner plugin.
256255
// One possibility would be to match the bus configuration of the wrapper plugin, but
257256
// the inner plugin isn't guaranteed to support the same layout. Alternatively, we
@@ -321,15 +320,19 @@ class HostAudioProcessorImpl
321320
getBlockSize()
322321
);
323322
}
324-
325-
inner->prepareToPlay(getSampleRate(), getBlockSize());
326323
}
327324

325+
this->prepareToPlay(getSampleRate(), getBlockSize());
326+
327+
if (inner != nullptr && !mb.isEmpty())
328+
inner->setStateInformation(mb.getData(), (int)mb.getSize());
329+
328330
if (needsPluginChanged)
329331
NullCheckedInvocation::invoke(pluginChanged);
330332
};
331333

332-
pluginFormatManager.createPluginInstanceAsync(pd, getSampleRate(), getBlockSize(), callback);
334+
if (inner == nullptr || (inner != nullptr && inner->getPluginDescription().name != pd.name))
335+
pluginFormatManager.createPluginInstanceAsync(pd, getSampleRate(), getBlockSize(), callback);
333336
}
334337

335338
void clearPlugin()

lib/atkaudio/src/atkaudio/PluginHost/PluginHost.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ static std::unique_ptr<StandalonePluginHolder2> createPluginHolder()
1616
struct atk::PluginHost::Impl : public juce::Timer
1717
{
1818
Impl()
19-
: mainWindow(std::make_unique<StandaloneFilterWindow>(
20-
"atkAudio Plugin Host",
21-
LookAndFeel::getDefaultLookAndFeel().findColour(ResizableWindow::backgroundColourId),
22-
createPluginHolder()
23-
))
19+
: mainWindow(
20+
std::make_unique<StandaloneFilterWindow>(
21+
"atkAudio Plugin Host",
22+
LookAndFeel::getDefaultLookAndFeel().findColour(ResizableWindow::backgroundColourId),
23+
createPluginHolder()
24+
)
25+
)
2426
{
2527
startTimerHz(30);
2628
}
@@ -62,8 +64,10 @@ struct atk::PluginHost::Impl : public juce::Timer
6264

6365
void process(float** buffer, int numChannels, int numSamples, double sampleRate)
6466
{
65-
if (this->numChannels != numChannels || this->numSamples < numSamples || this->sampleRate != sampleRate)
67+
if (!buffer || this->numChannels != numChannels || this->numSamples < numSamples ||
68+
this->sampleRate != sampleRate || isFirstRun)
6669
{
70+
isFirstRun = false;
6771
this->numChannels = numChannels;
6872
this->numSamples = numSamples;
6973
this->sampleRate = sampleRate;
@@ -130,6 +134,7 @@ struct atk::PluginHost::Impl : public juce::Timer
130134
double sampleRate = 48000.0;
131135

132136
std::atomic_bool isPrepared{false};
137+
bool isFirstRun = true;
133138
bool needsRelease = false;
134139
};
135140

0 commit comments

Comments
 (0)