]> git.donarmstrong.com Git - lilypond.git/blob - lily/articulations.cc
Web-ja: update introduction
[lilypond.git] / lily / articulations.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2010--2015 Carl Sorensen <c_sorensen@byu.edu>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 #include "engraver.hh"
20
21 #include "articulations.hh"
22 #include "stream-event.hh"
23 #include "warn.hh"
24 #include "context.hh"
25
26 /*
27   Return an articulation list given a note_events vector and an
28   articulation_events vector.
29
30   This is necessary, because the articulations come as events if
31   they are entered outside of a chord structure, and as articulations
32   if they are inside the chord structure.  So potentially we need to
33   combine the two types.
34 */
35
36 SCM
37 articulation_list (vector<Stream_event *> note_events,
38                    vector<Stream_event *> articulation_events,
39                    char const *articulation_name)
40 {
41   SCM articulations = SCM_EOL;
42   vsize j = 0;
43
44   for (vsize i = 0; i < note_events.size (); i++)
45     {
46
47       Stream_event *event = note_events[i];
48
49       Stream_event *articulation_event = 0;
50
51       /*
52         For notes inside a chord construct, string indications are
53         stored as articulations on the note, so we check through
54         the notes
55       */
56       for (SCM s = event->get_property ("articulations");
57            !articulation_event && scm_is_pair (s); s = scm_cdr (s))
58         {
59           Stream_event *art = unsmob<Stream_event> (scm_car (s));
60
61           if (art->in_event_class (articulation_name))
62             articulation_event = art;
63         }
64
65       /*
66         For string indications listed outside a chord construct,
67         a string_number_event is generated, so if there was no string
68         in the articulations, we check for string events outside
69         the chord construct
70       */
71       if (!articulation_event && j < articulation_events.size ())
72         {
73           articulation_event = articulation_events[j];
74           if (j + 1 < articulation_events.size ())
75             j++;
76         }
77       articulations = scm_cons ((articulation_event
78                                  ? articulation_event->self_scm ()
79                                  : SCM_EOL),
80                                 articulations);
81     }
82
83   return scm_reverse_x (articulations, SCM_EOL);
84 }