]> git.donarmstrong.com Git - lilypond.git/blob - lily/stem-info.cc
release: 0.1.61
[lilypond.git] / lily / stem-info.cc
1 /*
2   stem-info.cc -- implement Stem_info
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Jan Nieuwenhuizen <jan@digicash.com>
7
8 */
9
10 #include "proto.hh"
11 #include "dimen.hh"
12 #include "misc.hh"
13 #include "debug.hh"
14 #include "atom.hh"
15 #include "stem.hh"
16 #include "paper-def.hh"
17 #include "lookup.hh"
18 #include "stem-info.hh"
19
20 Stem_info::Stem_info ()
21 {
22 }
23
24 Stem_info::Stem_info (Stem const *s)
25 {
26   x_ = s->hpos_f ();
27   dir_ = s->dir_;
28   mult_i_ = s->mult_i_;
29
30   /*
31     [todo] 
32     * get algorithm runtime
33
34     Breitkopf + H\"artel:
35     miny_f_ = interline + #beams * interbeam
36     ideal8 = 2 * interline + interbeam
37     ideal16,32,64,128 = 1.5 * interline + #beams * interbeam
38
39     * B\"arenreiter:
40     miny_f_ = interline + #beams * interbeam
41     ideal8,16 = 2 interline + #beams * interbeam
42     ideal32,64,128 = 1.5 interline + #beams * interbeam
43        
44     */
45
46   Real internote_f = s->paper ()->internote_f ();
47   Real interline_f = 2.0 * internote_f;
48   Real interbeam_f = s->paper ()->interbeam_f ();
49   Real staffline_f = s->paper ()->rule_thickness ();
50   Real beam_f = 0.48 * (interline_f - staffline_f);
51          
52   if (check_debug && !monitor->silent_b ("Stem_info"))
53     {
54       static int i = 1;
55       cout << "******" << i++ << "******" << endl;
56       cout << "begin_f: " << s->stem_begin_f () * dir_ << endl;
57       // urg urg urg
58       cout << "chord_f/i: " << s->chord_start_f () * dir_ / internote_f << endl;
59     }
60
61   /*
62     For simplicity, we'll assume dir = UP and correct if 
63     dir = DOWN afterwards.
64    */
65   idealy_f_ = s->chord_start_f () * dir_ / internote_f;
66   idealy_f_ *= internote_f;
67
68   idealy_f_ += interbeam_f * mult_i_;
69
70   miny_f_ = idealy_f_;
71
72   // B"arenreiter
73   if (mult_i_ < 3)
74     idealy_f_ += 2.0 * interline_f;
75   else
76     idealy_f_ += 1.5 * interline_f;
77
78   miny_f_ += 1.0 * interline_f;
79
80   // lowest beam of (UP) beam must never be lower than second staffline
81   miny_f_ = miny_f_ >? (- 2 * internote_f - beam_f
82     + (mult_i_ > 0) * beam_f + interbeam_f * (mult_i_ - 1));
83
84   idealy_f_ /= internote_f;
85   miny_f_ /= internote_f;
86
87   if (check_debug && !monitor->silent_b ("Stem_info"))
88     {
89       cout << "dir_: " << dir_ << endl;
90       cout << "mult_i_: " << mult_i_ << endl;
91       cout << "idealy_f_: " << idealy_f_ << endl;
92       cout << "miny_f_: " << miny_f_ << endl;
93     }
94
95   idealy_f_ = miny_f_ >? idealy_f_;
96 }
97