2 misc.cc -- implement various stuff
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2007 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);
60 0 at 0, 1 at standard_x, and increasing thereafter.
63 convex_amplifier (Real standard_x
, Real increase_factor
, Real x
)
65 return (exp (increase_factor
* x
/ standard_x
) - 1.0) / (exp (increase_factor
) - 1.0);
69 camel_case_to_lisp_identifier (string in
)
73 /* don't add '-' before first character */
74 out
.push_back (char (tolower (in
[0])));
76 for (size_t inpos
= 1; inpos
< in
.size (); inpos
++)
78 if (isupper (in
[inpos
]))
80 out
.push_back ( char(tolower (in
[inpos
])));
83 string
result (&out
[0], out
.size ());
84 replace_all (&result
, '_', '-');