2 cluster-engraver.cc -- implement Cluster_engraver
4 (c) 2002--2004 Juergen Reuter <reuter@ipd.uka.de>
6 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 #include "note-head.hh"
13 #include "note-column.hh"
14 #include "group-interface.hh"
16 class Cluster_spanner_engraver
: public Engraver
20 TRANSLATOR_DECLARATIONS (Cluster_spanner_engraver
);
21 virtual bool try_music (Music
*);
22 virtual void process_music ();
23 virtual void acknowledge_grob (Grob_info
);
24 virtual void stop_translation_timestep ();
25 virtual void finalize ();
27 Link_array
<Music
> cluster_notes_
;
30 void typeset_grobs ();
32 Spanner
* finished_spanner_
;
35 Cluster_spanner_engraver::Cluster_spanner_engraver ()
38 finished_spanner_
= 0;
43 Cluster_spanner_engraver::finalize ()
46 finished_spanner_
= spanner_
;
52 Cluster_spanner_engraver::typeset_grobs ()
54 finished_spanner_
= 0;
59 Cluster_spanner_engraver::try_music (Music
*m
)
61 if (m
->is_mus_type ("cluster-note-event"))
63 cluster_notes_
.push (m
);
70 Cluster_spanner_engraver::process_music ()
72 if (cluster_notes_
.size ())
74 SCM c0scm
= get_property ("middleCPosition");
76 int c0
= ly_c_number_p (c0scm
) ? ly_scm2int (c0scm
) : 0;
80 for (int i
= 0; i
<cluster_notes_
.size (); i
++)
82 Pitch
*pit
=unsmob_pitch (cluster_notes_
[i
]->get_property ("pitch"));
84 int p
=( pit
? pit
->steps () : 0) + c0
;
90 beacon_
= make_item ("ClusterSpannerBeacon", cluster_notes_
[0]->self_scm ());
91 beacon_
->set_property ("positions",
92 scm_cons (scm_int2num (pmin
),
96 if (beacon_
&& !spanner_
)
98 spanner_
= make_spanner ("ClusterSpanner", cluster_notes_
[0]->self_scm () );
101 if (beacon_
&& spanner_
)
103 add_bound_item (spanner_
, beacon_
);
104 Pointer_group_interface::add_grob (spanner_
, ly_symbol2scm ("columns"), beacon_
);
110 Cluster_spanner_engraver::stop_translation_timestep ()
114 cluster_notes_
.clear ();
119 Cluster_spanner_engraver::acknowledge_grob (Grob_info info
)
121 if (!beacon_
&& Note_column::has_interface (info
.grob_
))
123 finished_spanner_
= spanner_
;
128 ENTER_DESCRIPTION (Cluster_spanner_engraver
,
129 /* descr */ "Engraves a cluster using Spanner notation ",
130 /* creats*/ "ClusterSpanner ClusterSpannerBeacon",
131 /* accepts */ "cluster-note-event",
132 /* acks */ "note-column-interface",