lilypond-0.0.4
[lilypond.git] / misc.cc
blob2be0f81dd67c9530007177553bd5723542aaf5dd
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, Real w)
31 // see Roelofs, p. 57
32 return w * pow(ENGRAVERS_SPACE, log2(d));