I have a plugin that uses the AudioProcessorValueStateTree. While debugging some nasty “std::variant” related bug I have tried to set up a smoke test by just using the static library of the plugin and emulating calls.
The thing is that I can see that I set the parameters correctly, I can even print out its value and it is correct, but the value changes aren’t seen from the audio processor. It works perfectly on the host. Am I missing some call? All parameters are AudioParameterInt.
#include <optional>
#include <gtest/gtest.h>
#include <juce_audio_processors/juce_audio_processors.h>
extern juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter();
//------------------------------------------------------------------------------
class smoke_test : public ::testing::Test {
public:
smoke_test() {}
void SetUp()
{
float io_cfg = ((float) 0x8421) / ((float) 0xffff);
gui_emu.emplace();
plugin.reset (createPluginFilter());
plugin->enableAllBuses();
audio.setSize (8, 128);
plugin->prepareToPlay (44100, 1024);
for (juce::AudioProcessorParameter* param : plugin->getParameters()) {
juce::String name = param->getName (64);
if (name == "fx_type_01") {
fx_type_param = param;
}
else if (name == "in_selection") {
ins_param = param;
param->setValue (io_cfg);
}
else if (name == "out_selection") {
outs_param = param;
param->setValue (io_cfg);
}
}
ASSERT_TRUE (fx_type_param != nullptr);
ASSERT_TRUE (ins_param != nullptr);
ASSERT_TRUE (outs_param != nullptr);
}
void TearDown()
{
plugin->releaseResources();
plugin.reset();
gui_emu.reset();
}
std::optional<juce::ScopedJuceInitialiser_GUI> gui_emu;
std::unique_ptr<juce::AudioProcessor> plugin;
juce::AudioBuffer<float> audio;
juce::AudioProcessorParameter* fx_type_param = nullptr;
juce::AudioProcessorParameter* ins_param = nullptr;
juce::AudioProcessorParameter* outs_param = nullptr;
juce::MidiBuffer midi;
};
//------------------------------------------------------------------------------
TEST_F (smoke_test, run_all_fx_on_ch1)
{
float interval = 1. / fx_type_param->getNumSteps();
for (float v = 0.; v <= 1.; v += interval) {
fx_type_param->setValue (v);
plugin->processBlock (audio, midi);
}
}