2 paper-def.cc -- implement Paper_def
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
13 #include "paper-def.hh"
17 #include "assoc-iter.hh"
18 #include "score-grav.hh"
23 Paper_def::Paper_def()
26 real_vars_p_
= new Dictionary
<Real
>;
29 Paper_def::~Paper_def()
35 Paper_def::Paper_def (Paper_def
const&s
)
36 : Music_output_def (s
)
38 lookup_p_
= s
.lookup_p_
? new Lookup (*s
.lookup_p_
) : 0;
39 lookup_p_
->paper_l_
= this;
40 real_vars_p_
= new Dictionary
<Real
> (*s
.real_vars_p_
);
41 outfile_str_
= s
.outfile_str_
;
45 Paper_def::set_var (String s
, Real r
)
47 real_vars_p_
->elem (s
) = r
;
51 Paper_def::get_var (String s
) const
53 if (! real_vars_p_
->elt_b (s
))
54 error ("unknown paper variable `" + s
+"'");
55 return real_vars_p_
->elem (s
);
59 Paper_def::linewidth_f() const
61 return get_var ("linewidth");
65 Paper_def::duration_to_dist (Moment d
,Real k
) const
67 if (get_var("geometric"))
68 return geometric_spacing(d
);
69 return arithmetic_spacing(d
,k
);
74 Get the measure wide constant for arithmetic.
77 John S. Gourlay. ``Spacing a Line of Music,'' Technical Report
78 OSU-CISRC-10/87-TR35, Department of Computer and Information Science,
79 The Ohio State University, 1987.
83 Paper_def::arithmetic_constant(Moment d
) const
85 return get_var("arithmetic_basicspace") - log_2(Moment(1,8) <? d
);
89 Paper_def::arithmetic_spacing(Moment d
,Real k
) const
91 return (log_2(d
) + k
)* get_var("arithmetic_multiplier");
95 Paper_def::geometric_spacing(Moment d
) const
97 Real dur_f
= (d
) ?pow (get_var ("geometric"), log_2(d
)) : 0;
98 return get_var ("basicspace") + get_var ("unitspace") * dur_f
;
102 Paper_def::set (Lookup
*l
)
104 assert (l
!= lookup_p_
);
107 lookup_p_
->paper_l_
= this;
111 Paper_def::interline_f() const
113 return get_var ("interline");
118 Paper_def::rule_thickness() const
120 return get_var ("rule_thickness");
124 Paper_def::interbeam_f() const
126 return get_var ("interbeam");
129 Paper_def::internote_f() const
131 return interline_f() / 2;
135 Paper_def::note_width() const
137 return get_var ("notewidth");
141 Paper_def::print() const
144 Music_output_def::print ();
146 DOUT
<< "out: " <<outfile_str_
;
148 for (Assoc_iter
<String
,Real
> i (*real_vars_p_
); i
.ok(); i
++)
150 DOUT
<< i
.key() << "= " << i
.val () << "\n";
157 Paper_def::lookup_l()
163 IMPLEMENT_IS_TYPE_B1(Paper_def
, Music_output_def
);