]> git.donarmstrong.com Git - lilypond.git/blob - lily/voice-devnull-engraver.cc
*** empty log message ***
[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--2003 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "engraver.hh"
10 #include "item.hh"
11 #include "event.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
27 ARGH .
28
29
30 This really sucks.
31
32  */
33 static char const *eat_spanners[] = {
34   "beam",
35   "crescendo",
36   "decrescendo",
37   "rest",
38   "slur",
39   0
40 };
41
42 bool
43 Voice_devnull_engraver::try_music (Music *m)
44 {
45   SCM s = get_property ("devNullVoice");
46
47 #if 0
48   /* No need */
49   if (gh_equal_p (s, ly_symbol2scm ("never")))
50     return;
51 #endif
52
53   if (gh_equal_p (s, ly_symbol2scm ("always"))
54       || (s == SCM_EOL
55           && daddy_trans_->id_string_.left_string (3) == "two"
56           && (to_boolean (get_property ("unison"))
57               || to_boolean (get_property ("unisilence")))))
58     {
59       if (m->is_mus_type ("span-event"))
60         {
61           SCM t = m->get_mus_property ("span-type");
62         
63           for (char const **p = eat_spanners; *p; p++)
64             {
65               if (t == scm_makfrom0str (*p))
66                 return true;
67             }
68         }
69       /* Ugh.  Should eat other events, script etc. too. */  
70       else if (m->is_mus_type ("tie-event"))
71         return true;
72     }
73   return false;
74 }
75     
76 static char const *junk_interfaces[] = {
77   "beam-interface",
78   "dynamic-interface",
79   "hairpin-interface",
80   "multi-measure-rest-interface",
81   "script-interface",
82   "slur-interface",
83   "text-interface",
84   "text-item-interface",
85   "text-script-interface",
86   "text-spanner-interface",
87   "tie-interface",
88   0
89 };
90
91 void
92 Voice_devnull_engraver::acknowledge_grob (Grob_info i)
93 {
94   SCM s = get_property ("devNullVoice");
95 #if 0
96   /* No need, next if will never be true */
97   if (s == ly_symbol2scm ("never"))
98     return;
99 #endif
100
101 #if 0  /* We used to have have this until 1.5.68.  Not sure about
102           soloADue requirement */
103   if (s == ly_symbol2scm ("always")
104       || (s == SCM_EOL
105           && daddy_trans_->id_string_.left_string (3) == "two"
106           && (to_boolean (get_property ("unison"))
107               || to_boolean (get_property ("unisilence")))))
108 #else
109     if (s == ly_symbol2scm ("always")
110         || (s == SCM_EOL
111             && to_boolean (get_property ("soloADue"))
112             && ((daddy_trans_->id_string_.left_string (3) == "two"
113                  && (to_boolean (get_property ("unison"))
114                      || to_boolean (get_property ("unisilence"))))
115                 
116                 /* Maybe this should be optional? */
117               || to_boolean (get_property ("othersolo")))))
118 #endif
119     
120     for (char const **p = junk_interfaces; *p; p++)
121       if (i.grob_->internal_has_interface (ly_symbol2scm (*p)))
122         {
123           i.grob_->suicide ();
124           return;
125         }
126 }
127  
128 Voice_devnull_engraver::Voice_devnull_engraver(){}
129   
130 ENTER_DESCRIPTION(Voice_devnull_engraver,
131 /* descr */       "Kill off certain items and spanners if we're Voice `two' and unison or unisilence is set.",
132 /* creats*/       "",
133 /* accepts */     "general-music", /*UGH.*/
134 /* acks  */      "grob-interface",
135 /* reads */       "",
136 /* write */       "");