MCPcopy Create free account
hub / github.com/VCVRack/Rack / setDisplayValueString

Method setDisplayValueString

src/Quantity.cpp:114–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void Quantity::setDisplayValueString(std::string s) {
115 teVarsInit();
116
117 // Uppercase letters aren't needed in formulas, so convert to lowercase in case user types INF or C4.
118 s = string::lowercase(s);
119
120 // Replace "#" with "s" so note names can be written as c#.
121 std::replace(s.begin(), s.end(), '#', 's');
122
123 // Compile string with tinyexpr
124 te_expr* expr = te_compile(s.c_str(), teVars.data(), teVars.size(), NULL);
125 if (!expr)
126 return;
127
128 double result = te_eval(expr);
129 te_free(expr);
130 if (std::isnan(result))
131 return;
132
133 setDisplayValue(result);
134}
135
136std::string Quantity::getString() {
137 std::string s;

Callers

nothing calls this directly

Calls 3

teVarsInitFunction · 0.85
lowercaseFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected