@@ -202,7 +202,8 @@ struct ParamMetaData
202
202
enum struct Features : uint64_t
203
203
{
204
204
SUPPORTS_MULTIPLICATIVE_MODULATION = 1 << 0 ,
205
- BELOW_ONE_IS_INVERSE_FRACTION = 1 << 1
205
+ BELOW_ONE_IS_INVERSE_FRACTION = 1 << 1 ,
206
+ ALLOW_FRACTIONAL_TYPEINS = 1 << 2
206
207
};
207
208
uint64_t features{0 };
208
209
ParamMetaData withFeature (Features f) const
@@ -858,8 +859,10 @@ struct ParamMetaData
858
859
void toClapParamInfo (IsAClapParamInfo *info) const
859
860
{
860
861
info->id = id;
861
- strncpy (info->name , name.c_str (), stringSize);
862
- strncpy (info->module , groupName.c_str (), stringSize);
862
+ strncpy (info->name , name.c_str (), stringSize - 2 );
863
+ info->name [stringSize - 1 ] = 0 ;
864
+ strncpy (info->module , groupName.c_str (), stringSize - 2 );
865
+ info->module [stringSize - 1 ] = 0 ;
863
866
info->min_value = minVal;
864
867
info->max_value = maxVal;
865
868
info->default_value = defaultVal;
@@ -1142,6 +1145,19 @@ inline std::optional<float> ParamMetaData::valueFromString(std::string_view v, s
1142
1145
else
1143
1146
r = 1.0 / uv;
1144
1147
}
1148
+ else if ((features & (uint64_t )Features::ALLOW_FRACTIONAL_TYPEINS) &&
1149
+ vs.find (" /" ) != std::string::npos)
1150
+ {
1151
+ auto ps = vs.find (" /" );
1152
+ auto num = vs.substr (0 , ps);
1153
+ auto den = vs.substr (ps + 1 );
1154
+ auto uv = std::stof (num);
1155
+ auto dv = std::stof (den);
1156
+ if (uv == 0 || dv == 0 )
1157
+ r = std::stof (std::string (v));
1158
+ else
1159
+ r = uv / dv;
1160
+ }
1145
1161
else
1146
1162
{
1147
1163
r = std::stof (std::string (v));
0 commit comments