Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Source/TestUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ static inline juce::Array<juce::AudioProcessorParameter*> getNonBypassAutomatabl
return parameters;
}

//==============================================================================
static inline void randomizeParameter (juce::Random& r, juce::AudioProcessorParameter* parameter)
{
auto newValue = r.nextFloat();

// snap to legal value
if (parameter->isDiscrete())
{
auto maxValue = static_cast<float>(parameter->getNumSteps() - 1);
newValue = std::round(newValue * maxValue) / maxValue;
}

parameter->setValue (newValue);
}

//==============================================================================
template<typename UnaryFunction>
void iterateAudioBuffer (juce::AudioBuffer<float>& ab, UnaryFunction fn)
Expand Down
13 changes: 7 additions & 6 deletions Source/tests/BasicTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ struct PluginStateTest : public PluginTest

// Set random parameter values
for (auto parameter : getNonBypassAutomatableParameters (instance))
parameter->setValue (r.nextFloat());
randomizeParameter (r, parameter);

// Restore original state
callSetStateInformationOnMessageThreadIfVST3 (instance, originalState);
Expand Down Expand Up @@ -318,8 +318,9 @@ struct PluginStateTestRestoration : public PluginTest
// Set random parameter values
for (auto parameter : getNonBypassAutomatableParameters(instance))
{
const auto originalValue = parameter->getValue();
parameter->setValue(r.nextFloat());
const auto originalValue = parameter->getValue();

randomizeParameter (r, parameter);

// Restore original state
callSetStateInformationOnMessageThreadIfVST3(instance, originalState);
Expand Down Expand Up @@ -398,7 +399,7 @@ struct AutomationTest : public PluginTest
for (int i = 0; i < juce::jmin (10, parameters.size()); ++i)
{
const int paramIndex = r.nextInt (parameters.size());
parameters[paramIndex]->setValue (r.nextFloat());
randomizeParameter (r, parameters[paramIndex]);
}
}

Expand Down Expand Up @@ -461,7 +462,7 @@ struct EditorAutomationTest : public PluginTest
while (--numBlocks >= 0)
{
for (auto parameter : parameters)
parameter->setValue (r.nextFloat());
randomizeParameter (r, parameter);

ut.resetTimeout();
juce::Thread::sleep (10);
Expand Down Expand Up @@ -589,7 +590,7 @@ struct BackgroundThreadStateTest : public PluginTest

// Set random parameter values
for (auto parameter : parameters)
parameter->setValue (r.nextFloat());
randomizeParameter (r, parameter);

// Restore original state
callSetStateInformationOnMessageThreadIfVST3 (instance, originalState);
Expand Down