Vuo 2.4.4
Loading...
Searching...
No Matches
VuoRealRegulation.c
Go to the documentation of this file.
1
10#include "VuoRealRegulation.h"
11
13#ifdef VUO_COMPILER
15 "title" : "Real Regulation",
16 "description" : "Parameters describing how to regulate a real number.",
17 "keywords" : [ ],
18 "version" : "1.0.0",
19 "dependencies" : [
20 "VuoReal",
21 "VuoText"
22 ]
23 });
24#endif
26
41{
42 return (VuoRealRegulation){
43 VuoJson_getObjectValue(VuoText, js, "name", NULL),
44 VuoJson_getObjectValue(VuoReal, js, "minimumValue", 0),
45 VuoJson_getObjectValue(VuoReal, js, "maximumValue", 0),
46 VuoJson_getObjectValue(VuoReal, js, "defaultValue", 0),
47 VuoJson_getObjectValue(VuoReal, js, "smoothDuration", 0)
48 };
49}
50
55{
56 json_object *js = json_object_new_object();
57 json_object_object_add(js, "name", VuoText_getJson(value.name));
58 json_object_object_add(js, "minimumValue", VuoReal_getJson(value.minimumValue));
59 json_object_object_add(js, "maximumValue", VuoReal_getJson(value.maximumValue));
60 json_object_object_add(js, "defaultValue", VuoReal_getJson(value.defaultValue));
61 json_object_object_add(js, "smoothDuration", VuoReal_getJson(value.smoothDuration));
62 return js;
63}
64
69{
70 return VuoText_format("Ensures %s is between %g and %g, with default %g and smooth duration %g", value.name, value.minimumValue, value.maximumValue, value.defaultValue, value.smoothDuration);
71}
72
76VuoRealRegulation VuoRealRegulation_make(VuoText name, VuoReal minimumValue, VuoReal maximumValue, VuoReal defaultValue, VuoReal smoothDuration)
77{
79
80 value.name = name;
81
82 // Allow the max and min to be in any order (so the user can specify an inverted mapping)…
83 value.minimumValue = minimumValue;
84 value.maximumValue = maximumValue;
85
86 value.defaultValue = VuoReal_clamp(defaultValue, minimumValue, maximumValue);
87
88 value.smoothDuration = smoothDuration;
89
90 return value;
91}