# HG changeset patch # User Chris Cannam # Date 1405338190 -3600 # Node ID 7d4c98c696a54668e0dbdda0222f2cc5da3039c3 # Parent b700f37dc1181449a47eba01cc90a20f761d6bda Choose more sensible non-default parameter values where possible diff -r b700f37dc118 -r 7d4c98c696a5 TestDefaults.cpp --- a/TestDefaults.cpp Tue Jun 10 08:50:54 2014 +0100 +++ b/TestDefaults.cpp Mon Jul 14 12:43:10 2014 +0100 @@ -187,13 +187,41 @@ if (p->getParameterDescriptors().empty()) return r; // Set all parameters to non-default values + Plugin::ParameterList pl = p->getParameterDescriptors(); + for (int i = 0; i < (int)pl.size(); ++i) { - if (pl[i].defaultValue == pl[i].minValue) { - p->setParameter(pl[i].identifier, pl[i].maxValue); - } else { - p->setParameter(pl[i].identifier, pl[i].minValue); + + // Half-way between default and max value, seems a + // reasonable guess for something to set it to. We want to + // avoid the real extremes because they can sometimes be + // very slow, and we want to avoid setting everything to + // the same values (e.g. min) because plugins will + // sometimes legitimately reject that. + + // Remember to take into account quantization + + float value = (pl[i].defaultValue + pl[i].maxValue) / 2; + + if (pl[i].isQuantized) { + value = round(value / pl[i].quantizeStep) * pl[i].quantizeStep; } + + if (value > pl[i].maxValue) { + value = pl[i].maxValue; + } + if (value < pl[i].minValue) { + value = pl[i].minValue; + } + if (value == pl[i].defaultValue) { + if (pl[i].defaultValue == pl[i].minValue) { + value = pl[i].maxValue; + } else { + value = pl[i].minValue; + } + } + + p->setParameter(pl[i].identifier, value); } if (!initAdapted(p.get(), channels, _step, _step, r)) return r;