2 duration-convert.cc -- implement Duration_convert
4 source file of the LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "duration-convert.hh"
12 #include "duration-iter.hh"
14 Duration_iterator::Duration_iterator ()
16 cursor_dur_
.durlog_i_
= 7;
17 if (Duration_convert::no_smaller_than_i_s
)
18 cursor_dur_
.durlog_i_
= Duration_convert::no_smaller_than_i_s
;
22 Duration_iterator::operator ++(int)
24 return forward_dur ();
28 Duration_iterator::operator ()()
33 Duration_iterator::operator bool ()
39 Duration_iterator::dur ()
45 Duration_iterator::forward_dur ()
47 /* should do smart table? guessing:
61 Duration dur
= cursor_dur_
;
63 if (!cursor_dur_
.dots_i_
&& !cursor_dur_
.plet_b ())
65 cursor_dur_
.durlog_i_
+= 1;
66 cursor_dur_
.dots_i_
= 2;
68 else if (cursor_dur_
.dots_i_
== 2)
70 assert (!cursor_dur_
.plet_b ());
71 cursor_dur_
.dots_i_
= 0;
72 cursor_dur_
.durlog_i_
-=2;
73 cursor_dur_
.set_plet (2, 3);
75 else if (cursor_dur_
.plet_b ()
76 && (cursor_dur_
.plet_
.iso_i_
== 2)
77 && (cursor_dur_
.plet_
.type_i_
== 3))
79 assert (!cursor_dur_
.dots_i_
);
80 cursor_dur_
.set_plet (1, 1);
81 cursor_dur_
.durlog_i_
+= 1;
82 cursor_dur_
.dots_i_
= 1;
84 else if (cursor_dur_
.dots_i_
== 1)
86 assert (!cursor_dur_
.plet_b ());
87 cursor_dur_
.dots_i_
= 0;
88 cursor_dur_
.durlog_i_
-= 1;
91 if (Duration_convert::no_triplets_b_s
92 && cursor_dur_
.plet_b () && ok ())
94 if (Duration_convert::no_double_dots_b_s
95 && (cursor_dur_
.dots_i_
== 2) && ok ())
97 if (Duration_convert::no_smaller_than_i_s
98 && (cursor_dur_
.durlog_i_
> Duration_convert::no_smaller_than_i_s
) && ok ())
100 if (Duration_convert::no_smaller_than_i_s
101 && cursor_dur_
.dots_i_
102 && (cursor_dur_
.durlog_i_
>= Duration_convert::no_smaller_than_i_s
)
105 if (Duration_convert::no_smaller_than_i_s
106 && (cursor_dur_
.dots_i_
== 2)
107 && (cursor_dur_
.durlog_i_
>= Duration_convert::no_smaller_than_i_s
/ 2)
115 Duration_iterator::ok ()
117 return cursor_dur_
.length_mom () <= Rational (4);