| 290 | } |
| 291 | |
| 292 | static float float_from_string(const char *s) |
| 293 | { |
| 294 | if (strchr(s, 'e')) |
| 295 | return Parameter::valueFromString(std::string(s)); |
| 296 | float rez = 0, fact = 1; |
| 297 | if (*s == '-'){ |
| 298 | s++; |
| 299 | fact = -1; |
| 300 | }; |
| 301 | for (int point_seen = 0; *s; s++){ |
| 302 | if (*s == '.'){ |
| 303 | point_seen = 1; |
| 304 | continue; |
| 305 | }; |
| 306 | int d = *s - '0'; |
| 307 | if (d >= 0 && d <= 9){ |
| 308 | if (point_seen) fact /= 10.0f; |
| 309 | rez = rez * 10.0f + (float)d; |
| 310 | }; |
| 311 | }; |
| 312 | return rez * fact; |
| 313 | } |
| 314 | |
| 315 | static bool readBankFile(const char *filename, Preset *presets) |
| 316 | { |