2 misc.cc -- implement various stuff
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
14 Return the 2-log, rounded down
34 return log (x) / log (2.0);
38 directed_round (Real f, Direction d)
49 0 at threshold, 1 at 0, with 1/x falloff.
52 peak_around (Real epsilon, Real threshold, Real x)
56 return max (- epsilon * (x - threshold) / ((x + epsilon) * threshold), 0.0);
61 camel_case_to_lisp_identifier (string in)
65 /* don't add '-' before first character */
66 out.push_back (tolower (in[0]));
68 for (size_t inpos = 1; inpos < in.size (); inpos++)
70 if (isupper (in[inpos]))
72 out.push_back (tolower (in[inpos]));
75 string result (&out[0], out.size ());
76 replace_all (result, '_', '-');