]> git.donarmstrong.com Git - lilypond.git/blob - lily/articulations.cc
Merge branch 'lilypond/translation'
[lilypond.git] / lily / articulations.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2010--2011 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   vector<Stream_event *> string_events;
42   SCM articulations = SCM_EOL;
43   vsize j = 0;
44
45   for (vsize i = 0; i < note_events.size (); i++)
46     {
47
48       Stream_event *event = note_events[i];
49
50       Stream_event *articulation_event = 0;
51
52       /*
53         For notes inside a chord construct, string indications are
54         stored as articulations on the note, so we check through
55         the notes
56       */
57       for (SCM s = event->get_property ("articulations");
58            !articulation_event && scm_is_pair (s); s = scm_cdr (s))
59         {
60           Stream_event *art = unsmob_stream_event (scm_car (s));
61
62           if (art->in_event_class (articulation_name))
63             articulation_event = art;
64         }
65
66       /*
67         For string indications listed outside a chord construct,
68         a string_number_event is generated, so if there was no string
69         in the articulations, we check for string events outside
70         the chord construct
71       */
72       if (!articulation_event && j < articulation_events.size ())
73         {
74           articulation_event = articulation_events[j];
75           if (j + 1 < articulation_events.size ())
76             j++;
77         }
78       articulations = scm_cons ((articulation_event
79                                  ? articulation_event->self_scm ()
80                                  : SCM_EOL),
81                                 articulations);
82     }
83
84   return (scm_reverse (articulations));
85 }