Fix type predicates/docstrings for two music properties.
[lilypond/mpolesky.git] / lily / chord-tremolo-iterator.cc
blobe6c4dd604abc8b524a758ebcfa0b17c714dcb8b1
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 Erik Sandberg <mandolaerik@gmail.com>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "chord-tremolo-iterator.hh"
23 #include "input.hh"
24 #include "international.hh"
25 #include "misc.hh"
26 #include "repeated-music.hh"
28 Chord_tremolo_iterator::Chord_tremolo_iterator ()
32 SCM
33 Chord_tremolo_iterator::get_music_list () const
35 Music *mus = get_music ();
36 Input *origin = mus->origin ();
37 Moment l = mus->get_length ();
38 Music *body = Repeated_music::body (mus);
39 bool body_is_sequential = body->is_mus_type ("sequential-music");
41 int elt_count = body_is_sequential ? scm_ilength (body->get_property ("elements")) : 1;
43 if (body_is_sequential &&
44 (elt_count != 2
45 && elt_count != 1))
46 mus->origin ()->warning (_f ("expect 2 elements for chord tremolo, found %d", elt_count));
48 if (elt_count <= 0)
49 elt_count = 1;
51 if (elt_count == 1)
53 Music *ev = make_music_by_name (ly_symbol2scm ("TremoloEvent"));
54 ev->set_spot (*origin);
55 ev->set_property ("repeat-count", mus->get_property ("repeat-count"));
56 ev->set_property ("tremolo-type", mus->get_property ("tremolo-type"));
57 return scm_list_2 (ev->unprotect (), body->self_scm ());
59 else
61 SCM tremolo_symbol = ly_symbol2scm ("TremoloSpanEvent");
62 SCM start_event_scm = scm_call_2 (ly_lily_module_constant ("make-span-event"), tremolo_symbol, scm_from_int (START));
63 unsmob_music (start_event_scm)->set_spot (*origin);
64 SCM stop_event_scm = scm_call_2 (ly_lily_module_constant ("make-span-event"), tremolo_symbol, scm_from_int (STOP));
66 Music *start_event = unsmob_music (start_event_scm);
67 Music *stop_event = unsmob_music (stop_event_scm);
68 start_event->set_spot (*origin);
69 stop_event->set_spot (*origin);
70 start_event->set_property ("repeat-count", mus->get_property ("repeat-count"));
71 start_event->set_property ("tremolo-type", mus->get_property ("tremolo-type"));
73 return scm_list_3 (start_event_scm, body->self_scm (), stop_event_scm);
77 IMPLEMENT_CTOR_CALLBACK (Chord_tremolo_iterator);