lilypond-0.0.9
[lilypond.git] / misc.cc
blobeffab35896fee3a3cfbb8a0a006e2d958ec847b4
1 #include "misc.hh"
2 #include "glob.hh"
3 #include "mtime.hh"
4 #include <math.h>
6 int intlog2(int d) {
7 int i=0;
8 while (!(d&1)) {
9 d/= 2; i++;
11 assert(!(d/2));
12 return i;
15 double log2(double x) {
16 return log(x) /log(2.0);
20 // golden ratio
22 const Real PHI = (1+sqrt(5))/2;
23 const double ENGRAVERS_SPACE = PHI;
24 const double WHOLE_SPACE = 5.0; // should be settable from input
28 Real
29 duration_to_idealspace(Mtime d)
31 // see Roelofs, p. 57
32 return WHOLE_SPACE * pow(ENGRAVERS_SPACE, log2(d));