+/*
+ ES TODO: This method should probably be reworked or junked.
+*/
+Stream_event *
+Music::to_event () const
+{
+ SCM class_name = ly_camel_case_2_lisp_identifier (get_property ("name"));
+
+ // catch programming mistakes.
+ if (!internal_is_music_type (class_name))
+ {
+ programming_error ("Not a music type");
+ }
+
+ Stream_event *e = new Stream_event (class_name, mutable_property_alist_);
+ Moment length = get_length ();
+ if (length.to_bool ())
+ e->set_property ("length", length.smobbed_copy ());
+
+ // articulations as events.
+ SCM art_mus = e->get_property ("articulations");
+ if (scm_is_pair (art_mus))
+ {
+ SCM art_ev = SCM_EOL;
+ for (; scm_is_pair (art_mus); art_mus = scm_cdr (art_mus))
+ {
+ Music *m = unsmob_music (scm_car (art_mus));
+ SCM ev = m ? m->to_event ()->unprotect () : scm_car (art_mus);
+ art_ev = scm_cons (ev, art_ev);
+ }
+ e->set_property ("articulations", scm_reverse_x (art_ev, SCM_EOL));
+ }
+
+ /*
+ ES TODO: This is a temporary fix. Stream_events should not be
+ aware of music.
+ */
+ e->set_property ("music-cause", self_scm ());
+
+ return e;
+}
+
+void
+Music::send_to_context (Context *c)
+{
+ Stream_event *ev = to_event ();
+ c->event_source ()->broadcast (ev);
+ ev->unprotect ();
+}