]> git.donarmstrong.com Git - lilypond.git/blob - lily/voice-devnull-engraver.cc
release: 1.3.129
[lilypond.git] / lily / voice-devnull-engraver.cc
1 /*
2   voice-devnull-engraver.cc -- implement Voice_devnull_engraver
3
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "engraver.hh"
10 #include "item.hh"
11 #include "musical-request.hh"
12 #include "translator-group.hh"
13
14 class Voice_devnull_engraver : public Engraver
15 {
16 public:
17   VIRTUAL_COPY_CONS (Translator);
18   
19 protected:
20   virtual bool try_music (Music *m);
21   virtual void acknowledge_grob (Grob_info);
22 };
23
24 ADD_THIS_TRANSLATOR (Voice_devnull_engraver);
25
26 static char const *eat_spanners[] = {
27   "beam-interface",
28   "slur",
29   "tie",
30   "dynamic-interface",
31   "crescendo-interface",
32   0
33 };
34
35 bool
36 Voice_devnull_engraver::try_music (Music *m)
37 {
38   SCM s = get_property ("devNullVoice");
39 #if 0
40   /* No need */
41   if (gh_equal_p (s, ly_symbol2scm ("never")))
42     return;
43 #endif
44
45   if (gh_equal_p (s, ly_symbol2scm ("allways"))
46       || (s == SCM_EOL
47           && daddy_trans_l_->id_str_.left_str (3) == "two"
48           && (to_boolean (get_property ("unison"))
49               || to_boolean (get_property ("unisilence")))))
50     {
51       for (char const **p = eat_spanners; *p; p++)
52         {
53           if (Span_req *s = dynamic_cast <Span_req *> (m))
54             {
55               if (scm_equal_p (s->get_mus_property ("span-type"),
56                                ly_str02scm ( *p)) == SCM_BOOL_T)
57                 {
58                   return true;
59                 }
60             }
61         }
62     }
63   return false;
64 }
65   
66 static char const *junk_interfaces[] = {
67 #if 0
68   "beam-interface",
69 #endif
70   "slur-interface",
71   "tie-interface",
72   "text-item-interface",
73   "text-script-interface",
74   "dynamic-interface",
75   "crescendo-interface",
76   0
77 };
78
79 void
80 Voice_devnull_engraver::acknowledge_grob (Grob_info i)
81 {
82   SCM s = get_property ("devNullVoice");
83 #if 0
84   /* No need */
85   if (gh_equal_p (s, ly_symbol2scm ("never")))
86     return;
87 #endif
88
89   if (gh_equal_p (s, ly_symbol2scm ("allways"))
90       || (gh_equal_p (s, ly_symbol2scm ("unisolo"))
91           && daddy_trans_l_->id_str_.left_str (3) == "two"
92           && (to_boolean (get_property ("unison"))
93               || to_boolean (get_property ("unisilence")))))
94     for (char const **p = junk_interfaces; *p; p++)
95       if (i.elem_l_->has_interface (ly_symbol2scm (*p)))
96         {
97           i.elem_l_->suicide ();
98           return;
99         }
100 }
101