X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmisc.cc;h=e7c3063df234c6ce79bca6185bf9358e837e401b;hb=cd8d085d0ca2487e965483554850234931156e9a;hp=5c3293073c1950d4d33bd8c1683d655874acd9b0;hpb=8347f6f06cd4c56d7a2d2ec482647afaaade1267;p=lilypond.git diff --git a/lily/misc.cc b/lily/misc.cc index 5c3293073c..e7c3063df2 100644 --- a/lily/misc.cc +++ b/lily/misc.cc @@ -9,7 +9,6 @@ #include "misc.hh" -#include "std-string.hh" /* Return the 2-log, rounded down @@ -35,52 +34,6 @@ log_2 (double x) return log (x) / log (2.0); } -vector -split_string (string str, char c) -{ - vector a; - ssize i = str.find (c); - while (i != NPOS) - { - string s = str.substr (0, i); - a.push_back (s); - while (str[++i] == c) - ; - str = str.substr (i); - i = str.find (c); - } - if (str.length ()) - a.push_back (str); - return a; -} - -#if 0 -vector -split_string (string s, char c) -{ - vector rv; - while (s.length ()) - { - ssize i = s.find (c); - - if (i == 0) - { - s = s.substr (1, s.length () -1); - continue; - } - - if (i == NPOS) - i = s.length (); - - rv.push_back (s.substr (0, i)); - s = s.substr (i, s.length () - i); - } - - return rv; -} -#endif - - Real directed_round (Real f, Direction d) { @@ -90,3 +43,15 @@ directed_round (Real f, Direction d) return ceil (f); } + + +/* + 0 at threshold, 1 at 0, with 1/x falloff. + */ +Real +peak_around (Real epsilon, Real threshold, Real x) +{ + if (x < 0) + return 1.0; + return max (- epsilon * (x - threshold) / ((x + epsilon) * threshold), 0.0); +}