MCPcopy Create free account
hub / github.com/DISTRHO/DPF / getParameterStringForValue

Method getParameterStringForValue

distrho/src/DistrhoPluginCLAP.cpp:1208–1239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1206 }
1207
1208 bool getParameterStringForValue(const clap_id param_id, double value, char* const display, const uint32_t size) const
1209 {
1210 const ParameterEnumerationValues& enumValues(fPlugin.getParameterEnumValues(param_id));
1211 const ParameterRanges& ranges(fPlugin.getParameterRanges(param_id));
1212 const uint32_t hints = fPlugin.getParameterHints(param_id);
1213
1214 if (hints & kParameterIsBoolean)
1215 {
1216 const float midRange = ranges.min + (ranges.max - ranges.min) * 0.5f;
1217 value = value > midRange ? ranges.max : ranges.min;
1218 }
1219 else if (hints & kParameterIsInteger)
1220 {
1221 value = std::round(value);
1222 }
1223
1224 for (uint32_t i=0; i < enumValues.count; ++i)
1225 {
1226 if (d_isEqual(static_cast<double>(enumValues.values[i].value), value))
1227 {
1228 d_strncpy(display, enumValues.values[i].label, size);
1229 return true;
1230 }
1231 }
1232
1233 if (hints & kParameterIsInteger)
1234 snprintf_i32(display, value, size);
1235 else
1236 snprintf_f32(display, value, size);
1237
1238 return true;
1239 }
1240
1241 bool getParameterValueForString(const clap_id param_id, const char* const display, double* const value) const
1242 {

Calls 5

roundFunction · 0.85
d_isEqualFunction · 0.85
d_strncpyFunction · 0.85
snprintf_i32Function · 0.85
snprintf_f32Function · 0.85

Tested by

no test coverage detected