]> git.donarmstrong.com Git - lilypond.git/blob - lily/articulations.cc
Issue 4550 (1/2) Avoid "using namespace std;" in included files
[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 using std::vector;
27
28 /*
29   Return an articulation list given a note_events vector and an
30   articulation_events vector.
31
32   This is necessary, because the articulations come as events if
33   they are entered outside of a chord structure, and as articulations
34   if they are inside the chord structure.  So potentially we need to
35   combine the two types.
36 */
37
38 SCM
39 articulation_list (vector<Stream_event *> note_events,
40                    vector<Stream_event *> articulation_events,
41                    char const *articulation_name)
42 {
43   SCM articulations = SCM_EOL;
44   vsize j = 0;
45
46   for (vsize i = 0; i < note_events.size (); i++)
47     {
48
49       Stream_event *event = note_events[i];
50
51       Stream_event *articulation_event = 0;
52
53       /*
54         For notes inside a chord construct, string indications are
55         stored as articulations on the note, so we check through
56         the notes
57       */
58       for (SCM s = event->get_property ("articulations");
59            !articulation_event && scm_is_pair (s); s = scm_cdr (s))
60         {
61           Stream_event *art = unsmob<Stream_event> (scm_car (s));
62
63           if (art->in_event_class (articulation_name))
64             articulation_event = art;
65         }
66
67       /*
68         For string indications listed outside a chord construct,
69         a string_number_event is generated, so if there was no string
70         in the articulations, we check for string events outside
71         the chord construct
72       */
73       if (!articulation_event && j < articulation_events.size ())
74         {
75           articulation_event = articulation_events[j];
76           if (j + 1 < articulation_events.size ())
77             j++;
78         }
79       articulations = scm_cons ((articulation_event
80                                  ? articulation_event->self_scm ()
81                                  : SCM_EOL),
82                                 articulations);
83     }
84
85   return scm_reverse_x (articulations, SCM_EOL);
86 }