]> git.donarmstrong.com Git - lilypond.git/blob - misc.cc
release: 0.0.5
[lilypond.git] / misc.cc
1 #include "misc.hh"
2 #include "glob.hh"
3
4 #include <math.h>
5
6 int intlog2(int d) {
7     int i=0;
8     while (!(d&1)) {
9         d/= 2; i++;
10     }
11     assert(!(d/2));
12     return i;
13 }
14
15 double log2(double x) {
16     return log(x)  /log(2.0);
17 }
18
19
20 // golden ratio
21  
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
25
26
27   
28 Real
29 duration_to_idealspace(Real d, Real w)
30 {
31     // see  Roelofs, p. 57
32     return w * pow(ENGRAVERS_SPACE, log2(d));
33 }
34
35
36
37