Skip to content
Merged
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
2 changes: 1 addition & 1 deletion products/dialogue/source/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace altvane::dialogue::params {
return formatSensitivity(v);
})
.withValueFromStringFunction([](const juce::String& t) {
return t.retainCharacters("+-.0123456789").getFloatValue() / 100.f;
return static_cast<float>(ui::format::parseLenient(t).value_or(0.0)) / 100.f;
});
for (size_t s = 0; s < dsp::kNumStems; ++s) {
for (size_t n = 0; n < dsp::kSensitivityNodes; ++n) {
Expand Down
12 changes: 12 additions & 0 deletions products/dialogue/tests/engine_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,3 +1003,15 @@ TEST_CASE("level text round-trips, with Off at the bottom", "[params]") {
const auto shown = voice->getText(voice->convertTo0to1(-6.f), 32);
CHECK(std::abs(voice->convertFrom0to1(voice->getValueForText(shown)) + 6.f) < .05f);
}

TEST_CASE("sensitivity text reads either minus sign", "[params]") {
PluginProcessor p;
auto* sensitivity = p.parameters_.getParameter(params::sensitivityID(0, 0));
for (const auto* text : {"-50%", "\u221250%", "\u2212 50 %"}) {
CHECK(std::abs(sensitivity->convertFrom0to1(sensitivity->getValueForText(juce::CharPointer_UTF8(text))) + .5f) < 1e-4f);
}
CHECK(std::abs(sensitivity->convertFrom0to1(sensitivity->getValueForText("+25%")) - .25f) < 1e-4f);
// what the interface shows reads back
const auto shown = sensitivity->getText(sensitivity->convertTo0to1(-.4f), 32);
CHECK(std::abs(sensitivity->convertFrom0to1(sensitivity->getValueForText(shown)) + .4f) < 1e-4f);
}
4 changes: 2 additions & 2 deletions products/leveler/source/ui/control_deck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ namespace altvane::leveler {
if (b.percent) {
b.knob.format = [](const float v) { return params::formatPercent(v); };
b.knob.parse = [](const juce::String& t) -> std::optional<float> {
const auto clean = t.retainCharacters("+-.0123456789");
return clean.containsAnyOf("0123456789") ? std::optional<float>(clean.getFloatValue() / 100.f) : std::nullopt;
const auto value = ui::format::parseLenient(t);
return value ? std::optional<float>(static_cast<float>(*value) / 100.f) : std::nullopt;
};
} else {
b.knob.format = [](const float v) { return params::formatDb(v); };
Expand Down
Loading