From: Erik Sandberg Date: Wed, 19 Jul 2006 21:33:02 +0000 (+0000) Subject: * lily/*-performer.cc: Converted try_music to listen_* X-Git-Tag: release/2.10.0-2~446 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=eb51e9b3adf374a806fed1dda25d146974950123;p=lilypond.git * lily/*-performer.cc: Converted try_music to listen_* * lily/grob-info.cc, lily/engraver.cc: represent the cause of grob as a stream-event internally. Introduce event_cause (), deprecate music_cause (). * scm/define-music-types.scm: Removed BusyPlayingEvent --- diff --git a/ChangeLog b/ChangeLog index 3b0154b619..b75ac3fd9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-07-19 Erik Sandberg + + * lily/*-performer.cc: Converted try_music to listen_* + + * lily/grob-info.cc, lily/engraver.cc: represent the cause of grob + as a stream-event internally. Introduce event_cause (), deprecate + music_cause (). + + * scm/define-music-types.scm: Removed BusyPlayingEvent + 2006-07-19 Mats Bengtsson * Documentation/user/advanced-notation.itely (Font selection): diff --git a/lily/accidental-placement.cc b/lily/accidental-placement.cc index d8702520e1..f05a5e67f5 100644 --- a/lily/accidental-placement.cc +++ b/lily/accidental-placement.cc @@ -7,16 +7,17 @@ */ - #include "accidental-placement.hh" -#include "skyline.hh" + +#include "accidental-interface.hh" #include "music.hh" -#include "pitch.hh" -#include "warn.hh" +#include "note-collision.hh" #include "note-column.hh" +#include "pitch.hh" #include "pointer-group-interface.hh" -#include "note-collision.hh" -#include "accidental-interface.hh" +#include "skyline.hh" +#include "stream-event.hh" +#include "warn.hh" void @@ -26,10 +27,10 @@ Accidental_placement::add_accidental (Grob *me, Grob *a) a->set_property ("X-offset", Grob::x_parent_positioning_proc); SCM cause = a->get_parent (Y_AXIS)->get_property ("cause"); - Music *mcause = unsmob_music (cause); + Stream_event *mcause = unsmob_stream_event (cause); if (!mcause) { - programming_error ("note head has no music cause"); + programming_error ("note head has no event cause"); return; } diff --git a/lily/arpeggio-engraver.cc b/lily/arpeggio-engraver.cc index d67d9da120..1cc143dbd7 100644 --- a/lily/arpeggio-engraver.cc +++ b/lily/arpeggio-engraver.cc @@ -45,7 +45,6 @@ IMPLEMENT_TRANSLATOR_LISTENER (Arpeggio_engraver, arpeggio); void Arpeggio_engraver::listen_arpeggio (Stream_event *ev) { arpeggio_event_ = ev; - ev->protect (); } void @@ -86,7 +85,6 @@ Arpeggio_engraver::process_music () if (arpeggio_event_) { arpeggio_ = make_item ("Arpeggio", arpeggio_event_->self_scm ()); - arpeggio_event_->unprotect (); } } diff --git a/lily/audio-element-info.cc b/lily/audio-element-info.cc index f6dd6b471f..877828bb94 100644 --- a/lily/audio-element-info.cc +++ b/lily/audio-element-info.cc @@ -11,7 +11,7 @@ #include "translator-group.hh" #include "context.hh" -Audio_element_info::Audio_element_info (Audio_element *s, Music *r) +Audio_element_info::Audio_element_info (Audio_element *s, Stream_event *r) { elem_ = s; origin_trans_ = 0; diff --git a/lily/beam-performer.cc b/lily/beam-performer.cc index 0998ef3220..6d36c78381 100644 --- a/lily/beam-performer.cc +++ b/lily/beam-performer.cc @@ -10,6 +10,7 @@ #include "audio-item.hh" #include "audio-column.hh" #include "global-context.hh" +#include "stream-event.hh" #include "warn.hh" #include "music.hh" @@ -21,13 +22,13 @@ public: TRANSLATOR_DECLARATIONS (Beam_performer); protected: - virtual bool try_music (Music *ev); void start_translation_timestep (); void process_music (); void set_melisma (bool); + DECLARE_TRANSLATOR_LISTENER (beam); private: - Music *start_ev_; - Music *now_stop_ev_; + Stream_event *start_ev_; + Stream_event *now_stop_ev_; bool beam_; }; @@ -69,20 +70,16 @@ Beam_performer::start_translation_timestep () now_stop_ev_ = 0; } -bool -Beam_performer::try_music (Music *m) +IMPLEMENT_TRANSLATOR_LISTENER (Beam_performer, beam); +void +Beam_performer::listen_beam (Stream_event *ev) { - if (m->is_mus_type ("beam-event")) - { - Direction d = to_dir (m->get_property ("span-direction")); + Direction d = to_dir (ev->get_property ("span-direction")); - if (d == START) - start_ev_ = m; - else if (d == STOP) - now_stop_ev_ = m; - return true; - } - return false; + if (d == START) + start_ev_ = ev; + else if (d == STOP) + now_stop_ev_ = ev; } ADD_TRANSLATOR (Beam_performer, "", "", diff --git a/lily/cluster-engraver.cc b/lily/cluster-engraver.cc index faac5f79d0..df26f6a689 100644 --- a/lily/cluster-engraver.cc +++ b/lily/cluster-engraver.cc @@ -129,7 +129,7 @@ ADD_ACKNOWLEDGER (Cluster_spanner_engraver, note_column); ADD_TRANSLATOR (Cluster_spanner_engraver, /* doc */ "Engraves a cluster using Spanner notation ", /* create */ "ClusterSpanner ClusterSpannerBeacon", - /* accept */ "cluster-note-event busy-playing-event", + /* accept */ "cluster-note-event", /* read */ "", /* write */ ""); diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index 6fe80dc309..aee5e181c2 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -97,8 +97,6 @@ Completion_heads_engraver::try_music (Music *m) return true; } - else if (m->is_mus_type ("busy-playing-event")) - return note_events_.size () && is_first_; return false; } @@ -303,6 +301,6 @@ ADD_TRANSLATOR (Completion_heads_engraver, "@code{Note_heads_engraver}. It plays some trickery to " "break long notes and automatically tie them into the next measure.", /* create */ "NoteHead Dots Tie", - /* accept */ "busy-playing-event note-event", + /* accept */ "note-event", /* read */ "middleCPosition measurePosition measureLength", /* write */ ""); diff --git a/lily/drum-note-engraver.cc b/lily/drum-note-engraver.cc index 1d1b8d2331..7a0adbda6e 100644 --- a/lily/drum-note-engraver.cc +++ b/lily/drum-note-engraver.cc @@ -46,8 +46,6 @@ Drum_notes_engraver::try_music (Music *m) events_.push_back (m); return true; } - else if (m->is_mus_type ("busy-playing-event")) - return events_.size (); return false; } @@ -160,7 +158,7 @@ ADD_ACKNOWLEDGER (Drum_notes_engraver, note_column); ADD_TRANSLATOR (Drum_notes_engraver, /* doc */ "Generate noteheads.", /* create */ "NoteHead Dots Script", - /* accept */ "note-event busy-playing-event", + /* accept */ "note-event", /* read */ "drumStyleTable", /* write */ ""); diff --git a/lily/drum-note-performer.cc b/lily/drum-note-performer.cc index a29b7a1dee..112ad6972c 100644 --- a/lily/drum-note-performer.cc +++ b/lily/drum-note-performer.cc @@ -10,9 +10,10 @@ #include "audio-item.hh" #include "audio-column.hh" #include "global-context.hh" -#include "warn.hh" #include "pitch.hh" -#include "music.hh" +#include "stream-event.hh" +#include "translator.icc" +#include "warn.hh" class Drum_note_performer : public Performer { @@ -20,12 +21,11 @@ public: TRANSLATOR_DECLARATIONS (Drum_note_performer); protected: - virtual bool try_music (Music *ev); void stop_translation_timestep (); void process_music (); - + DECLARE_TRANSLATOR_LISTENER (note); private: - vector note_evs_; + vector note_evs_; vector notes_; }; @@ -40,7 +40,7 @@ Drum_note_performer::process_music () while (note_evs_.size ()) { - Music *n = note_evs_.back (); + Stream_event *n = note_evs_.back (); note_evs_.pop_back (); SCM sym = n->get_property ("drum-type"); SCM defn = SCM_EOL; @@ -51,7 +51,7 @@ Drum_note_performer::process_music () if (Pitch *pit = unsmob_pitch (defn)) { - Audio_note *p = new Audio_note (*pit, n->get_length (), 0); + Audio_note *p = new Audio_note (*pit, get_event_length (n), 0); Audio_element_info info (p, n); announce_element (info); notes_.push_back (p); @@ -73,22 +73,13 @@ Drum_note_performer::stop_translation_timestep () note_evs_.clear (); } -bool -Drum_note_performer::try_music (Music *ev) +IMPLEMENT_TRANSLATOR_LISTENER (Drum_note_performer, note); +void +Drum_note_performer::listen_note (Stream_event *ev) { - if (ev->is_mus_type ("note-event")) - { - note_evs_.push_back (ev); - return true; - } - else if (ev->is_mus_type ("busy-playing-event")) - return note_evs_.size (); - - return false; + note_evs_.push_back (ev); } -#include "translator.icc" - ADD_TRANSLATOR (Drum_note_performer, "Play drum notes.", "", - "note-event busy-playing-event", "", ""); + "note-event", "", ""); diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc index 05969cffad..1289051bbb 100644 --- a/lily/dynamic-performer.cc +++ b/lily/dynamic-performer.cc @@ -9,7 +9,7 @@ #include "performer.hh" #include "audio-item.hh" -#include "music.hh" +#include "stream-event.hh" #include "translator.icc" /* @@ -24,12 +24,12 @@ class Dynamic_performer : public Performer public: TRANSLATOR_DECLARATIONS (Dynamic_performer); protected: - virtual bool try_music (Music *event); void stop_translation_timestep (); void process_music (); + DECLARE_TRANSLATOR_LISTENER (absolute_dynamic); private: - Music *script_event_; + Stream_event *script_event_; Audio_dynamic *audio_; }; @@ -110,18 +110,12 @@ Dynamic_performer::stop_translation_timestep () } } -bool -Dynamic_performer::try_music (Music *r) +IMPLEMENT_TRANSLATOR_LISTENER (Dynamic_performer, absolute_dynamic); +void +Dynamic_performer::listen_absolute_dynamic (Stream_event *r) { if (!script_event_) - { - if (r->is_mus_type ("absolute-dynamic-event")) // fixme. - { - script_event_ = r; - return true; - } - } - return false; + script_event_ = r; } ADD_TRANSLATOR (Dynamic_performer, diff --git a/lily/easy-notation.cc b/lily/easy-notation.cc index fde6514345..6ddc00e1d3 100644 --- a/lily/easy-notation.cc +++ b/lily/easy-notation.cc @@ -11,14 +11,15 @@ #include using namespace std; -#include "text-interface.hh" +#include "font-interface.hh" #include "grob.hh" -#include "output-def.hh" #include "music.hh" +#include "output-def.hh" #include "pitch.hh" -#include "font-interface.hh" #include "staff-symbol-referencer.hh" #include "stem.hh" +#include "stream-event.hh" +#include "text-interface.hh" /* @@ -33,7 +34,7 @@ Note_head::brew_ez_stencil (SCM smob) int log = Note_head::get_balltype (me); SCM cause = me->get_property ("cause"); - SCM spitch = unsmob_music (cause)->get_property ("pitch"); + SCM spitch = unsmob_stream_event (cause)->get_property ("pitch"); Pitch *pit = unsmob_pitch (spitch); SCM idx = scm_from_int (pit->get_notename ()); diff --git a/lily/engraver.cc b/lily/engraver.cc index 7f7dc65f3a..cf2eebbe9b 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -8,13 +8,14 @@ #include "engraver.hh" +#include "context.hh" +#include "item.hh" +#include "lilypond-key.hh" #include "music.hh" #include "score-engraver.hh" -#include "warn.hh" #include "spanner.hh" -#include "item.hh" -#include "context.hh" -#include "lilypond-key.hh" +#include "stream-event.hh" +#include "warn.hh" Engraver_group * Engraver::get_daddy_engraver () const @@ -35,13 +36,18 @@ Engraver::announce_end_grob (Grob_info inf) } /* - CAUSE is the object (typically a Music object) that + CAUSE is the object (typically a Stream_event object) that was the reason for making E. */ void Engraver::announce_grob (Grob *e, SCM cause) { - if (unsmob_music (cause) || unsmob_grob (cause)) + /* TODO: Remove Music code when it's no longer needed */ + if (Music *m = unsmob_music (cause)) + { + cause = m->to_event ()->unprotect (); + } + if (unsmob_stream_event (cause) || unsmob_grob (cause)) e->set_property ("cause", cause); Grob_info i (this, e); @@ -59,7 +65,12 @@ Engraver::announce_grob (Grob *e, SCM cause) void Engraver::announce_end_grob (Grob *e, SCM cause) { - if (unsmob_music (cause) || unsmob_grob (cause)) + /* TODO: Remove Music code when it's no longer needed */ + if (Music *m = unsmob_music (cause)) + { + cause = m->to_event ()->unprotect (); + } + if (unsmob_stream_event (cause) || unsmob_grob (cause)) e->set_property ("cause", cause); Grob_info i (this, e); diff --git a/lily/grob-info.cc b/lily/grob-info.cc index a8f3f4c7b1..5ad3d5701e 100644 --- a/lily/grob-info.cc +++ b/lily/grob-info.cc @@ -6,13 +6,14 @@ (c) 1997--2006 Han-Wen Nienhuys */ +#include "context.hh" #include "grob-info.hh" #include "grob.hh" +#include "item.hh" #include "music.hh" -#include "translator-group.hh" -#include "context.hh" #include "spanner.hh" -#include "item.hh" +#include "stream-event.hh" +#include "translator-group.hh" Grob_info::Grob_info (Translator *t, Grob *g) { @@ -28,11 +29,29 @@ Grob_info::Grob_info () origin_trans_ = 0; } +/* ES TODO: Junk this when no more engravers use try_music */ Music * Grob_info::music_cause () const { SCM cause = grob_->get_property ("cause"); - return unsmob_music (cause); + + Music *ret = unsmob_music (cause); + if (ret) + return ret; + else + { + Stream_event *ev = unsmob_stream_event (cause); + if (!ev) + return 0; + return unsmob_music (ev->get_property ("music-cause")); + } +} + +Stream_event * +Grob_info::event_cause () const +{ + SCM cause = grob_->get_property ("cause"); + return unsmob_stream_event (cause); } vector @@ -68,6 +87,20 @@ Grob_info::item () const return dynamic_cast (grob_); } +Stream_event * +Grob_info::ultimate_event_cause () const +{ + SCM cause = grob_->self_scm (); + while (unsmob_grob (cause)) + { + cause = unsmob_grob (cause)->get_property ("cause"); + } + return unsmob_stream_event (cause); +} + +/* +ES TODO: Junk this when no more engraver uses try_music +*/ Music * Grob_info::ultimate_music_cause () const { @@ -77,6 +110,12 @@ Grob_info::ultimate_music_cause () const cause = unsmob_grob (cause)->get_property ("cause"); } - return unsmob_music (cause); + Music *ret = unsmob_music (cause); + if (ret) + return ret; + else + { + Stream_event *ev = unsmob_stream_event (cause); + return unsmob_music (ev->get_property ("music-cause")); + } } - diff --git a/lily/grob.cc b/lily/grob.cc index c1545de824..d13f127044 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -514,6 +514,7 @@ Grob::warning (string s) const while (Grob *g = unsmob_grob (cause)) cause = g->get_property ("cause"); + /* ES TODO: cause can't be Music*/ if (Music *m = unsmob_music (cause)) m->origin ()->warning (s); else if (Stream_event *ev = unsmob_stream_event (cause)) @@ -541,6 +542,7 @@ Grob::programming_error (string s) const s = _f ("programming error: %s", s); + /* ES TODO: cause can't be Music*/ if (Music *m = unsmob_music (cause)) m->origin ()->message (s); else if (Stream_event *ev = unsmob_stream_event (cause)) diff --git a/lily/include/audio-element-info.hh b/lily/include/audio-element-info.hh index 8eed595373..fd529bfde2 100644 --- a/lily/include/audio-element-info.hh +++ b/lily/include/audio-element-info.hh @@ -19,12 +19,12 @@ class Audio_element_info { public: Audio_element *elem_; - Music *event_; + Stream_event *event_; Translator *origin_trans_; vector origin_contexts (Translator *) const; - Audio_element_info (Audio_element *, Music *); + Audio_element_info (Audio_element *, Stream_event *); Audio_element_info (); }; diff --git a/lily/include/grob-info.hh b/lily/include/grob-info.hh index 4ed3790954..ebd860ef3a 100644 --- a/lily/include/grob-info.hh +++ b/lily/include/grob-info.hh @@ -29,7 +29,9 @@ public: Translator *origin_translator () const { return origin_trans_; } Context *context () const; + Stream_event *event_cause () const; Music *music_cause () const; + Stream_event *ultimate_event_cause () const; Music *ultimate_music_cause () const; vector origin_contexts (Translator *) const; Grob_info (Translator *, Grob *); diff --git a/lily/include/music.hh b/lily/include/music.hh index 3c43209b47..f09ba2f851 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -29,6 +29,8 @@ public: bool internal_is_music_type (SCM) const; + Stream_event *to_event () const; + DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM)); Pitch to_relative_octave (Pitch); Pitch generic_to_relative_octave (Pitch); @@ -46,7 +48,7 @@ public: void send_to_context (Context *c); DECLARE_SCHEME_CALLBACK (duration_length_callback, (SCM)); - + protected: virtual SCM copy_mutable_properties () const; virtual void type_check_assignment (SCM, SCM) const; diff --git a/lily/include/stream-event.hh b/lily/include/stream-event.hh index 0ac1b4712f..6a1f8d9845 100644 --- a/lily/include/stream-event.hh +++ b/lily/include/stream-event.hh @@ -19,6 +19,7 @@ public: Stream_event (); Input *origin () const; void set_spot (Input *i); + bool internal_in_event_class (SCM class_name); DECLARE_SCHEME_CALLBACK (undump, (SCM)); DECLARE_SCHEME_CALLBACK (dump, (SCM)); @@ -30,6 +31,8 @@ public: Stream_event (Stream_event *ev); }; +#define in_event_class(class_name) internal_in_event_class (ly_symbol2scm (class_name)) + Stream_event *unsmob_stream_event (SCM); DECLARE_TYPE_P (Stream_event); diff --git a/lily/include/translator.hh b/lily/include/translator.hh index eba2d6def4..f39b122d8b 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -137,5 +137,6 @@ protected: // should be private. void add_translator (Translator *trans); Translator *get_translator (SCM s); +Moment get_event_length (Stream_event *s); DECLARE_UNSMOB (Translator, translator); #endif // TRANSLATOR_HH diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 26dbe93a8d..c2fc6346cc 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -6,11 +6,14 @@ (c) 1997--2006 Jan Nieuwenhuizen */ -#include "music-sequence.hh" #include "audio-item.hh" +#include "music-sequence.hh" #include "performer.hh" +#include "stream-event.hh" #include "warn.hh" +#include "translator.icc" + class Key_performer : public Performer { public: @@ -18,12 +21,12 @@ public: ~Key_performer (); protected: - virtual bool try_music (Music *ev); void process_music (); void stop_translation_timestep (); + DECLARE_TRANSLATOR_LISTENER (key_change); private: - Music *key_ev_; + Stream_event *key_ev_; Audio_key *audio_; }; @@ -85,17 +88,14 @@ Key_performer::stop_translation_timestep () } } -bool -Key_performer::try_music (Music *ev) +IMPLEMENT_TRANSLATOR_LISTENER (Key_performer, key_change); +void +Key_performer::listen_key_change (Stream_event *ev) { if (!key_ev_) key_ev_ = ev; - - return true; } -#include "translator.icc" - ADD_TRANSLATOR (Key_performer, "", "", "key-change-event", diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc index 935f06c35e..5e3a919b2c 100644 --- a/lily/lyric-performer.cc +++ b/lily/lyric-performer.cc @@ -8,7 +8,8 @@ #include "audio-item.hh" #include "performer.hh" -#include "music.hh" +#include "stream-event.hh" +#include "translator.icc" class Lyric_performer : public Performer { @@ -16,12 +17,11 @@ public: TRANSLATOR_DECLARATIONS (Lyric_performer); protected: - virtual bool try_music (Music *event); void stop_translation_timestep (); - void process_music (); - + void process_music (); + DECLARE_TRANSLATOR_LISTENER (lyric); private: - vector events_; + vector events_; Audio_text *audio_; }; @@ -57,18 +57,12 @@ Lyric_performer::stop_translation_timestep () events_.clear (); } -bool -Lyric_performer::try_music (Music *event) +IMPLEMENT_TRANSLATOR_LISTENER (Lyric_performer, lyric); +void +Lyric_performer::listen_lyric (Stream_event *event) { - if (event->is_mus_type ("lyric-event")) - { - events_.push_back (event); - return true; - } - return false; + events_.push_back (event); } -#include "translator.icc" - ADD_TRANSLATOR (Lyric_performer, "", "", "lyric-event", "", ""); diff --git a/lily/music.cc b/lily/music.cc index 88f38f6a38..246074f475 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -236,17 +236,13 @@ Music::origin () const return ip ? ip : &dummy_input_global; } -void -Music::send_to_context (Context *c) +/* + ES TODO: This method should probably be reworked or junked. +*/ +Stream_event * +Music::to_event () const { - /* - TODO: This is a work-in-progress solution. Send the event so it - can be read both by old-style translators and the new ones. - */ - send_stream_event (c, "OldMusicEvent", origin (), - ly_symbol2scm("music"), self_scm (), 0); - - /* UGH. This is a temp hack for Music->Stream_event transition */ + /* UGH. Temp hack */ SCM orig_sym = get_property ("name"); char out[200]; string in = ly_symbol2string (orig_sym); @@ -261,9 +257,33 @@ Music::send_to_context (Context *c) } out[outpos] = 0; SCM class_name = ly_symbol2scm (out); - + Stream_event *e = new Stream_event (class_name, mutable_property_alist_); - c->event_source ()->broadcast (e); + Moment length = get_length (); + if (length.to_bool ()) + e->set_property ("length", length.smobbed_copy ()); + + /* + 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) +{ + /* + TODO: This is a work-in-progress solution. Send the event so it + can be read both by old-style translators and the new ones. + */ + send_stream_event (c, "OldMusicEvent", origin (), + ly_symbol2scm("music"), self_scm (), 0); + + Stream_event *ev = to_event (); + c->event_source ()->broadcast (ev); + ev->unprotect (); } Music * diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index 7b91132246..d650b675e7 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -45,8 +45,6 @@ Note_heads_engraver::try_music (Music *m) note_evs_.push_back (m); return true; } - else if (m->is_mus_type ("busy-playing-event")) - return note_evs_.size (); return false; } @@ -132,7 +130,6 @@ ADD_TRANSLATOR (Note_heads_engraver, "NoteHead " "Dots", /* accept */ - "note-event " - "busy-playing-event", + "note-event", /* read */ "middleCPosition", /* write */ ""); diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 331e7cc60f..a9acca733a 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -10,8 +10,10 @@ #include "audio-item.hh" #include "audio-column.hh" #include "global-context.hh" +#include "stream-event.hh" #include "warn.hh" -#include "music.hh" + +#include "translator.icc" /** Convert evs to audio notes. @@ -22,13 +24,12 @@ public: TRANSLATOR_DECLARATIONS (Note_performer); protected: - virtual bool try_music (Music *ev); - void stop_translation_timestep (); void process_music (); + DECLARE_TRANSLATOR_LISTENER (note); private: - vector note_evs_; + vector note_evs_; vector notes_; }; @@ -45,13 +46,13 @@ Note_performer::process_music () while (note_evs_.size ()) { - Music *n = note_evs_.back (); + Stream_event *n = note_evs_.back (); note_evs_.pop_back (); SCM pit = n->get_property ("pitch"); if (Pitch *pitp = unsmob_pitch (pit)) { - Audio_note *p = new Audio_note (*pitp, n->get_length (), - transposing); + Audio_note *p = new Audio_note (*pitp, get_event_length (n), - transposing); Audio_element_info info (p, n); announce_element (info); notes_.push_back (p); @@ -73,25 +74,15 @@ Note_performer::stop_translation_timestep () note_evs_.clear (); } -bool -Note_performer::try_music (Music *ev) +IMPLEMENT_TRANSLATOR_LISTENER (Note_performer, note) +void +Note_performer::listen_note (Stream_event *ev) { - if (ev->is_mus_type ("note-event")) - { - note_evs_.push_back (ev); - return true; - } - else if (ev->is_mus_type ("busy-playing-event")) - return note_evs_.size (); - - return false; + note_evs_.push_back (ev); } -#include "translator.icc" - ADD_TRANSLATOR (Note_performer, "", "", - "note-event " - "busy-playing-event", + "note-event ", "", ""); Note_performer::Note_performer () diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc index 4083c468f9..4048bb57a7 100644 --- a/lily/piano-pedal-performer.cc +++ b/lily/piano-pedal-performer.cc @@ -10,7 +10,15 @@ #include "audio-item.hh" #include "international.hh" -#include "music.hh" +#include "stream-event.hh" +#include "warn.hh" + +#include "translator.icc" + +#define SOSTENUTO 0 +#define SUSTAIN 1 +#define UNA_CORDA 2 +#define NUM_PEDAL_TYPES 3 /** perform Piano pedals @@ -19,71 +27,76 @@ class Piano_pedal_performer : public Performer { struct Pedal_info { - char const *name_; - Music *start_event_; - Drul_array event_drul_; + Stream_event *start_event_; + Drul_array event_drul_; }; public: TRANSLATOR_DECLARATIONS (Piano_pedal_performer); - ~Piano_pedal_performer (); protected: virtual void initialize (); - virtual bool try_music (Music *); + static const char *pedal_type_str (int t); void process_music (); void stop_translation_timestep (); void start_translation_timestep (); - + DECLARE_TRANSLATOR_LISTENER (sustain); + DECLARE_TRANSLATOR_LISTENER (una_corda); + DECLARE_TRANSLATOR_LISTENER (sostenuto); private: vector audios_; - Pedal_info *info_alist_; + Pedal_info info_alist_[NUM_PEDAL_TYPES]; }; Piano_pedal_performer::Piano_pedal_performer () { - info_alist_ = 0; } -Piano_pedal_performer::~Piano_pedal_performer () +const char * +Piano_pedal_performer::pedal_type_str (int t) { - delete[] info_alist_; + switch (t) + { + case SOSTENUTO: + return "Sostenuto"; + case SUSTAIN: + return "Sustain"; + case UNA_CORDA: + return "UnaCorda"; + default: + programming_error ("Unknown pedal type"); + return 0; + } } void Piano_pedal_performer::initialize () { - info_alist_ = new Pedal_info[4]; Pedal_info *p = info_alist_; - char *names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 }; - char **np = names; - do + for (int i = 0; i < NUM_PEDAL_TYPES; i++, p++) { - p->name_ = *np; p->event_drul_[START] = 0; p->event_drul_[STOP] = 0; p->start_event_ = 0; - - p++; } - while (* (np++)); } void Piano_pedal_performer::process_music () { - for (Pedal_info *p = info_alist_; p && p->name_; p++) + Pedal_info *p = info_alist_; + for (int i = 0; i < NUM_PEDAL_TYPES; i++, p++) { if (p->event_drul_[STOP]) { if (!p->start_event_) - p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", string (p->name_))); + p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", pedal_type_str (i))); else { Audio_piano_pedal *a = new Audio_piano_pedal; - a->type_string_ = string (p->name_); + a->type_string_ = string (pedal_type_str (i)); a->dir_ = STOP; audios_.push_back (a); Audio_element_info info(a, p->event_drul_[STOP]); @@ -96,7 +109,7 @@ Piano_pedal_performer::process_music () { p->start_event_ = p->event_drul_[START]; Audio_piano_pedal *a = new Audio_piano_pedal; - a->type_string_ = string (p->name_); + a->type_string_ = string (pedal_type_str (i)); a->dir_ = START; audios_.push_back (a); Audio_element_info info(a, p->event_drul_[START]); @@ -118,34 +131,37 @@ Piano_pedal_performer::stop_translation_timestep () void Piano_pedal_performer::start_translation_timestep () { - for (Pedal_info *p = info_alist_; p && p->name_; p++) + Pedal_info *p = info_alist_; + for (int i = 0; i < NUM_PEDAL_TYPES; i++, p++) { p->event_drul_[STOP] = 0; p->event_drul_[START] = 0; } } -bool -Piano_pedal_performer::try_music (Music *r) +IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_performer, sostenuto); +void +Piano_pedal_performer::listen_sostenuto (Stream_event *r) { - if (r->is_mus_type ("pedal-event")) - { - for (Pedal_info *p = info_alist_; p->name_; p++) - { - string nm = p->name_ + string ("Event"); - if (ly_is_equal (r->get_property ("name"), - scm_str2symbol (nm.c_str ()))) - { - Direction d = to_dir (r->get_property ("span-direction")); - p->event_drul_[d] = r; - return true; - } - } - } - return false; + Direction d = to_dir (r->get_property ("span-direction")); + info_alist_[SOSTENUTO].event_drul_[d] = r; } -#include "translator.icc" +IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_performer, sustain); +void +Piano_pedal_performer::listen_sustain (Stream_event *r) +{ + Direction d = to_dir (r->get_property ("span-direction")); + info_alist_[SUSTAIN].event_drul_[d] = r; +} + +IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_performer, una_corda); +void +Piano_pedal_performer::listen_una_corda (Stream_event *r) +{ + Direction d = to_dir (r->get_property ("span-direction")); + info_alist_[UNA_CORDA].event_drul_[d] = r; +} ADD_TRANSLATOR (Piano_pedal_performer, "", "", "pedal-event", diff --git a/lily/slur-performer.cc b/lily/slur-performer.cc index b699058f21..447897d8b6 100644 --- a/lily/slur-performer.cc +++ b/lily/slur-performer.cc @@ -10,8 +10,10 @@ #include "audio-item.hh" #include "audio-column.hh" #include "global-context.hh" +#include "stream-event.hh" #include "warn.hh" -#include "music.hh" + +#include "translator.icc" /* this is C&P from beam_performer. @@ -23,13 +25,14 @@ public: TRANSLATOR_DECLARATIONS (Slur_performer); protected: - virtual bool try_music (Music *ev); void start_translation_timestep (); void process_music (); void set_melisma (bool); + + DECLARE_TRANSLATOR_LISTENER (slur); private: - Music *start_ev_; - Music *now_stop_ev_; + Stream_event *start_ev_; + Stream_event *now_stop_ev_; bool slur_; }; @@ -69,26 +72,19 @@ Slur_performer::start_translation_timestep () now_stop_ev_ = 0; } -bool -Slur_performer::try_music (Music *m) +IMPLEMENT_TRANSLATOR_LISTENER (Slur_performer, slur); +void +Slur_performer::listen_slur (Stream_event *ev) { - if (m->is_mus_type ("slur-event")) - { - Direction d = to_dir (m->get_property ("span-direction")); + Direction d = to_dir (ev->get_property ("span-direction")); - if (d == START) - start_ev_ = m; - else if (d == STOP) - now_stop_ev_ = m; - return true; - } - return false; + if (d == START) + start_ev_ = ev; + else if (d == STOP) + now_stop_ev_ = ev; } -#include "translator.icc" - ADD_TRANSLATOR (Slur_performer, "", "", "slur-event", "", ""); - diff --git a/lily/span-dynamic-performer.cc b/lily/span-dynamic-performer.cc index 3d8d053be2..755dd86925 100644 --- a/lily/span-dynamic-performer.cc +++ b/lily/span-dynamic-performer.cc @@ -10,7 +10,9 @@ #include "audio-item.hh" #include "international.hh" -#include "music.hh" +#include "stream-event.hh" + +#include "translator.icc" /* TODO: fold this into 1 engraver: \< and \> should also stop when @@ -31,16 +33,17 @@ public: TRANSLATOR_DECLARATIONS (Span_dynamic_performer); protected: - virtual bool try_music (Music *); virtual void acknowledge_audio_element (Audio_element_info); void process_music (); void stop_translation_timestep (); + DECLARE_TRANSLATOR_LISTENER (decrescendo); + DECLARE_TRANSLATOR_LISTENER (crescendo); private: Audio_dynamic *audio_; Real last_volume_; - Music *span_start_event_; - Drul_array span_events_; + Stream_event *span_start_event_; + Drul_array span_events_; vector dynamic_tuples_; vector finished_dynamic_tuples_; Direction dir_; @@ -95,7 +98,7 @@ Span_dynamic_performer::process_music () if (span_events_[START]) { - dir_ = (span_events_[START]->is_mus_type ("crescendo-event")) + dir_ = (span_events_[START]->in_event_class ("crescendo-event")) ? RIGHT : LEFT; span_start_event_ = span_events_[START]; @@ -163,19 +166,21 @@ Span_dynamic_performer::stop_translation_timestep () span_events_[START] = 0; } -bool -Span_dynamic_performer::try_music (Music *r) +IMPLEMENT_TRANSLATOR_LISTENER (Span_dynamic_performer, decrescendo); +void +Span_dynamic_performer::listen_decrescendo (Stream_event *r) { - if (r->is_mus_type ("crescendo-event") - || r->is_mus_type ("decrescendo-event")) - { - Direction d = to_dir (r->get_property ("span-direction")); - span_events_[d] = r; - return true; - } - return false; + Direction d = to_dir (r->get_property ("span-direction")); + span_events_[d] = r; +} + +IMPLEMENT_TRANSLATOR_LISTENER (Span_dynamic_performer, crescendo); +void +Span_dynamic_performer::listen_crescendo (Stream_event *r) +{ + Direction d = to_dir (r->get_property ("span-direction")); + span_events_[d] = r; } -#include "translator.icc" ADD_TRANSLATOR (Span_dynamic_performer, "", "", diff --git a/lily/stream-event-scheme.cc b/lily/stream-event-scheme.cc index bdccd1483b..ce337d5472 100644 --- a/lily/stream-event-scheme.cc +++ b/lily/stream-event-scheme.cc @@ -17,7 +17,7 @@ LY_DEFINE (ly_make_stream_event, "ly:make-stream-event", return e->unprotect (); } -LY_DEFINE (ly_stream_event_property, "ly:stream-event-property", +LY_DEFINE (ly_event_property, "ly:event-property", 2, 0, 0, (SCM sev, SCM sym), "Get the property @var{sym} of stream event @var{mus}.\n" "If @var{sym} is undefined, return @code{' ()}.\n") diff --git a/lily/stream-event.cc b/lily/stream-event.cc index e9fe80a22f..1019c9e85b 100644 --- a/lily/stream-event.cc +++ b/lily/stream-event.cc @@ -13,6 +13,8 @@ #include "input.hh" #include "input-smob.hh" +/* TODO: Rename Stream_event -> Event */ + Stream_event::Stream_event () : Prob (ly_symbol2scm ("Stream_event"), SCM_EOL) { @@ -53,11 +55,20 @@ Stream_event::origin () const return i ? i : &dummy_input_global; } -void Stream_event::set_spot (Input *i) +void +Stream_event::set_spot (Input *i) { set_property ("origin", make_input (*i)); } +bool +Stream_event::internal_in_event_class (SCM class_name) +{ + SCM cl = get_property ("class"); + cl = scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), cl); + return scm_c_memq (class_name, cl) != SCM_BOOL_F; +} + IMPLEMENT_TYPE_P (Stream_event, "ly:stream-event?"); MAKE_SCHEME_CALLBACK (Stream_event, undump, 1); diff --git a/lily/swallow-perf.cc b/lily/swallow-perf.cc index 150e61b274..a2e3aa7b85 100644 --- a/lily/swallow-perf.cc +++ b/lily/swallow-perf.cc @@ -20,8 +20,7 @@ protected: bool Swallow_performer::try_music (Music *m) { - if (m->is_mus_type ("busy-playing-event") - || m->is_mus_type ("melisma-playing-event")) + if (m->is_mus_type ("melisma-playing-event")) return false; else return true; diff --git a/lily/tab-note-heads-engraver.cc b/lily/tab-note-heads-engraver.cc index be9fa38515..b6f3f4ced9 100644 --- a/lily/tab-note-heads-engraver.cc +++ b/lily/tab-note-heads-engraver.cc @@ -58,8 +58,6 @@ Tab_note_heads_engraver::try_music (Music *m) tabstring_events_.push_back (m); return true; } - else if (m->is_mus_type ("busy-playing-event")) - return note_events_.size (); return false; } @@ -168,7 +166,7 @@ Tab_note_heads_engraver::stop_translation_timestep () ADD_TRANSLATOR (Tab_note_heads_engraver, /* doc */ "Generate one or more tablature noteheads from Music of type NoteEvent.", /* create */ "TabNoteHead Dots", - /* accept */ "note-event string-number-event busy-playing-event", + /* accept */ "note-event string-number-event", /* read */ "middleCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost", /* write */ ""); diff --git a/lily/tempo-performer.cc b/lily/tempo-performer.cc index 9a70f9cdc4..e21f617b60 100644 --- a/lily/tempo-performer.cc +++ b/lily/tempo-performer.cc @@ -9,8 +9,10 @@ #include "performer.hh" #include "audio-item.hh" -#include "music.hh" #include "duration.hh" +#include "stream-event.hh" + +#include "translator.icc" class Tempo_performer : public Performer { @@ -20,12 +22,11 @@ public: protected: - virtual bool try_music (Music *event); void stop_translation_timestep (); void process_music (); - + DECLARE_TRANSLATOR_LISTENER (metronome_change); private: - Music *tempo_event_; + Stream_event *tempo_event_; Audio_tempo *audio_; }; @@ -67,18 +68,13 @@ Tempo_performer::stop_translation_timestep () } } -bool -Tempo_performer::try_music (Music *event) +IMPLEMENT_TRANSLATOR_LISTENER (Tempo_performer, metronome_change); +void +Tempo_performer::listen_metronome_change (Stream_event *event) { - if (tempo_event_) - return false; - tempo_event_ = event; - return true; } -#include "translator.icc" - ADD_TRANSLATOR (Tempo_performer, "", "", "metronome-change-event", "", ""); diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index c7484ed0b7..2341c3d08e 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -16,6 +16,7 @@ #include "protected-scm.hh" #include "spanner.hh" #include "staff-symbol-referencer.hh" +#include "stream-event.hh" #include "tie-column.hh" #include "tie.hh" #include "warn.hh" @@ -103,15 +104,15 @@ Tie_engraver::acknowledge_note_head (Grob_info i) for (vsize i = heads_to_tie_.size (); i--;) { Grob *th = heads_to_tie_[i].head_; - Music *right_mus = unsmob_music (h->get_property ("cause")); - Music *left_mus = unsmob_music (th->get_property ("cause")); + Stream_event *right_ev = unsmob_stream_event (h->get_property ("cause")); + Stream_event *left_ev = unsmob_stream_event (th->get_property ("cause")); /* maybe should check positions too. */ - if (right_mus && left_mus - && ly_is_equal (right_mus->get_property ("pitch"), - left_mus->get_property ("pitch"))) + if (right_ev && left_ev + && ly_is_equal (right_ev->get_property ("pitch"), + left_ev->get_property ("pitch"))) { Grob *p = new Spanner (heads_to_tie_[i].tie_definition_, context ()->get_grob_key ("Tie")); @@ -176,8 +177,8 @@ Tie_engraver::stop_translation_timestep () for (vsize i = 0; i < now_heads_.size (); i++) { Grob *head = now_heads_[i]; - Music *left_mus = unsmob_music (head->get_property ("cause")); - if (left_mus) + Stream_event *left_ev = unsmob_stream_event (head->get_property ("cause")); + if (left_ev) { Head_event_tuple event_tup; @@ -188,11 +189,11 @@ Tie_engraver::stop_translation_timestep () Moment end = now_mom (); if (end.grace_part_) { - end.grace_part_ += left_mus->get_length ().main_part_; + end.grace_part_ += get_event_length (left_ev).main_part_; } else { - end += left_mus->get_length (); + end += get_event_length (left_ev); } event_tup.end_moment_ = end; diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index bf3c513bcb..5e1256453e 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -8,15 +8,16 @@ #include "performer.hh" -#include "music.hh" -#include "context.hh" #include "audio-item.hh" +#include "context.hh" #include "pqueue.hh" +#include "stream-event.hh" +#include "translator.icc" class Tie_performer : public Performer { - Music *event_; - Music *last_event_; + Stream_event *event_; + Stream_event *last_event_; vector now_heads_; vector heads_to_tie_; @@ -26,8 +27,8 @@ protected: void stop_translation_timestep (); void start_translation_timestep (); virtual void acknowledge_audio_element (Audio_element_info); - virtual bool try_music (Music *); void process_music (); + DECLARE_TRANSLATOR_LISTENER (tie); public: TRANSLATOR_DECLARATIONS (Tie_performer); }; @@ -39,13 +40,11 @@ Tie_performer::Tie_performer () ties_created_ = false; } -bool -Tie_performer::try_music (Music *mus) +IMPLEMENT_TRANSLATOR_LISTENER (Tie_performer, tie); +void +Tie_performer::listen_tie (Stream_event *ev) { - if (mus->is_mus_type ("tie-event")) - event_ = mus; - - return true; + event_ = ev; } void @@ -63,10 +62,10 @@ Tie_performer::acknowledge_audio_element (Audio_element_info inf) now_heads_.push_back (inf); for (vsize i = heads_to_tie_.size (); i--;) { - Music *right_mus = inf.event_; + Stream_event *right_mus = inf.event_; Audio_note *th = dynamic_cast (heads_to_tie_[i].elem_); - Music *left_mus = heads_to_tie_[i].event_; + Stream_event *left_mus = heads_to_tie_[i].event_; if (right_mus && left_mus && ly_is_equal (right_mus->get_property ("pitch"), @@ -105,8 +104,6 @@ Tie_performer::stop_translation_timestep () now_heads_.clear (); } -#include "translator.icc" - ADD_TRANSLATOR (Tie_performer, /* doc */ "Generate ties between noteheads of equal pitch.", /* create */ "", diff --git a/lily/translator.cc b/lily/translator.cc index 7bd0e6b47e..6eab93b9a8 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -231,6 +231,16 @@ generic_get_acknowledger (SCM sym, vector const *ack_ar return 0; } +Moment +get_event_length (Stream_event *e) +{ + Moment *m = unsmob_moment (e->get_property ("length")); + if (m) + return *m; + else + return Moment (0); +} + ADD_TRANSLATOR (Translator, "Base class. Unused", "", diff --git a/scm/define-event-classes.scm b/scm/define-event-classes.scm index 86245efcbb..f70e4d57c3 100644 --- a/scm/define-event-classes.scm +++ b/scm/define-event-classes.scm @@ -13,7 +13,13 @@ ((RemoveContext ChangeParent Override Revert UnsetProperty SetProperty MusicEvent OldMusicEvent CreateContext Prepare OneTimeStep Finish) . StreamEvent) - ((arpeggio-event) . MusicEvent) + ((arpeggio-event + beam-event note-event absolute-dynamic-event + key-change-event lyric-event pedal-event slur-event tie-event + metronome-change-event span-dynamic-event) + . MusicEvent) + ((decrescendo-event crescendo-event) . span-dynamic-event) + ((sostenuto-event sustain-event una-corda-event) . pedal-event) ((Announcement) . '()) ((AnnounceNewContext) . Announcement) )) diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index 757e9e3a1e..489e27b2a2 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -124,12 +124,6 @@ Syntax: (types . (general-music event breathing-event)) )) - (BusyPlayingEvent - . ( - (description . "Used internally to signal beginning and ending of notes.") - - (types . (general-music event busy-playing-event)) - )) (ContextChange . ( (description . "Change staffs in Piano staff. diff --git a/scm/framework-gnome.scm b/scm/framework-gnome.scm index 7243ccebbc..9e8cf4510d 100644 --- a/scm/framework-gnome.scm +++ b/scm/framework-gnome.scm @@ -193,12 +193,12 @@ (define location-callback spawn-editor) (define (get-location grob) - (and-let* ((p? (procedure? point-and-click)) + (and-let* ((p (procedure? point-and-click)) (g grob) (cause (ly:grob-property grob 'cause)) - (music-origin (if (ly:music? cause) - (ly:music-property cause 'origin) - ;; How come # [and '()] + (music-origin (if (ly:event? cause) + (ly:event-property cause 'origin) + ;; How come # [and '()] ;; are #t? :-( #f))) (if (ly:input-location? music-origin) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index e38d967e95..561184cbe9 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -248,17 +248,17 @@ centered, X==1 is at the right, X == -1 is at the left." (define-public (tuplet-number::calc-denominator-text grob) (let* - ((mus (ly:grob-property grob 'cause))) + ((ev (ly:grob-property grob 'cause))) - (number->string (ly:music-property mus 'denominator)))) + (number->string (ly:event-property ev 'denominator)))) (define-public (tuplet-number::calc-fraction-text grob) (let* - ((mus (ly:grob-property grob 'cause))) + ((ev (ly:grob-property grob 'cause))) (format "~a:~a" - (ly:music-property mus 'denominator) - (ly:music-property mus 'numerator)))) + (ly:event-property ev 'denominator) + (ly:event-property ev 'numerator)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Color diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 94d53f71de..010e8f15a2 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -174,8 +174,8 @@ (define (grob-cause offset grob) (let* ((cause (ly:grob-property grob 'cause)) - (music-origin (if (ly:music? cause) - (ly:music-property cause 'origin)))) + (music-origin (if (ly:stream-event? cause) + (ly:event-property cause 'origin)))) (if (not (ly:input-location? music-origin)) "" (let* ((location (ly:input-file-line-char-column music-origin)) diff --git a/scm/output-socket.scm b/scm/output-socket.scm index c8a0fac3c7..e992e7c74b 100644 --- a/scm/output-socket.scm +++ b/scm/output-socket.scm @@ -49,12 +49,12 @@ breapth width depth height blot-diameter )) -(define (music-cause grob) +(define (event-cause grob) (let* ((cause (ly:grob-property grob 'cause))) (cond - ((ly:music? cause) cause) + ((ly:stream-event? cause) cause) ; ((ly:grob? cause) (music-cause cause)) (else #f)))) @@ -83,9 +83,9 @@ (define-public (grob-cause offset grob) (let* - ((cause (music-cause grob)) - (tag (if (and cause (integer? (ly:music-property cause 'input-tag))) - (ly:music-property cause 'input-tag) + ((cause (event-cause grob)) + (tag (if (and cause (integer? (ly:event-property cause 'input-tag))) + (ly:event-property cause 'input-tag) -1)) (name (cdr (assoc 'name (ly:grob-property grob 'meta)))) ) diff --git a/scm/output-tex.scm b/scm/output-tex.scm index 9068f5b937..c9697f5f12 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -173,8 +173,8 @@ (if (procedure? point-and-click) (let* ((cause (ly:grob-property grob 'cause)) - (music-origin (if (ly:music? cause) - (ly:music-property cause 'origin))) + (music-origin (if (ly:stream-event? cause) + (ly:event-property cause 'origin))) (location (if (ly:input-location? music-origin) (ly:input-file-line-column music-origin)))) (if (pair? location) diff --git a/scm/stencil.scm b/scm/stencil.scm index e4befe50d3..cf810d6bd3 100644 --- a/scm/stencil.scm +++ b/scm/stencil.scm @@ -310,13 +310,13 @@ grestore rest)) expr)) - (define (music-cause grob) + (define (event-cause grob) (let* ((cause (ly:grob-property grob 'cause))) (cond - ((ly:music? cause) cause) - ((ly:grob? cause) (music-cause cause)) + ((ly:stream-event? cause) cause) + ((ly:grob? cause) (event-cause cause)) (else #f)))) (define (pythonic-string expr) @@ -341,8 +341,8 @@ grestore ((grob (car expr)) (rest (cdr expr)) (collected '()) - (cause (music-cause grob)) - (input (if (ly:music? cause) (ly:music-property cause 'origin) #f)) + (cause (event-cause grob)) + (input (if (ly:stream-event? cause) (ly:event-property cause 'origin) #f)) (location (if (ly:input-location? input) (ly:input-file-line-char-column input) '())) (x-ext (ly:grob-extent grob system-grob X))