]> git.donarmstrong.com Git - lilypond.git/blob - lily/musical-request.cc
* input/trip.ly (fugaIILeft): add arpeggio
[lilypond.git] / lily / musical-request.cc
1 /*
2   request.cc -- implement all musical requests.
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "musical-request.hh"
10 #include "misc.hh"
11 #include "warn.hh"
12 #include "music-list.hh"
13
14
15 Tremolo_req::Tremolo_req ()
16 {
17 }
18
19 LY_DEFINE(music_duration_length, "music-duration-length", 1, 0,0,
20           (SCM mus),
21           "Extract the duration field from @var{mus}, and return the length.")
22 {
23   Music* m =   unsmob_music(mus);
24   SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "Music");
25   
26   Duration *d = unsmob_duration (m->get_mus_property ("duration"));
27
28   Moment l ;
29   
30   if (d)
31     {
32       l = d->length_mom ();  
33     }
34   else
35     programming_error("Rhythmic_req has no duration");
36   return l.smobbed_copy();
37   
38 }
39
40
41 LY_DEFINE(music_duration_compress, "music-duration-compress", 2, 0,0,
42           (SCM mus, SCM factor),
43           "Extract the duration field from @var{mus}, and compress it.")
44 {
45   Music* m =   unsmob_music(mus);
46   Moment * f = unsmob_moment (factor);
47   SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "Music");
48   SCM_ASSERT_TYPE(f, factor, SCM_ARG2, __FUNCTION__, "Moment");
49   
50   Duration *d = unsmob_duration (m->get_mus_property ("duration"));
51   if (d)
52     m->set_mus_property ("duration", d->compressed (f->main_part_).smobbed_copy());
53   return SCM_UNSPECIFIED;
54 }
55
56   
57 Moment
58 Rhythmic_req::length_mom () const
59 {
60   Duration *d = unsmob_duration (get_mus_property ("duration"));
61   if (!d)
62     {
63       Moment m ;
64       programming_error("Rhythmic_req has no duration");
65       return m;
66     }
67   return d->length_mom ();
68 }
69
70 void
71 Rhythmic_req::compress (Moment m)
72 {
73   Duration *d =  unsmob_duration (get_mus_property ("duration"));
74   if (d)
75     set_mus_property ("duration", d ->compressed (m.main_part_).smobbed_copy ());
76 }
77
78
79
80 bool
81 Span_req::do_equal_b (Request const*r) const
82 {
83   Span_req const* s = dynamic_cast <Span_req const*> (r);
84   return s && get_span_dir () == s->get_span_dir ();
85 }
86
87 Span_req::Span_req ()
88 {
89 }
90
91
92 bool
93 Text_script_req::do_equal_b (Request const* r) const
94 {
95   Text_script_req const* t  = dynamic_cast<Text_script_req const*> (r);
96   return t && gh_equal_p (get_mus_property ("text"),
97                           t->get_mus_property ("text"));
98 }
99
100 bool
101 Articulation_req::do_equal_b (Request const* r) const
102 {
103   Articulation_req const* a = dynamic_cast<Articulation_req const*> (r);
104   
105   return a && gh_equal_p (get_mus_property ("articulation-type"),
106                           r->get_mus_property ("articulation-type"))
107     && get_direction () == a->get_direction ();
108 }
109