lilypond-1.3.145
[lilypond.git] / lily / voice-devnull-engraver.cc
blob94859cf81946dec02d8765cc7b4831a846a5f6ea
1 /*
2 voice-devnull-engraver.cc -- implement Voice_devnull_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2001 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "engraver.hh"
10 #include "item.hh"
11 #include "musical-request.hh"
12 #include "translator-group.hh"
14 class Voice_devnull_engraver : public Engraver
16 public:
17 VIRTUAL_COPY_CONS (Translator);
19 protected:
20 virtual bool try_music (Music *m);
21 virtual void acknowledge_grob (Grob_info);
24 ADD_THIS_TRANSLATOR (Voice_devnull_engraver);
26 static char const *eat_spanners[] = {
27 "beam",
28 "crescendo",
29 "decrescendo",
30 "slur",
34 bool
35 Voice_devnull_engraver::try_music (Music *m)
37 SCM s = get_property ("devNullVoice");
38 #if 0
39 /* No need */
40 if (gh_equal_p (s, ly_symbol2scm ("never")))
41 return;
42 #endif
44 if (gh_equal_p (s, ly_symbol2scm ("allways"))
45 || (s == SCM_EOL
46 && daddy_trans_l_->id_str_.left_str (3) == "two"
47 && (to_boolean (get_property ("unison"))
48 || to_boolean (get_property ("unisilence")))))
50 if (Span_req *s = dynamic_cast <Span_req *> (m))
52 SCM t = s->get_mus_property ("span-type");
54 for (char const **p = eat_spanners; *p; p++)
56 if (t == ly_str02scm (*p))
57 return true;
60 /* Ugh. Should eat other requests, script etc. too. */
61 else if (Tie_req *t = dynamic_cast<Tie_req*> (m))
62 return true;
64 return false;
67 static char const *junk_interfaces[] = {
68 "beam-interface",
69 "dynamic-interface",
70 "hairpin-interface",
71 "multi-measure-rest-interface",
72 "script-interface",
73 "slur-interface",
74 "text-interface",
75 "text-item-interface",
76 "text-script-interface",
77 "text-spanner-interface",
78 "tie-interface",
82 void
83 Voice_devnull_engraver::acknowledge_grob (Grob_info i)
85 SCM s = get_property ("devNullVoice");
86 #if 0
87 /* No need, next if will never be true */
88 if (s == ly_symbol2scm ("never"))
89 return;
90 #endif
92 if (s == ly_symbol2scm ("allways")
93 || (s == SCM_EOL
94 && daddy_trans_l_->id_str_.left_str (3) == "two"
95 && (to_boolean (get_property ("unison"))
96 || to_boolean (get_property ("unisilence")))))
97 for (char const **p = junk_interfaces; *p; p++)
98 if (i.elem_l_->has_interface (ly_symbol2scm (*p)))
100 #if 0
101 /* Ugh: virtual mmrest::suicide () ? */
102 if (i.elem_l_->has_interface (ly_symbol2scm ("multi-measure-rest-interface")))
103 i.elem_l_->set_grob_property ("skip-timestep", SCM_BOOL_T);
104 else
106 #endif
107 /* Ugh, we can suicide them, but they remain living */
108 i.elem_l_->suicide ();
109 return;