]> git.donarmstrong.com Git - lilypond.git/blob - lily/voice-devnull-engraver.cc
input/test/script-priority.ly: New file.
[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--2002 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   TRANSLATOR_DECLARATIONS(Voice_devnull_engraver);
18   
19 protected:
20   virtual bool try_music (Music *m);
21   virtual void acknowledge_grob (Grob_info);
22 };
23
24
25
26 static char const *eat_spanners[] = {
27   "beam",
28   "crescendo",
29   "decrescendo",
30   "rest",
31   "slur",
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       if (Span_req *s = dynamic_cast <Span_req *> (m))
52         {
53           SCM t = s->get_mus_property ("span-type");
54         
55           for (char const **p = eat_spanners; *p; p++)
56             {
57               if (t == ly_str02scm (*p))
58                 return true;
59             }
60         }
61       /* Ugh.  Should eat other requests, script etc. too. */  
62       else if (dynamic_cast<Tie_req*> (m))
63         return true;
64     }
65   return false;
66 }
67     
68 static char const *junk_interfaces[] = {
69   "beam-interface",
70   "dynamic-interface",
71   "hairpin-interface",
72   "multi-measure-rest-interface",
73   "script-interface",
74   "slur-interface",
75   "text-interface",
76   "text-item-interface",
77   "text-script-interface",
78   "text-spanner-interface",
79   "tie-interface",
80   0
81 };
82
83 void
84 Voice_devnull_engraver::acknowledge_grob (Grob_info i)
85 {
86   SCM s = get_property ("devNullVoice");
87 #if 0
88   /* No need, next if will never be true */
89   if (s == ly_symbol2scm ("never"))
90     return;
91 #endif
92
93   if (s == ly_symbol2scm ("allways")
94       || (s == SCM_EOL
95           && daddy_trans_l_->id_str_.left_str (3) == "two"
96           && (to_boolean (get_property ("unison"))
97               || to_boolean (get_property ("unisilence")))))
98     for (char const **p = junk_interfaces; *p; p++)
99       if (i.grob_l_->internal_has_interface (ly_symbol2scm (*p)))
100         {
101           /* Ugh, we can suicide them, but they remain living */
102           i.grob_l_->suicide ();
103           return;
104         }
105 }
106  
107 Voice_devnull_engraver::Voice_devnull_engraver(){}
108   
109 ENTER_DESCRIPTION(Voice_devnull_engraver,
110 /* descr */       "Kill off certain items and spanners if we're Voice `two' and unison or unisilence is set.",
111 /* creats*/       "",
112 /* acks  */       "grob-interface",
113 /* reads */       "",
114 /* write */       "");