Vuo 2.4.4
Loading...
Searching...
No Matches
VuoTempoRange.c
Go to the documentation of this file.
1
10#include "VuoTempoRange.h"
11
13#ifdef VUO_COMPILER
15 "title" : "Tempo Range",
16 "description" : "A range of BPM values.",
17 "keywords" : [ ],
18 "version" : "1.0.0",
19 "dependencies" : [
20 "VuoList_VuoTempoRange"
21 ]
22 });
23#endif
25
34{
35 const char *valueAsString = "";
36 if (json_object_get_type(js) == json_type_string)
37 valueAsString = json_object_get_string(js);
38
39 VuoTempoRange value = VuoTempoRange_Andante;
40
41 if (strcmp(valueAsString, "moderato") == 0)
42 value = VuoTempoRange_Moderato;
43 else if (strcmp(valueAsString, "allegro") == 0)
44 value = VuoTempoRange_Allegro;
45 else if (strcmp(valueAsString, "presto") == 0)
46 value = VuoTempoRange_Presto;
47 else if (strcmp(valueAsString, "prestissimo") == 0)
48 value = VuoTempoRange_Prestissimo;
49
50 return value;
51}
52
56json_object *VuoTempoRange_getJson(const VuoTempoRange value)
57{
58 char *valueAsString = "andante";
59
60 if (value == VuoTempoRange_Moderato)
61 valueAsString = "moderato";
62 else if (value == VuoTempoRange_Allegro)
63 valueAsString = "allegro";
64 else if (value == VuoTempoRange_Presto)
65 valueAsString = "presto";
66 else if (value == VuoTempoRange_Prestissimo)
67 valueAsString = "prestissimo";
68
69 return json_object_new_string(valueAsString);
70}
71
76{
78 VuoListAppendValue_VuoTempoRange(l, VuoTempoRange_Andante);
79 VuoListAppendValue_VuoTempoRange(l, VuoTempoRange_Moderato);
80 VuoListAppendValue_VuoTempoRange(l, VuoTempoRange_Allegro);
81 VuoListAppendValue_VuoTempoRange(l, VuoTempoRange_Presto);
82 VuoListAppendValue_VuoTempoRange(l, VuoTempoRange_Prestissimo);
83 return l;
84}
85
90{
91 // Each BPM range actually covers N to 2N BPM, but only works well for the middle ~60% of the range.
92
93 char *valueAsString = " 70–110 BPM"; // actually 60–120 BPM
94 // FIGURE SPACE U+2007, to match the width of the numeral
95
96 if (value == VuoTempoRange_Moderato)
97 valueAsString = "100–140 BPM"; // actually 80-160 BPM
98 else if (value == VuoTempoRange_Allegro)
99 valueAsString = "120–180 BPM"; // actually 100–200 BPM
100 else if (value == VuoTempoRange_Presto)
101 valueAsString = "170–250 BPM"; // actually 140-280 BPM
102 else if (value == VuoTempoRange_Prestissimo)
103 valueAsString = "220–320 BPM"; // actually 180-360 BPM
104
105 return strdup(valueAsString);
106}
107
113{
114 if (value == VuoTempoRange_Andante)
115 return 60;
116 else if (value == VuoTempoRange_Allegro)
117 return 100;
118 else if (value == VuoTempoRange_Presto)
119 return 140;
120 else if (value == VuoTempoRange_Prestissimo)
121 return 180;
122 else
123 return 80;
124}
125
129bool VuoTempoRange_areEqual(const VuoTempoRange valueA, const VuoTempoRange valueB)
130{
131 return valueA == valueB;
132}
133
138{
139 return valueA < valueB;
140}