From: Erik Sandberg Date: Fri, 22 Sep 2006 07:51:37 +0000 (+0000) Subject: * lily/translator.cc, lily/context.cc:, lily/translator-group.cc: X-Git-Tag: cvs/HEAD~68 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=68f8545bd6a0221ee1100336e4ad49399a7ffaa4;p=lilypond.git * lily/translator.cc, lily/context.cc:, lily/translator-group.cc: remove try_music * lily/*-engraver.cc, lily/*-performer.cc: Remove all remaining references to Music; use ASSIGN_EVENT_ONCE everywhere * lily/grob-info.cc: junk *music_cause * lily/music.cc: copy eventified articulations to stream event * lily/part-combine-iterator.cc: Cleanup using enums * lily/translator-group.cc: Junk OldMusicEvent, and associated methods * lily/include/engraver.hh: Junk music.hh include * lily/stream-event.cc: Changed constructors --- diff --git a/ChangeLog b/ChangeLog index bf5710c049..f0d3b2a493 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,25 @@ hidden_state. Works around a problem when parser fetches MUSIC_FUNCTION token but not the following EXPECT_* token. + * lily/translator.cc, lily/context.cc:, lily/translator-group.cc: + remove try_music + + * lily/*-engraver.cc, lily/*-performer.cc: Remove all remaining + references to Music; use ASSIGN_EVENT_ONCE everywhere + + * lily/grob-info.cc: junk *music_cause + + * lily/music.cc: copy eventified articulations to stream event + + * lily/part-combine-iterator.cc: Cleanup using enums + + * lily/translator-group.cc: Junk OldMusicEvent, and associated + methods + + * lily/include/engraver.hh: Junk music.hh include + + * lily/stream-event.cc: Changed constructors + 2006-09-21 Graham Percival * Documentation/user/tweaks.itely (Fitting music onto fewer diff --git a/flower/include/international.hh b/flower/include/international.hh index d1c71ed08b..162e7ee38d 100644 --- a/flower/include/international.hh +++ b/flower/include/international.hh @@ -31,6 +31,10 @@ string _ (char const *ch); string _f (char const *format, ...) __attribute__ ((format (printf, 1, 2))); string _f (char const *format, string s, string s2 = "", string s3 = ""); +/** + va_list version of _f + */ +string v_f (char const *format, va_list args); #endif // INTERNATIONAL_HH diff --git a/flower/international.cc b/flower/international.cc index 7bb4130856..ef1ebfbc89 100644 --- a/flower/international.cc +++ b/flower/international.cc @@ -32,11 +32,17 @@ _f (char const *format, ...) { va_list args; va_start (args, format); - string str = String_convert::vform_string (gettext (format), args); + string str = v_f (format, args); va_end (args); return str; } +string +v_f (char const *format, va_list args) +{ + return String_convert::vform_string (gettext (format), args); +} + string _f (char const *format, string s, string s2, string s3) { diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index 39a66ba953..f6ea8e0e18 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -12,11 +12,11 @@ #include "context.hh" #include "engraver.hh" #include "international.hh" -#include "music.hh" #include "pitch.hh" #include "protected-scm.hh" #include "rhythmic-head.hh" #include "side-position-interface.hh" +#include "stream-event.hh" #include "tie.hh" #include "warn.hh" @@ -26,7 +26,7 @@ class Accidental_entry { public: bool done_; - Music *melodic_; + Stream_event *melodic_; Grob *accidental_; Context *origin_; Engraver *origin_engraver_; @@ -51,8 +51,8 @@ class Accidental_engraver : public Engraver int get_bar_number (); void update_local_key_signature (); void create_accidental (Accidental_entry *entry, bool, bool); - Grob *make_standard_accidental (Music *note, Grob *note_head, Engraver *trans); - Grob *make_suggested_accidental (Music *note, Grob *note_head, Engraver *trans); + Grob *make_standard_accidental (Stream_event *note, Grob *note_head, Engraver *trans); + Grob *make_suggested_accidental (Stream_event *note, Grob *note_head, Engraver *trans); protected: TRANSLATOR_DECLARATIONS (Accidental_engraver); @@ -316,7 +316,7 @@ Accidental_engraver::process_acknowledged () continue; accidentals_[i].done_ = true; - Music *note = accidentals_[i].melodic_; + Stream_event *note = accidentals_[i].melodic_; Context *origin = accidentals_[i].origin_; Pitch *pitch = unsmob_pitch (note->get_property ("pitch")); @@ -348,7 +348,7 @@ Accidental_engraver::process_acknowledged () /* Cannot look for ties: it's not guaranteed that they reach us before the notes. */ if (num - && !note->is_mus_type ("trill-span-event")) + && !note->in_event_class ("trill-span-event")) create_accidental (&accidentals_[i], num > 1, cautionary); } } @@ -359,7 +359,7 @@ Accidental_engraver::create_accidental (Accidental_entry *entry, bool restore_natural, bool cautionary) { - Music *note = entry->melodic_; + Stream_event *note = entry->melodic_; Grob *support = entry->head_; Pitch *pitch = unsmob_pitch (note->get_property ("pitch")); @@ -387,7 +387,7 @@ Accidental_engraver::create_accidental (Accidental_entry *entry, } Grob * -Accidental_engraver::make_standard_accidental (Music *note, +Accidental_engraver::make_standard_accidental (Stream_event *note, Grob *note_head, Engraver *trans) { @@ -433,7 +433,7 @@ Accidental_engraver::make_standard_accidental (Music *note, } Grob * -Accidental_engraver::make_suggested_accidental (Music *note, +Accidental_engraver::make_suggested_accidental (Stream_event *note, Grob *note_head, Engraver *trans) { @@ -481,7 +481,7 @@ Accidental_engraver::stop_translation_timestep () { int barnum = get_bar_number (); - Music *note = accidentals_[i].melodic_; + Stream_event *note = accidentals_[i].melodic_; Context *origin = accidentals_[i].origin_; Pitch *pitch = unsmob_pitch (note->get_property ("pitch")); @@ -537,10 +537,10 @@ Accidental_engraver::stop_translation_timestep () void Accidental_engraver::acknowledge_rhythmic_head (Grob_info info) { - Music *note = info.music_cause (); + Stream_event *note = info.event_cause (); if (note - && (note->is_mus_type ("note-event") - || note->is_mus_type ("trill-span-event"))) + && (note->in_event_class ("note-event") + || note->in_event_class ("trill-span-event"))) { /* string harmonics usually don't have accidentals. diff --git a/lily/ambitus-engraver.cc b/lily/ambitus-engraver.cc index f71c33b49c..1321c5bf6e 100644 --- a/lily/ambitus-engraver.cc +++ b/lily/ambitus-engraver.cc @@ -17,6 +17,7 @@ #include "protected-scm.hh" #include "side-position-interface.hh" #include "staff-symbol-referencer.hh" +#include "stream-event.hh" #include "translator.icc" @@ -117,8 +118,8 @@ Ambitus_engraver::stop_translation_timestep () void Ambitus_engraver::acknowledge_note_head (Grob_info info) { - Music *nr = info.music_cause (); - if (nr && nr->is_mus_type ("note-event")) + Stream_event *nr = info.event_cause (); + if (nr && nr->in_event_class ("note-event")) { Pitch pitch = *unsmob_pitch (nr->get_property ("pitch")); pitch_interval_.add_point (pitch); diff --git a/lily/arpeggio-engraver.cc b/lily/arpeggio-engraver.cc index 1cc143dbd7..633d924e5a 100644 --- a/lily/arpeggio-engraver.cc +++ b/lily/arpeggio-engraver.cc @@ -44,7 +44,7 @@ Arpeggio_engraver::Arpeggio_engraver () IMPLEMENT_TRANSLATOR_LISTENER (Arpeggio_engraver, arpeggio); void Arpeggio_engraver::listen_arpeggio (Stream_event *ev) { - arpeggio_event_ = ev; + ASSIGN_EVENT_ONCE (arpeggio_event_, ev); } void diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 26aef17543..0472c4cdec 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -133,7 +133,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Auto_beam_engraver, beam_forbid); void Auto_beam_engraver::listen_beam_forbid (Stream_event *ev) { - forbid_ = ev; + ASSIGN_EVENT_ONCE (forbid_, ev); } bool diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index 42d0a8db41..46d932e2f7 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -102,9 +102,9 @@ Beam_engraver::listen_beam (Stream_event *ev) Direction d = to_dir (ev->get_property ("span-direction")); if (d == START && valid_start_point ()) - start_ev_ = ev; + ASSIGN_EVENT_ONCE (start_ev_, ev); else if (d == STOP && valid_end_point ()) - now_stop_ev_ = ev; + ASSIGN_EVENT_ONCE (now_stop_ev_, ev); } void diff --git a/lily/beam-performer.cc b/lily/beam-performer.cc index 6d36c78381..ba0135f1d0 100644 --- a/lily/beam-performer.cc +++ b/lily/beam-performer.cc @@ -12,7 +12,6 @@ #include "global-context.hh" #include "stream-event.hh" #include "warn.hh" -#include "music.hh" #include "translator.icc" diff --git a/lily/breathing-sign-engraver.cc b/lily/breathing-sign-engraver.cc index 5b2ddaff47..126110e07e 100644 --- a/lily/breathing-sign-engraver.cc +++ b/lily/breathing-sign-engraver.cc @@ -42,9 +42,9 @@ Breathing_sign_engraver::Breathing_sign_engraver () IMPLEMENT_TRANSLATOR_LISTENER (Breathing_sign_engraver, breathing); void -Breathing_sign_engraver::listen_breathing (Stream_event *r) +Breathing_sign_engraver::listen_breathing (Stream_event *ev) { - breathing_sign_event_ = r; + ASSIGN_EVENT_ONCE (breathing_sign_event_, ev); } void diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index b0f17352ba..f07e984626 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -73,15 +73,19 @@ Chord_tremolo_engraver::listen_tremolo_span (Stream_event *ev) Direction span_dir = to_dir (ev->get_property ("span-direction")); if (span_dir == START) { - repeat_ = ev; - int type = scm_to_int (ev->get_property ("tremolo-type")); - /* e.g. 1 for type 8, 2 for type 16 */ - flags_ = intlog2 (type) - 2; - expected_beam_count_ = scm_to_int (ev->get_property ("expected-beam-count")); - beam_dir_ = RIGHT; + if (ASSIGN_EVENT_ONCE (repeat_, ev)) + { + int type = scm_to_int (ev->get_property ("tremolo-type")); + /* e.g. 1 for type 8, 2 for type 16 */ + flags_ = intlog2 (type) - 2; + expected_beam_count_ = scm_to_int (ev->get_property ("expected-beam-count")); + beam_dir_ = RIGHT; + } } else if (span_dir == STOP) { + if (!repeat_) + ev->origin ()->warning (_ ("No tremolo to end")); repeat_ = 0; beam_ = 0; expected_beam_count_ = 0; @@ -123,13 +127,13 @@ Chord_tremolo_engraver::acknowledge_stem (Grob_info info) if (beam_dir_ == RIGHT) beam_dir_ = LEFT; - if (info.ultimate_music_cause ()->is_mus_type ("rhythmic-event")) + if (info.ultimate_event_cause ()->in_event_class ("rhythmic-event")) Beam::add_stem (beam_, s); else { string s = _ ("stem must have Rhythmic structure"); - if (info.music_cause ()) - info.music_cause ()->origin ()->warning (s); + if (info.event_cause ()) + info.event_cause ()->origin ()->warning (s); else ::warning (s); } diff --git a/lily/coherent-ligature-engraver.cc b/lily/coherent-ligature-engraver.cc index a4815f0b8a..96ff842d0c 100644 --- a/lily/coherent-ligature-engraver.cc +++ b/lily/coherent-ligature-engraver.cc @@ -9,11 +9,12 @@ #include "coherent-ligature-engraver.hh" #include "warn.hh" -#include "staff-symbol-referencer.hh" -#include "spanner.hh" #include "paper-column.hh" #include "pitch.hh" #include "pointer-group-interface.hh" +#include "spanner.hh" +#include "staff-symbol-referencer.hh" +#include "stream-event.hh" /* * This abstract class serves as common superclass for all ligature @@ -142,9 +143,9 @@ compute_delta_pitches (vector primitives) for (vsize i = 0; i < primitives.size (); i++) { primitive = dynamic_cast (primitives[i].grob ()); - Music *music_cause = primitives[i].music_cause (); + Stream_event *cause = primitives[i].event_cause (); int pitch - = unsmob_pitch (music_cause->get_property ("pitch"))->steps (); + = unsmob_pitch (cause->get_property ("pitch"))->steps (); if (prev_primitive) { delta_pitch = pitch - prev_pitch; diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index 3e5056619d..69cd4b0785 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -12,7 +12,6 @@ using namespace std; #include "duration.hh" #include "global-context.hh" #include "item.hh" -#include "music.hh" #include "output-def.hh" #include "pitch.hh" #include "rhythmic-head.hh" diff --git a/lily/constrained-breaking.cc b/lily/constrained-breaking.cc index 4d9c5795ee..4e5de38254 100644 --- a/lily/constrained-breaking.cc +++ b/lily/constrained-breaking.cc @@ -238,7 +238,7 @@ Constrained_breaking::get_solution (vsize start, vsize end, vsize sys_count) { if (brk != end_brk) { - warning ( _("couldn't find line breaking that satisfies constraints" )); + warning (_ ("couldn't find line breaking that satisfies constraints" )); ret.push_back (space_line (brk, end_brk)); } /* build up the good solution */ @@ -255,7 +255,7 @@ Constrained_breaking::get_solution (vsize start, vsize end, vsize sys_count) } } /* if we get to here, just put everything on one line */ - warning ( _("couldn't find line breaking that satisfies constraints" )); + warning (_ ("couldn't find line breaking that satisfies constraints" )); ret.push_back (space_line (0, end_brk)); return ret; } diff --git a/lily/context-handle.cc b/lily/context-handle.cc index b9c8692ff0..80aa6a1a2f 100644 --- a/lily/context-handle.cc +++ b/lily/context-handle.cc @@ -47,12 +47,6 @@ Context_handle::down () outlet_ = 0; } -bool -Context_handle::try_music (Music *m) -{ - return outlet_->try_music (m); -} - void Context_handle::operator = (Context_handle const &s) { diff --git a/lily/context.cc b/lily/context.cc index 5211cbb3f0..d9c5f88129 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -655,20 +655,6 @@ IMPLEMENT_SMOBS (Context); IMPLEMENT_DEFAULT_EQUAL_P (Context); IMPLEMENT_TYPE_P (Context, "ly:context?"); -bool -Context::try_music (Music *m) -{ - Translator_group *t = implementation (); - if (!t) - return false; - - bool b = t->try_music (m); - if (!b && daddy_context_) - b = daddy_context_->try_music (m); - - return b; -} - Global_context * Context::get_global_context () const { diff --git a/lily/custos-engraver.cc b/lily/custos-engraver.cc index 3b3f7610e0..82381b764c 100644 --- a/lily/custos-engraver.cc +++ b/lily/custos-engraver.cc @@ -11,9 +11,10 @@ #include "bar-line.hh" #include "item.hh" #include "note-head.hh" +#include "pitch.hh" #include "staff-symbol-referencer.hh" +#include "stream-event.hh" #include "warn.hh" -#include "pitch.hh" #include "translator.icc" @@ -73,8 +74,8 @@ Custos_engraver::acknowledge_bar (Grob_info info) void Custos_engraver::acknowledge_note_head (Grob_info info) { - Music *m = info.music_cause (); - if (m && m->is_mus_type ("note-event")) + Stream_event *ev = info.event_cause (); + if (ev && ev->in_event_class ("note-event")) { /* @@ -85,7 +86,7 @@ Custos_engraver::acknowledge_note_head (Grob_info info) don't look at the staff-position, since we can't be sure whether Clef_engraver already applied a vertical shift. */ - pitches_.push_back (*unsmob_pitch (m->get_property ("pitch"))); + pitches_.push_back (*unsmob_pitch (ev->get_property ("pitch"))); } } diff --git a/lily/drum-note-performer.cc b/lily/drum-note-performer.cc index 2926fb8961..a4e0ff2f7f 100644 --- a/lily/drum-note-performer.cc +++ b/lily/drum-note-performer.cc @@ -10,7 +10,6 @@ #include "audio-item.hh" #include "audio-column.hh" #include "global-context.hh" -#include "music.hh" #include "pitch.hh" #include "stream-event.hh" #include "translator.icc" @@ -53,17 +52,17 @@ Drum_note_performer::process_music () if (Pitch *pit = unsmob_pitch (defn)) { SCM articulations = n->get_property ("articulations"); - Music *tie_event = 0; + Stream_event *tie_event = 0; for (SCM s = articulations; !tie_event && scm_is_pair (s); s = scm_cdr (s)) { - Music *m = unsmob_music (scm_car (s)); - if (!m) + Stream_event *ev = unsmob_stream_event (scm_car (s)); + if (!ev) continue; - if (m->is_mus_type ("tie-event")) - tie_event = m; + if (ev->in_event_class ("tie-event")) + tie_event = ev; } Audio_note *p = new Audio_note (*pit, get_event_length (n), diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 09a7e39305..d8795f0bdc 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -97,7 +97,7 @@ Dynamic_engraver::listen_absolute_dynamic (Stream_event *ev) /* TODO: probably broken. */ - script_ev_ = ev; + ASSIGN_EVENT_ONCE (script_ev_, ev); } IMPLEMENT_TRANSLATOR_LISTENER (Dynamic_engraver, span_dynamic); @@ -106,9 +106,14 @@ Dynamic_engraver::listen_span_dynamic (Stream_event *ev) { Direction d = to_dir (ev->get_property ("span-direction")); - accepted_spanevents_drul_[d] = ev; - if (current_cresc_ev_ && d == START) - accepted_spanevents_drul_[STOP] = ev; + if (d == START) + ASSIGN_EVENT_ONCE (accepted_spanevents_drul_[START], ev); + + /* Cancel any ongoing crescendo, either explicitly by \! or + implicitly by a new crescendo. Also avoid warning if cresc is + cancelled both implicitly and explicitly. */ + if ((d == STOP || current_cresc_ev_) && !accepted_spanevents_drul_[STOP]) + ASSIGN_EVENT_ONCE (accepted_spanevents_drul_[STOP], ev); } void diff --git a/lily/event-chord-iterator.cc b/lily/event-chord-iterator.cc index 60e7e3081a..89a0f383a9 100644 --- a/lily/event-chord-iterator.cc +++ b/lily/event-chord-iterator.cc @@ -9,11 +9,13 @@ #include "event-chord-iterator.hh" #include "context.hh" +#include "dispatcher.hh" #include "duration.hh" #include "input.hh" #include "international.hh" #include "music.hh" #include "pitch.hh" +#include "stream-event.hh" #include "warn.hh" Event_chord_iterator::Event_chord_iterator () @@ -38,6 +40,12 @@ Event_chord_iterator::process (Moment m) Music *mus = unsmob_music (scm_car (s)); report_event (mus); } + for (SCM s = get_music ()->get_property ("events"); + scm_is_pair (s); s = scm_cdr (s)) + { + Stream_event *ev = unsmob_stream_event (scm_car (s)); + get_outlet ()->event_source ()->broadcast (ev); + } } Simple_music_iterator::process (m); } diff --git a/lily/fall-engraver.cc b/lily/fall-engraver.cc index 5df614bb41..b0751a31d5 100644 --- a/lily/fall-engraver.cc +++ b/lily/fall-engraver.cc @@ -8,6 +8,7 @@ #include "engraver.hh" #include "item.hh" +#include "moment.hh" #include "spanner.hh" #include "stream-event.hh" @@ -92,7 +93,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Bend_after_engraver, bend_after); void Bend_after_engraver::listen_bend_after (Stream_event *ev) { - fall_event_ = ev; + ASSIGN_EVENT_ONCE (fall_event_, ev); } void diff --git a/lily/figured-bass-engraver.cc b/lily/figured-bass-engraver.cc index 9e0bf61786..a300df86d4 100644 --- a/lily/figured-bass-engraver.cc +++ b/lily/figured-bass-engraver.cc @@ -137,7 +137,7 @@ void Figured_bass_engraver::listen_rest (Stream_event *ev) { new_event_found_ = true; - rest_event_ = ev; + ASSIGN_EVENT_ONCE (rest_event_, ev); } IMPLEMENT_TRANSLATOR_LISTENER (Figured_bass_engraver, bass_figure); @@ -145,8 +145,9 @@ void Figured_bass_engraver::listen_bass_figure (Stream_event *ev) { new_event_found_ = true; - stop_moment_ = now_mom () + get_event_length (ev); - + Moment stop = now_mom () + get_event_length (ev); + stop_moment_ = max (stop_moment_, stop); + SCM fig = ev->get_property ("figure"); for (vsize i = 0; i < groups_.size (); i++) { diff --git a/lily/figured-bass-position-engraver.cc b/lily/figured-bass-position-engraver.cc index 8b4e7462c7..2286fe6b52 100644 --- a/lily/figured-bass-position-engraver.cc +++ b/lily/figured-bass-position-engraver.cc @@ -10,7 +10,6 @@ #include "engraver.hh" #include "context.hh" -#include "music.hh" #include "spanner.hh" #include "side-position-interface.hh" #include "translator.icc" diff --git a/lily/grace-spacing-engraver.cc b/lily/grace-spacing-engraver.cc index b784358a2c..f86b12ef22 100644 --- a/lily/grace-spacing-engraver.cc +++ b/lily/grace-spacing-engraver.cc @@ -8,8 +8,9 @@ */ #include "engraver.hh" -#include "spanner.hh" +#include "moment.hh" #include "pointer-group-interface.hh" +#include "spanner.hh" #include "translator.icc" diff --git a/lily/gregorian-ligature-engraver.cc b/lily/gregorian-ligature-engraver.cc index 6a99e3946e..e6b3c9b534 100644 --- a/lily/gregorian-ligature-engraver.cc +++ b/lily/gregorian-ligature-engraver.cc @@ -17,6 +17,9 @@ #include "stream-event.hh" #include "warn.hh" +/* ASSIGN_EVENT_ONCE */ +#include "translator.icc" + /* * This abstract class is the common superclass for all ligature * engravers for Gregorian chant notation. It cares for the musical @@ -36,7 +39,7 @@ Gregorian_ligature_engraver::Gregorian_ligature_engraver () void Gregorian_ligature_engraver::listen_pes_or_flexa (Stream_event *ev) { - pes_or_flexa_req_ = ev; + ASSIGN_EVENT_ONCE (pes_or_flexa_req_, ev); } void fix_prefix (char *name, int mask, diff --git a/lily/grob-info.cc b/lily/grob-info.cc index 5ad3d5701e..23ff736d95 100644 --- a/lily/grob-info.cc +++ b/lily/grob-info.cc @@ -29,24 +29,6 @@ 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"); - - 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 { @@ -97,25 +79,3 @@ Grob_info::ultimate_event_cause () const } return unsmob_stream_event (cause); } - -/* -ES TODO: Junk this when no more engraver uses try_music -*/ -Music * -Grob_info::ultimate_music_cause () const -{ - SCM cause = grob_->self_scm (); - while (unsmob_grob (cause)) - { - cause = unsmob_grob (cause)->get_property ("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-pq-engraver.cc b/lily/grob-pq-engraver.cc index 80d072b404..6f6ee8faab 100644 --- a/lily/grob-pq-engraver.cc +++ b/lily/grob-pq-engraver.cc @@ -60,13 +60,13 @@ LY_DEFINE (ly_grob_pq_less_p, "ly:grob-pq-less?", void Grob_pq_engraver::acknowledge_grob (Grob_info gi) { - Music *m = gi.music_cause (); + Stream_event *ev = gi.event_cause (); - if (m + if (ev && !gi.grob ()->internal_has_interface (ly_symbol2scm ("multi-measure-interface"))) { Moment n = now_mom (); - Moment l = m->get_length (); + Moment l = get_event_length (ev); if (!l.to_bool ()) return; diff --git a/lily/include/context-handle.hh b/lily/include/context-handle.hh index ea7e255809..e32bc29cb7 100644 --- a/lily/include/context-handle.hh +++ b/lily/include/context-handle.hh @@ -21,7 +21,6 @@ public: Context_handle (); void set_context (Context *); - bool try_music (Music *); void operator = (Context_handle const &); Context_handle (Context_handle const &); Context *get_outlet () const; diff --git a/lily/include/context.hh b/lily/include/context.hh index 1a9c0c2567..6be715ce3d 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -112,7 +112,6 @@ public: void add_context (Context *trans); bool is_bottom_context () const; bool is_removable () const; - bool try_music (Music *); Context *find_create_context (SCM context_name, string id, SCM ops); diff --git a/lily/include/engraver.hh b/lily/include/engraver.hh index 04a7623e3f..abbeb2eec9 100644 --- a/lily/include/engraver.hh +++ b/lily/include/engraver.hh @@ -9,7 +9,6 @@ #ifndef ENGRAVER_HH #define ENGRAVER_HH -#include "music.hh" #include "grob-info.hh" #include "translator.hh" diff --git a/lily/include/grob-info.hh b/lily/include/grob-info.hh index ebd860ef3a..b92f033718 100644 --- a/lily/include/grob-info.hh +++ b/lily/include/grob-info.hh @@ -30,9 +30,7 @@ public: 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 *); Grob_info (); diff --git a/lily/include/paper-column-engraver.hh b/lily/include/paper-column-engraver.hh index 5f3131ccb0..1dd227e209 100644 --- a/lily/include/paper-column-engraver.hh +++ b/lily/include/paper-column-engraver.hh @@ -11,6 +11,7 @@ #include "engraver.hh" #include "listener.hh" +#include "moment.hh" #include "stream-event.hh" class Paper_column_engraver : public Engraver diff --git a/lily/include/stream-event.hh b/lily/include/stream-event.hh index 991e672309..4e1688f6f4 100644 --- a/lily/include/stream-event.hh +++ b/lily/include/stream-event.hh @@ -19,8 +19,7 @@ public: Stream_event (); VIRTUAL_COPY_CONSTRUCTOR (Stream_event, Stream_event); // todo: remove unneeded constructors - Stream_event (SCM event_class, SCM mutable_props); - Stream_event (SCM property_alist); + Stream_event (SCM event_class, SCM mutable_props=SCM_EOL); Stream_event (SCM class_name, Input *); Stream_event (Stream_event *ev); diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index 2552fb4186..45a7c77030 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -50,7 +50,6 @@ private: SCM protected_events_; DECLARE_LISTENER (create_child_translator); - DECLARE_LISTENER (eat_event); public: VIRTUAL_COPY_CONSTRUCTOR (Translator_group, Translator_group); @@ -61,7 +60,6 @@ public: virtual void disconnect_from_context (); virtual Translator_group *get_daddy_translator ()const; virtual SCM get_simple_trans_list (); - virtual bool try_music (Music *req); virtual void initialize (); virtual void finalize (); @@ -80,7 +78,6 @@ public: Context *context () const { return context_; } protected: SCM simple_trans_list_; - SCM accept_hash_table_; Context *context_; friend class Context_def; diff --git a/lily/include/translator.hh b/lily/include/translator.hh index 871b87a95d..eea779085a 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -108,7 +108,6 @@ public: virtual Translator_group *get_daddy_translator ()const; virtual Moment now_mom () const; - virtual bool try_music (Music *req); virtual void initialize (); virtual void finalize (); diff --git a/lily/ligature-engraver.cc b/lily/ligature-engraver.cc index 81523a0109..9922ca1c48 100644 --- a/lily/ligature-engraver.cc +++ b/lily/ligature-engraver.cc @@ -82,7 +82,7 @@ void Ligature_engraver::listen_ligature (Stream_event *ev) { Direction d = to_dir (ev->get_property ("span-direction")); - events_drul_[d] = ev; + ASSIGN_EVENT_ONCE (events_drul_[d], ev); } void diff --git a/lily/lily-parser-scheme.cc b/lily/lily-parser-scheme.cc index 30062e14ff..90d9a60366 100644 --- a/lily/lily-parser-scheme.cc +++ b/lily/lily-parser-scheme.cc @@ -110,9 +110,9 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", exit (2); } - if ((file_name != "-") && global_path.find (file_name).empty ()) + if ((file_name != "-") && file_name.empty ()) { - warning (_f ("can't find file: `%s'", file_name)); + warning (_f ("can't find file: `%s'", file)); scm_throw (ly_symbol2scm ("ly-file-failed"), scm_list_1 (scm_makfrom0str (file_name.c_str ()))); } diff --git a/lily/lyric-combine-music-iterator.cc b/lily/lyric-combine-music-iterator.cc index aaccf2e210..dafed1d3c8 100644 --- a/lily/lyric-combine-music-iterator.cc +++ b/lily/lyric-combine-music-iterator.cc @@ -63,11 +63,8 @@ void Lyric_combine_music_iterator::set_busy (SCM se) { Stream_event *e = unsmob_stream_event (se); - SCM mus = e->get_property ("music"); - Music *m = unsmob_music (mus); - assert (m); - if (m->is_mus_type ("note-event") || m->is_mus_type ("cluster-note-event")) + if (e->in_event_class ("note-event") || e->in_event_class ("cluster-note-event")) busy_ = true; } @@ -76,13 +73,13 @@ Lyric_combine_music_iterator::set_music_context (Context *to) { if (music_context_) { - music_context_->event_source()->remove_listener (GET_LISTENER (set_busy), ly_symbol2scm ("OldMusicEvent")); + music_context_->event_source()->remove_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event")); lyrics_context_->unset_property (ly_symbol2scm ("associatedVoiceContext")); } music_context_ = to; if (to) { - to->event_source()->add_listener (GET_LISTENER (set_busy), ly_symbol2scm ("OldMusicEvent")); + to->event_source()->add_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event")); lyrics_context_->set_property ("associatedVoiceContext", to->self_scm ()); } } diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc index b236779ac1..70115d62fd 100644 --- a/lily/mark-engraver.cc +++ b/lily/mark-engraver.cc @@ -113,7 +113,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Mark_engraver, mark); void Mark_engraver::listen_mark (Stream_event *ev) { - mark_ev_ = ev; + ASSIGN_EVENT_ONCE (mark_ev_, ev); } /* diff --git a/lily/melisma-translator.cc b/lily/melisma-translator.cc index 69f9f7f53a..adc873d4dc 100644 --- a/lily/melisma-translator.cc +++ b/lily/melisma-translator.cc @@ -9,6 +9,7 @@ #include "engraver.hh" #include "grob.hh" #include "context.hh" +#include "music.hh" #include "translator.icc" /* Remove this translator. */ diff --git a/lily/mensural-ligature-engraver.cc b/lily/mensural-ligature-engraver.cc index c1c5bcad6d..f40ce004b0 100644 --- a/lily/mensural-ligature-engraver.cc +++ b/lily/mensural-ligature-engraver.cc @@ -11,11 +11,11 @@ #include "font-interface.hh" #include "international.hh" #include "mensural-ligature.hh" -#include "music.hh" #include "note-column.hh" #include "note-head.hh" #include "output-def.hh" #include "paper-column.hh" +#include "pitch.hh" #include "rhythmic-head.hh" #include "spanner.hh" #include "staff-symbol-referencer.hh" @@ -104,12 +104,12 @@ Mensural_ligature_engraver::transform_heads (vector primitives) Item *primitive = dynamic_cast (info.grob ()); int duration_log = Note_head::get_balltype (primitive); - Music *nr = info.music_cause (); + Stream_event *nr = info.event_cause (); /* ugh. why not simply check for pitch? */ - if (!nr->is_mus_type ("note-event")) + if (!nr->in_event_class ("note-event")) { nr->origin ()->warning (_f ("cannot determine pitch of ligature primitive -> skipping")); @@ -174,7 +174,7 @@ Mensural_ligature_engraver::transform_heads (vector primitives) } // b. descendens longa or brevis else if (i < s - 1 - && (unsmob_pitch (primitives[i + 1].music_cause () + && (unsmob_pitch (primitives[i + 1].event_cause () ->get_property ("pitch"))->steps () < pitch) && duration_log > -3) { diff --git a/lily/metronome-engraver.cc b/lily/metronome-engraver.cc index cfae9a5ee8..5e5986d2ea 100644 --- a/lily/metronome-engraver.cc +++ b/lily/metronome-engraver.cc @@ -11,10 +11,13 @@ using namespace std; #include "engraver.hh" -#include "item.hh" #include "context.hh" -#include "grob-array.hh" #include "duration.hh" +#include "grob-array.hh" +#include "item.hh" +#include "stream-event.hh" + +#include "translator.icc" /** put stuff over or next to bars. Examples: bar numbers, marginal notes, @@ -91,8 +94,6 @@ Metronome_mark_engraver::process_music () last_count_ = count; } -#include "translator.icc" - ADD_TRANSLATOR (Metronome_mark_engraver, /* doc */ "Engrave metro nome marking. This delegates the formatting work " "to the function in the metronomeMarkFormatter property. " diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index ff073601e9..2019959399 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -65,8 +65,14 @@ IMPLEMENT_TRANSLATOR_LISTENER (Multi_measure_rest_engraver, multi_measure_rest); void Multi_measure_rest_engraver::listen_multi_measure_rest (Stream_event *ev) { + /* FIXME: Should use ASSIGN_EVENT_ONCE. Can't do that yet because of + the kill-mm-rests hack in part-combine-iterator. */ rest_ev_ = ev; stop_moment_ = now_mom () + get_event_length (rest_ev_); + /* + if (ASSIGN_EVENT_ONCE (rest_ev_, ev)) + stop_moment_ = now_mom () + get_event_length (rest_ev_); + */ } IMPLEMENT_TRANSLATOR_LISTENER (Multi_measure_rest_engraver, multi_measure_text); diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index ce824968a9..036a0c3249 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -169,7 +169,7 @@ Music_iterator::report_event (Music *m) FIXME: then don't do it. */ if (!m->is_mus_type ("event")) - m->origin ()->programming_error (_f ("Sending non-event to context")); + m->origin ()->programming_error (_ ("Sending non-event to context")); m->send_to_context (get_outlet ()); } diff --git a/lily/music.cc b/lily/music.cc index 4d71d99d98..b938c86e22 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -269,7 +269,7 @@ Music::to_event () const out[outpos] = 0; SCM class_name = ly_symbol2scm (out); - // catch mistakes. + // catch programming mistakes. if (!internal_is_music_type (class_name)) { programming_error ("Not a music type"); @@ -280,24 +280,32 @@ Music::to_event () const 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) { - /* - 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 (); diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index 75e893c351..2e8c94399c 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -14,7 +14,7 @@ #include "self-alignment-interface.hh" #include "side-position-interface.hh" #include "stem.hh" -#include "stem.hh" +#include "stream-event.hh" #include "warn.hh" #include "translator.icc" @@ -23,8 +23,8 @@ struct Finger_tuple { Grob *head_; Grob *script_; - Music *note_event_; - Music *finger_event_; + Stream_event *note_event_; + Stream_event *finger_event_; bool follow_into_staff_; int position_; @@ -58,16 +58,16 @@ protected: void stop_translation_timestep (); DECLARE_ACKNOWLEDGER (rhythmic_head); DECLARE_ACKNOWLEDGER (stem); - void add_fingering (Grob *, Music *, Music *); - void add_script (Grob *, Music *, Music *); - void add_string (Grob *, Music *, Music *); + void add_fingering (Grob *, Stream_event *, Stream_event *); + void add_script (Grob *, Stream_event *, Stream_event *); + void add_string (Grob *, Stream_event *, Stream_event *); void position_scripts (SCM orientations, vector *); }; void New_fingering_engraver::acknowledge_rhythmic_head (Grob_info inf) { - Music *note_ev = inf.music_cause (); + Stream_event *note_ev = inf.event_cause (); if (!note_ev) return; @@ -75,20 +75,20 @@ New_fingering_engraver::acknowledge_rhythmic_head (Grob_info inf) for (SCM s = arts; scm_is_pair (s); s = scm_cdr (s)) { - Music *m = unsmob_music (scm_car (s)); + Stream_event *ev = unsmob_stream_event (scm_car (s)); - if (!m) + if (!ev) continue; - if (m->is_mus_type ("fingering-event")) - add_fingering (inf.grob (), m, note_ev); - else if (m->is_mus_type ("text-script-event")) - m->origin ()->warning (_ ("can't add text scripts to individual note heads")); - else if (m->is_mus_type ("script-event")) - add_script (inf.grob (), m, note_ev); - else if (m->is_mus_type ("string-number-event")) - add_string (inf.grob (), m, note_ev); - else if (m->is_mus_type ("harmonic-event")) + if (ev->in_event_class ("fingering-event")) + add_fingering (inf.grob (), ev, note_ev); + else if (ev->in_event_class ("text-script-event")) + ev->origin ()->warning (_ ("can't add text scripts to individual note heads")); + else if (ev->in_event_class ("script-event")) + add_script (inf.grob (), ev, note_ev); + else if (ev->in_event_class ("string-number-event")) + add_string (inf.grob (), ev, note_ev); + else if (ev->in_event_class ("harmonic-event")) { inf.grob ()->set_property ("style", ly_symbol2scm ("harmonic")); Grob *d = unsmob_grob (inf.grob ()->get_object ("dot")); @@ -108,8 +108,8 @@ New_fingering_engraver::acknowledge_stem (Grob_info inf) void New_fingering_engraver::add_script (Grob *head, - Music *event, - Music *note) + Stream_event *event, + Stream_event *note) { (void) note; @@ -129,8 +129,8 @@ New_fingering_engraver::add_script (Grob *head, void New_fingering_engraver::add_fingering (Grob *head, - Music *event, - Music *hevent) + Stream_event *event, + Stream_event *hevent) { Finger_tuple ft; @@ -166,8 +166,8 @@ New_fingering_engraver::add_fingering (Grob *head, void New_fingering_engraver::add_string (Grob *head, - Music *event, - Music *hevent) + Stream_event *event, + Stream_event *hevent) { Finger_tuple ft; diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index 93fb8feb4d..1d2f32418a 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -14,6 +14,7 @@ using namespace std; #include "duration.hh" #include "item.hh" #include "output-def.hh" +#include "pitch.hh" #include "rhythmic-head.hh" #include "staff-symbol-referencer.hh" #include "stream-event.hh" diff --git a/lily/note-name-engraver.cc b/lily/note-name-engraver.cc index 1222654dab..32253cb2bc 100644 --- a/lily/note-name-engraver.cc +++ b/lily/note-name-engraver.cc @@ -8,6 +8,7 @@ #include "engraver.hh" #include "item.hh" +#include "pitch.hh" #include "stream-event.hh" #include "translator.icc" diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 8a39546b41..4aecc39606 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -10,7 +10,6 @@ #include "audio-item.hh" #include "audio-column.hh" #include "global-context.hh" -#include "music.hh" #include "stream-event.hh" #include "warn.hh" @@ -54,17 +53,17 @@ Note_performer::process_music () if (Pitch *pitp = unsmob_pitch (pit)) { SCM articulations = n->get_property ("articulations"); - Music *tie_event = 0; + Stream_event *tie_event = 0; for (SCM s = articulations; !tie_event && scm_is_pair (s); s = scm_cdr (s)) { - Music *m = unsmob_music (scm_car (s)); - if (!m) + Stream_event *ev = unsmob_stream_event (scm_car (s)); + if (!ev) continue; - if (m->is_mus_type ("tie-event")) - tie_event = m; + if (ev->in_event_class ("tie-event")) + tie_event = ev; } Audio_note *p = new Audio_note (*pitp, get_event_length (n), diff --git a/lily/parenthesis-engraver.cc b/lily/parenthesis-engraver.cc index 01ea191cb3..53d332427e 100644 --- a/lily/parenthesis-engraver.cc +++ b/lily/parenthesis-engraver.cc @@ -9,12 +9,12 @@ #include "engraver.hh" -#include "warn.hh" -#include "simple-closure.hh" -#include "music.hh" #include "grob.hh" #include "item.hh" #include "pointer-group-interface.hh" +#include "simple-closure.hh" +#include "stream-event.hh" +#include "warn.hh" #include "translator.icc" @@ -33,9 +33,9 @@ Parenthesis_engraver::Parenthesis_engraver() void Parenthesis_engraver::acknowledge_grob (Grob_info info) { - if (Music *music = info.music_cause ()) + if (Stream_event *ev = info.event_cause ()) { - if (to_boolean (music->get_property ("parenthesize"))) + if (to_boolean (ev->get_property ("parenthesize"))) { if (Item *victim = dynamic_cast (info.grob ())) { diff --git a/lily/part-combine-engraver.cc b/lily/part-combine-engraver.cc index d1bd10cc51..284f7616c7 100644 --- a/lily/part-combine-engraver.cc +++ b/lily/part-combine-engraver.cc @@ -38,7 +38,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Part_combine_engraver, part_combine); void Part_combine_engraver::listen_part_combine (Stream_event *ev) { - event_ = ev; + ASSIGN_EVENT_ONCE (event_, ev); } Part_combine_engraver::Part_combine_engraver () diff --git a/lily/part-combine-iterator.cc b/lily/part-combine-iterator.cc index 99f36b2b74..2a85da8037 100644 --- a/lily/part-combine-iterator.cc +++ b/lily/part-combine-iterator.cc @@ -15,6 +15,14 @@ #include "music-sequence.hh" #include "warn.hh" +typedef enum Outlet_type + { + CONTEXT_ONE, CONTEXT_TWO, CONTEXT_SHARED, CONTEXT_SOLO, CONTEXT_NULL, NUM_OUTLETS + }; + +static const char *outlet_names_[NUM_OUTLETS] = + {"one", "two", "shared", "solo", "null"}; + class Part_combine_iterator : public Music_iterator { public: @@ -67,16 +75,13 @@ private: /* TODO: this is getting of hand... */ - Context_handle one_; - Context_handle two_; - Context_handle null_; - Context_handle shared_; - Context_handle solo_; + Context_handle handles_[NUM_OUTLETS]; - void substitute_both (Context *to1, - Context *to2); + void substitute_both (Outlet_type to1, + Outlet_type to2); - void kill_mmrest (Context *); + /* parameter is really Outlet_type */ + void kill_mmrest (int in); void chords_together (); void solo1 (); void solo2 (); @@ -92,11 +97,14 @@ Part_combine_iterator::do_quit () if (second_iter_) second_iter_->quit (); - null_.set_context (0); - one_.set_context (0); - two_.set_context (0); - shared_.set_context (0); - solo_.set_context (0); + // Add listeners to all contexts except Devnull. + for (int i = 0; i < NUM_OUTLETS; i++) + { + Context *c = handles_[i].get_outlet (); + if (c->is_alias (ly_symbol2scm ("Voice"))) + c->event_source ()->remove_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event")); + handles_[i].set_context (0); + } } Part_combine_iterator::Part_combine_iterator () @@ -154,21 +162,21 @@ Part_combine_iterator::chords_together () playing_state_ = TOGETHER; state_ = TOGETHER; - substitute_both (shared_.get_outlet (), shared_.get_outlet ()); + substitute_both (CONTEXT_SHARED, CONTEXT_SHARED); } } void -Part_combine_iterator::kill_mmrest (Context *tg) +Part_combine_iterator::kill_mmrest (int in) { - static Music *mmrest; + static Stream_event *mmrest; if (!mmrest) { - mmrest = make_music_by_name (ly_symbol2scm ("MultiMeasureRestEvent")); + mmrest = new Stream_event (ly_symbol2scm ("multi-measure-rest-event")); mmrest->set_property ("duration", SCM_EOL); } - mmrest->send_to_context (tg); + handles_[in].get_outlet ()->event_source ()->broadcast (mmrest); } void @@ -179,50 +187,42 @@ Part_combine_iterator::solo1 () else { state_ = SOLO1; - substitute_both (solo_.get_outlet (), - null_.get_outlet ()); + substitute_both (CONTEXT_SOLO, CONTEXT_NULL); - kill_mmrest (two_.get_outlet ()); - kill_mmrest (shared_.get_outlet ()); + kill_mmrest (CONTEXT_TWO); + kill_mmrest (CONTEXT_SHARED); if (playing_state_ != SOLO1) { - static Music *event; + static Stream_event *event; if (!event) - event = make_music_by_name (ly_symbol2scm ("SoloOneEvent")); + event = new Stream_event (ly_symbol2scm ("solo1-event")); - event->send_to_context (first_iter_->get_outlet ()); + first_iter_->get_outlet ()->event_source ()->broadcast (event); } playing_state_ = SOLO1; } } void -Part_combine_iterator::substitute_both (Context *to1, - Context *to2) +Part_combine_iterator::substitute_both (Outlet_type to1, + Outlet_type to2) { - Context *tos[] = {to1, to2}; + Outlet_type tos[] = {to1, to2}; + Music_iterator *mis[] = {first_iter_, second_iter_}; - Context_handle *hs[] - = { - &null_, - &one_, &two_, - &shared_, &solo_, - 0 - }; for (int i = 0; i < 2; i++) { - for (int j = 0; hs[j]; j++) - if (hs[j]->get_outlet () != tos[i]) - mis[i]->substitute_outlet (hs[j]->get_outlet (), tos[i]); + for (int j = 0; j < NUM_OUTLETS; j++) + if (j != tos[i]) + mis[i]->substitute_outlet (handles_[j].get_outlet (), handles_[tos[i]].get_outlet ()); } - for (int j = 0; hs[j]; j++) + for (int j = 0; j < NUM_OUTLETS; j++) { - Context *t = hs[j]->get_outlet (); - if (t != to1 && t != to2) - kill_mmrest (t); + if (j != to1 && j != to2) + kill_mmrest (j); } } @@ -240,23 +240,24 @@ Part_combine_iterator::unisono (bool silent) in the 1st voice, so in that case, we use the second voice as a basis for events. */ - Context *c1 = (last_playing_ == SOLO2) ? null_.get_outlet () : shared_.get_outlet (); - Context *c2 = (last_playing_ == SOLO2) ? shared_.get_outlet () : null_.get_outlet (); + Outlet_type c1 = (last_playing_ == SOLO2) ? CONTEXT_NULL : CONTEXT_SHARED; + Outlet_type c2 = (last_playing_ == SOLO2) ? CONTEXT_SHARED : CONTEXT_NULL; substitute_both (c1, c2); kill_mmrest ((last_playing_ == SOLO2) - ? one_.get_outlet () : two_.get_outlet ()); - kill_mmrest (shared_.get_outlet ()); + ? CONTEXT_ONE : CONTEXT_TWO); + kill_mmrest (CONTEXT_SHARED); if (playing_state_ != UNISONO && newstate == UNISONO) { - static Music *event; + static Stream_event *event; if (!event) - event = make_music_by_name (ly_symbol2scm ("UnisonoEvent")); + event = new Stream_event (ly_symbol2scm ("unisono-event")); + Context *out = (last_playing_ == SOLO2 ? second_iter_ : first_iter_) ->get_outlet (); - event->send_to_context (out); + out->event_source ()->broadcast (event); playing_state_ = UNISONO; } state_ = newstate; @@ -272,15 +273,15 @@ Part_combine_iterator::solo2 () { state_ = SOLO2; - substitute_both (null_.get_outlet (), solo_.get_outlet ()); + substitute_both (CONTEXT_NULL, CONTEXT_SOLO); if (playing_state_ != SOLO2) { - static Music *event; + static Stream_event *event; if (!event) - event = make_music_by_name (ly_symbol2scm ("SoloTwoEvent")); + event = new Stream_event (ly_symbol2scm ("solo2-event")); - event->send_to_context (second_iter_->get_outlet ()); + second_iter_->get_outlet ()->event_source ()->broadcast (event); playing_state_ = SOLO2; } } @@ -297,7 +298,7 @@ Part_combine_iterator::apart (bool silent) else { state_ = APART; - substitute_both (one_.get_outlet (), two_.get_outlet ()); + substitute_both (CONTEXT_ONE, CONTEXT_TWO); } } @@ -306,56 +307,27 @@ Part_combine_iterator::construct_children () { start_moment_ = get_outlet ()->now_mom (); split_list_ = get_music ()->get_property ("split-list"); - SCM lst = get_music ()->get_property ("elements"); - - SCM props = scm_list_n (/* - used to have tweaks here. - */ - SCM_UNDEFINED); + Context *c = get_outlet (); - Context *tr - = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"), - "shared", props); - - shared_.set_context (tr); - - /* - If we don't, we get a new staff for every Voice. - */ - set_context (tr); - - Context *solo_tr - = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"), - "solo", props); - - solo_.set_context (solo_tr); - - Context *null - = get_outlet ()->find_create_context (ly_symbol2scm ("Devnull"), - "", SCM_EOL); - - if (!null) - programming_error ("no Devnull found"); - - null_.set_context (null); - - Context *one = tr->find_create_context (ly_symbol2scm ("Voice"), - "one", props); - - one_.set_context (one); + for (int i = 0; i < NUM_OUTLETS; i++) + { + SCM type = (i == CONTEXT_NULL) ? ly_symbol2scm ("Devnull") : ly_symbol2scm ("Voice"); + /* find context below c: otherwise we may create new staff for each voice */ + c = c->find_create_context (type, outlet_names_[i], SCM_EOL); + handles_[i].set_context (c); + if (c->is_alias (ly_symbol2scm ("Voice"))) + c->event_source ()->add_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event")); + } + SCM lst = get_music ()->get_property ("elements"); + Context *one = handles_[CONTEXT_ONE].get_outlet (); set_context (one); first_iter_ = unsmob_iterator (get_iterator (unsmob_music (scm_car (lst)))); - - Context *two = tr->find_create_context (ly_symbol2scm ("Voice"), - "two", props); - two_.set_context (two); + Context *two = handles_[CONTEXT_TWO].get_outlet (); set_context (two); second_iter_ = unsmob_iterator (get_iterator (unsmob_music (scm_cadr (lst)))); - set_context (tr); - char const *syms[] = { "Stem", @@ -369,13 +341,6 @@ Part_combine_iterator::construct_children () 0 }; - // Add listeners to all contexts except Devnull. - Context *contexts[] = {one, two, solo_tr, tr, 0}; - for (int i = 0; contexts[i]; i++) - { - contexts[i]->event_source ()->add_listener (GET_LISTENER (set_busy), ly_symbol2scm ("OldMusicEvent")); - } - for (char const **p = syms; *p; p++) { SCM sym = ly_symbol2scm (*p); @@ -395,11 +360,8 @@ Part_combine_iterator::set_busy (SCM se) return; Stream_event *e = unsmob_stream_event (se); - SCM mus = e->get_property ("music"); - Music *m = unsmob_music (mus); - assert (m); - if (m->is_mus_type ("note-event") || m->is_mus_type ("cluster-note-event")) + if (e->in_event_class ("note-event") || e->in_event_class ("cluster-note-event")) busy_ = true; } diff --git a/lily/percent-repeat-engraver.cc b/lily/percent-repeat-engraver.cc index a27eef826b..57357cb559 100644 --- a/lily/percent-repeat-engraver.cc +++ b/lily/percent-repeat-engraver.cc @@ -78,26 +78,31 @@ Percent_repeat_engraver::listen_percent (Stream_event *ev) Moment body_length = get_event_length (ev); Moment meas_len (robust_scm2moment (get_property ("measureLength"), Moment (1))); - if (meas_len == body_length) - { - repeat_sign_type_ = MEASURE; - start_mom_ = now_mom (); - stop_mom_ = now_mom () + body_length; - get_global_context ()->add_moment_to_process (stop_mom_); - } + { + repeat_sign_type_ = MEASURE; + start_mom_ = now_mom (); + stop_mom_ = now_mom () + body_length; + get_global_context ()->add_moment_to_process (stop_mom_); + } else if (Moment (2) * meas_len == body_length) - { - repeat_sign_type_ = DOUBLE_MEASURE; - start_mom_ = now_mom () + meas_len; - stop_mom_ = now_mom () + body_length; /* never used */ - get_global_context ()->add_moment_to_process (start_mom_); - } + { + repeat_sign_type_ = DOUBLE_MEASURE; + start_mom_ = now_mom () + meas_len; + stop_mom_ = now_mom () + body_length; /* never used */ + get_global_context ()->add_moment_to_process (start_mom_); + } else - return; - + { + ev->origin ()->warning (_ ("Junking percent repeat event: Duration must be exactly one or two measures")); + return; + } percent_event_ = ev; } + else + /* print a warning: no assignment happens because + percent_event_ != 0 */ + ASSIGN_EVENT_ONCE (percent_event_, ev); } void diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc index d9c6e3e039..bb93668ca9 100644 --- a/lily/phrasing-slur-engraver.cc +++ b/lily/phrasing-slur-engraver.cc @@ -66,9 +66,9 @@ Phrasing_slur_engraver::listen_phrasing_slur (Stream_event *ev) */ Direction d = to_dir (ev->get_property ("span-direction")); if (d == START) - events_[START] = ev; + ASSIGN_EVENT_ONCE (events_[START], ev); else if (d == STOP && !slurs_.empty ()) - events_[STOP] = ev; + ASSIGN_EVENT_ONCE (events_[STOP], ev); } void diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 90844c6d24..c8a44bd4e4 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -225,26 +225,26 @@ Piano_pedal_engraver::acknowledge_note_column (Grob_info info) IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_engraver, sostenuto); void -Piano_pedal_engraver::listen_sostenuto (Stream_event *r) +Piano_pedal_engraver::listen_sostenuto (Stream_event *ev) { - Direction d = to_dir (r->get_property ("span-direction")); - info_list_[SOSTENUTO].event_drul_[d] = r; + Direction d = to_dir (ev->get_property ("span-direction")); + ASSIGN_EVENT_ONCE (info_list_[SOSTENUTO].event_drul_[d], ev); } IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_engraver, sustain); void -Piano_pedal_engraver::listen_sustain (Stream_event *r) +Piano_pedal_engraver::listen_sustain (Stream_event *ev) { - Direction d = to_dir (r->get_property ("span-direction")); - info_list_[SUSTAIN].event_drul_[d] = r; + Direction d = to_dir (ev->get_property ("span-direction")); + ASSIGN_EVENT_ONCE (info_list_[SUSTAIN].event_drul_[d], ev); } IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_engraver, una_corda); void -Piano_pedal_engraver::listen_una_corda (Stream_event *r) +Piano_pedal_engraver::listen_una_corda (Stream_event *ev) { - Direction d = to_dir (r->get_property ("span-direction")); - info_list_[UNA_CORDA].event_drul_[d] = r; + Direction d = to_dir (ev->get_property ("span-direction")); + ASSIGN_EVENT_ONCE (info_list_[UNA_CORDA].event_drul_[d], ev); } void diff --git a/lily/pitched-trill-engraver.cc b/lily/pitched-trill-engraver.cc index b514dfd101..5044552a52 100644 --- a/lily/pitched-trill-engraver.cc +++ b/lily/pitched-trill-engraver.cc @@ -8,14 +8,15 @@ #include "engraver.hh" -#include "dots.hh" -#include "pointer-group-interface.hh" #include "axis-group-interface.hh" #include "context.hh" -#include "note-head.hh" +#include "dots.hh" #include "item.hh" -#include "side-position-interface.hh" +#include "note-head.hh" #include "pitch.hh" +#include "pointer-group-interface.hh" +#include "side-position-interface.hh" +#include "stream-event.hh" #include "warn.hh" class Pitched_trill_engraver : public Engraver @@ -37,7 +38,7 @@ private: vector heads_; - void make_trill (Music *); + void make_trill (Stream_event *); }; Pitched_trill_engraver::Pitched_trill_engraver () @@ -61,18 +62,18 @@ Pitched_trill_engraver::acknowledge_note_head (Grob_info info) void Pitched_trill_engraver::acknowledge_text_spanner (Grob_info info) { - Music *mus = info.music_cause (); - if (mus - && mus->is_mus_type ("trill-span-event") - && to_dir (mus->get_property ("span-direction")) == START - && unsmob_pitch (mus->get_property ("pitch"))) - make_trill (mus); + Stream_event *ev = info.event_cause (); + if (ev + && ev->in_event_class ("trill-span-event") + && to_dir (ev->get_property ("span-direction")) == START + && unsmob_pitch (ev->get_property ("pitch"))) + make_trill (ev); } void -Pitched_trill_engraver::make_trill (Music *mus) +Pitched_trill_engraver::make_trill (Stream_event *ev) { - SCM scm_pitch = mus->get_property ("pitch"); + SCM scm_pitch = ev->get_property ("pitch"); Pitch *p = unsmob_pitch (scm_pitch); SCM keysig = get_property ("localKeySignature"); @@ -90,7 +91,7 @@ Pitched_trill_engraver::make_trill (Music *mus) trill_head_ = 0; } - trill_head_ = make_item ("TrillPitchHead", mus->self_scm ()); + trill_head_ = make_item ("TrillPitchHead", ev->self_scm ()); SCM c0scm = get_property ("middleCPosition"); int c0 = scm_is_number (c0scm) ? scm_to_int (c0scm) : 0; @@ -99,14 +100,14 @@ Pitched_trill_engraver::make_trill (Music *mus) scm_from_int (unsmob_pitch (scm_pitch)->steps () + c0)); - trill_group_ = make_item ("TrillPitchGroup", mus->self_scm ()); + trill_group_ = make_item ("TrillPitchGroup", ev->self_scm ()); trill_group_->set_parent (trill_head_, Y_AXIS); Axis_group_interface::add_element (trill_group_, trill_head_); if (print_acc) { - trill_accidental_ = make_item ("TrillPitchAccidental", mus->self_scm ()); + trill_accidental_ = make_item ("TrillPitchAccidental", ev->self_scm ()); // fixme: naming -> alterations trill_accidental_->set_property ("accidentals", scm_list_1 (scm_from_int (p->get_alteration ()))); diff --git a/lily/recording-group-engraver.cc b/lily/recording-group-engraver.cc index e230316d8f..896ad6f694 100644 --- a/lily/recording-group-engraver.cc +++ b/lily/recording-group-engraver.cc @@ -4,10 +4,13 @@ source file of the GNU LilyPond music typesetter (c) 2003--2006 Han-Wen Nienhuys + +TODO: junk this file */ #include "recording-group-engraver.hh" #include "context.hh" +#include "music.hh" /* TODO: Junk this class, extract events directly instead. @@ -54,7 +57,7 @@ Recording_group_engraver::finalize () bool Recording_group_engraver::try_music (Music *m) { - bool retval = Translator_group::try_music (m); + bool retval = true;//Translator_group::try_music (m); add_music (m->self_scm (), ly_bool2scm (retval)); return retval; diff --git a/lily/relocate.cc b/lily/relocate.cc index d7f7888c4a..ac4c31bac4 100644 --- a/lily/relocate.cc +++ b/lily/relocate.cc @@ -385,7 +385,7 @@ read_relocation_file (string filename) else if (command == "prependdir") prepend_env_path (variable.c_str (), value); else - error ( _f("Unknown relocation command %s", command)); + error (_f ("Unknown relocation command %s", command)); } fclose (f); diff --git a/lily/repeat-tie-engraver.cc b/lily/repeat-tie-engraver.cc index c9e8c9c208..c793449dda 100644 --- a/lily/repeat-tie-engraver.cc +++ b/lily/repeat-tie-engraver.cc @@ -47,7 +47,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Repeat_tie_engraver, repeat_tie); void Repeat_tie_engraver::listen_repeat_tie (Stream_event *ev) { - event_ = ev; + ASSIGN_EVENT_ONCE (event_, ev); } void diff --git a/lily/rest-engraver.cc b/lily/rest-engraver.cc index b59acf73f4..95a8d10126 100644 --- a/lily/rest-engraver.cc +++ b/lily/rest-engraver.cc @@ -11,6 +11,7 @@ #include "dots.hh" #include "duration.hh" #include "item.hh" +#include "pitch.hh" #include "rhythmic-head.hh" #include "staff-symbol-referencer.hh" #include "stream-event.hh" diff --git a/lily/slash-repeat-engraver.cc b/lily/slash-repeat-engraver.cc index 18d5312311..37595526c5 100644 --- a/lily/slash-repeat-engraver.cc +++ b/lily/slash-repeat-engraver.cc @@ -8,6 +8,7 @@ #include "bar-line.hh" #include "global-context.hh" +#include "international.hh" #include "item.hh" #include "misc.hh" #include "percent-repeat-iterator.hh" @@ -48,7 +49,9 @@ Slash_repeat_engraver::listen_percent (Stream_event *ev) = robust_scm2moment (get_property ("measureLength"), Moment (0)); if (get_event_length (ev) < meas_length) - slash_ = ev; + ASSIGN_EVENT_ONCE (slash_, ev); + else + ev->origin ()->warning (_ ("Slash repeat doesn't fit in one measure, junking")); } void diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc index fb7a9e67c6..3ee546c3bf 100644 --- a/lily/slur-engraver.cc +++ b/lily/slur-engraver.cc @@ -63,9 +63,10 @@ Slur_engraver::listen_slur (Stream_event *ev) { Direction d = to_dir (ev->get_property ("span-direction")); if (d == START) - events_[START] = ev; + ASSIGN_EVENT_ONCE (events_[START], ev); else if (d == STOP) - events_[STOP] = ev; + ASSIGN_EVENT_ONCE (events_[STOP], ev); + else ev->origin ()->warning (_ ("Invalid direction of slur-event")); } void diff --git a/lily/spacing-engraver.cc b/lily/spacing-engraver.cc index a77fb9b593..914c672ccd 100644 --- a/lily/spacing-engraver.cc +++ b/lily/spacing-engraver.cc @@ -7,6 +7,7 @@ */ #include "engraver.hh" +#include "moment.hh" #include "note-spacing.hh" #include "paper-column.hh" #include "pointer-group-interface.hh" @@ -89,7 +90,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Spacing_engraver, spacing_section); void Spacing_engraver::listen_spacing_section (Stream_event *ev) { - start_section_ = ev; + ASSIGN_EVENT_ONCE (start_section_, ev); } void diff --git a/lily/staff-symbol-engraver.cc b/lily/staff-symbol-engraver.cc index d4e57955fc..242e06e46a 100644 --- a/lily/staff-symbol-engraver.cc +++ b/lily/staff-symbol-engraver.cc @@ -57,7 +57,7 @@ Staff_symbol_engraver::listen_staff_span (Stream_event *ev) { Direction d = to_dir (ev->get_property ("span-direction")); if (d) - span_events_[d] = ev; + ASSIGN_EVENT_ONCE (span_events_[d], ev); else programming_error (_ ("staff-span event has no direction")); } diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index 6a69aaa649..6ca9368d86 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -166,7 +166,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Stem_engraver, tremolo); void Stem_engraver::listen_tremolo (Stream_event *ev) { - tremolo_ev_ = ev; + ASSIGN_EVENT_ONCE (tremolo_ev_, ev); } ADD_ACKNOWLEDGER (Stem_engraver, rhythmic_head); diff --git a/lily/stream-event-scheme.cc b/lily/stream-event-scheme.cc index ce337d5472..ea93654961 100644 --- a/lily/stream-event-scheme.cc +++ b/lily/stream-event-scheme.cc @@ -9,11 +9,17 @@ #include "stream-event.hh" LY_DEFINE (ly_make_stream_event, "ly:make-stream-event", - 1, 0, 0, (SCM proplist), - "Creates a stream event, with the given property list.\n" ) + 1, 1, 0, (SCM cl, SCM proplist), + "Creates a stream event of class @var{cl} with the given mutable property list.\n" ) { - SCM_ASSERT_TYPE (scm_list_p (proplist), proplist, SCM_ARG1, __FUNCTION__, "association list"); - Stream_event *e = new Stream_event (proplist); + SCM_ASSERT_TYPE (scm_is_symbol (cl), cl, SCM_ARG1, __FUNCTION__, "symbol"); + if (proplist != SCM_UNDEFINED) + { + SCM_ASSERT_TYPE (scm_list_p (proplist), proplist, SCM_ARG2, __FUNCTION__, "association list"); + } + else + proplist = SCM_EOL; + Stream_event *e = new Stream_event (cl, proplist); return e->unprotect (); } @@ -28,3 +34,11 @@ LY_DEFINE (ly_event_property, "ly:event-property", return e->internal_get_property (sym); } + +LY_DEFINE (ly_event_set_property, "ly:event-set-property!", + 3, 0, 0, (SCM ev, SCM sym, SCM val), + "Set property @var{sym} in event @var{ev} to @var{val}."){ + Stream_event *sc = unsmob_stream_event (ev); + SCM_ASSERT_TYPE (sc, ev, SCM_ARG1, __FUNCTION__, "event"); + return ly_prob_set_property_x (ev, sym, val); +} diff --git a/lily/stream-event.cc b/lily/stream-event.cc index 7a1118e65a..ff736d8832 100644 --- a/lily/stream-event.cc +++ b/lily/stream-event.cc @@ -27,12 +27,6 @@ Stream_event::Stream_event (SCM event_class, SCM mutable_props) mutable_property_alist_ = mutable_props; } -Stream_event::Stream_event (SCM property_alist) - : Prob (ly_symbol2scm ("Stream_event"), SCM_EOL) -{ - mutable_property_alist_ = property_alist; -} - Stream_event::Stream_event (SCM class_name, Input *origin) : Prob (ly_symbol2scm ("Stream_event"), scm_list_1 (scm_cons (ly_symbol2scm ("class"), class_name))) diff --git a/lily/tab-note-heads-engraver.cc b/lily/tab-note-heads-engraver.cc index 1ddabdd697..d30c2265c7 100644 --- a/lily/tab-note-heads-engraver.cc +++ b/lily/tab-note-heads-engraver.cc @@ -14,8 +14,8 @@ using namespace std; #include "dots.hh" #include "duration.hh" #include "item.hh" -#include "music.hh" #include "output-def.hh" +#include "pitch.hh" #include "rhythmic-head.hh" #include "score-engraver.hh" #include "staff-symbol-referencer.hh" @@ -81,10 +81,10 @@ Tab_note_heads_engraver::process_music () for (SCM s = event->get_property ("articulations"); !tabstring_event && scm_is_pair (s); s = scm_cdr (s)) { - Music *art = unsmob_music (scm_car (s)); + Stream_event *art = unsmob_stream_event (scm_car (s)); - if (art->is_mus_type ("string-number-event")) - tabstring_event = art->to_event (); + if (art->in_event_class ("string-number-event")) + tabstring_event = art; } if (!tabstring_event && j < tabstring_events_.size ()) @@ -163,7 +163,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.", + /* doc */ "Generate one or more tablature noteheads from event of type NoteEvent.", /* create */ "TabNoteHead Dots", /* accept */ "note-event string-number-event", /* read */ "middleCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost", diff --git a/lily/text-spanner-engraver.cc b/lily/text-spanner-engraver.cc index b7628c325c..b10832f1b3 100644 --- a/lily/text-spanner-engraver.cc +++ b/lily/text-spanner-engraver.cc @@ -48,7 +48,7 @@ void Text_spanner_engraver::listen_text_span (Stream_event *ev) { Direction d = to_dir (ev->get_property ("span-direction")); - event_drul_[d] = ev; + ASSIGN_EVENT_ONCE (event_drul_[d], ev); } void @@ -137,7 +137,7 @@ Text_spanner_engraver::finalize () ADD_ACKNOWLEDGER (Text_spanner_engraver, note_column); ADD_TRANSLATOR (Text_spanner_engraver, - /* doc */ "Create text spanner from a Music.", + /* doc */ "Create text spanner from an event.", /* create */ "TextSpanner", /* accept */ "text-span-event", /* read */ "", diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 9547d14025..1dfb42fa52 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -38,7 +38,7 @@ struct Head_event_tuple Moment end_moment_; SCM tie_definition_; Stream_event *tie_stream_event_; - Music *tie_event_; + Stream_event *tie_event_; Head_event_tuple () { @@ -88,7 +88,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Tie_engraver, tie); void Tie_engraver::listen_tie (Stream_event *ev) { - event_ = ev; + ASSIGN_EVENT_ONCE (event_, ev); } void @@ -198,18 +198,18 @@ Tie_engraver::stop_translation_timestep () SCM left_articulations = left_ev->get_property ("articulations"); - Music *tie_event = 0; + Stream_event *tie_event = 0; Stream_event *tie_stream_event = event_; for (SCM s = left_articulations; !tie_event && !tie_stream_event && scm_is_pair (s); s = scm_cdr (s)) { - Music *m = unsmob_music (scm_car (s)); - if (!m) + Stream_event *ev = unsmob_stream_event (scm_car (s)); + if (!ev) continue; - if (m->is_mus_type ("tie-event")) - tie_event = m; + if (ev->in_event_class ("tie-event")) + tie_event = ev; } if (left_ev && (tie_event || tie_stream_event)) diff --git a/lily/translator-group.cc b/lily/translator-group.cc index badd1b82e8..da3fda5ed5 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -51,8 +51,6 @@ Translator_group::connect_to_context (Context *c) } context_ = c; - c->event_source ()->add_listener (GET_LISTENER (eat_event), - ly_symbol2scm ("OldMusicEvent")); c->event_source ()->add_listener (GET_LISTENER (create_child_translator), ly_symbol2scm ("AnnounceNewContext")); for (SCM tr_list = simple_trans_list_; scm_is_pair (tr_list); tr_list = scm_cdr (tr_list)) @@ -70,8 +68,6 @@ Translator_group::disconnect_from_context () Translator *tr = unsmob_translator (scm_car (tr_list)); tr->disconnect_from_context (context_); } - context_->event_source ()->remove_listener (GET_LISTENER (eat_event), - ly_symbol2scm ("OldMusicEvent")); context_->event_source ()->remove_listener (GET_LISTENER (create_child_translator), ly_symbol2scm ("AnnounceNewContext")); context_ = 0; @@ -83,33 +79,6 @@ Translator_group::finalize () { } -bool -translator_accepts_any_of (Translator *tr, SCM ifaces) -{ - SCM ack_ifs = scm_assoc (ly_symbol2scm ("events-accepted"), - tr->translator_description ()); - ack_ifs = scm_cdr (ack_ifs); - for (SCM s = ifaces; scm_is_pair (s); s = scm_cdr (s)) - if (scm_c_memq (scm_car (s), ack_ifs) != SCM_BOOL_F) - return true; - return false; -} - -SCM -find_accept_translators (SCM gravlist, SCM ifaces) -{ - SCM l = SCM_EOL; - for (SCM s = gravlist; scm_is_pair (s); s = scm_cdr (s)) - { - Translator *tr = unsmob_translator (scm_car (s)); - if (translator_accepts_any_of (tr, ifaces)) - l = scm_cons (tr->self_scm (), l); - } - l = scm_reverse_x (l, SCM_EOL); - - return l; -} - SCM filter_performers (SCM ell) { @@ -221,56 +190,6 @@ Translator_group::create_child_translator (SCM sev) DOWN); } -IMPLEMENT_LISTENER (Translator_group, eat_event); -void -Translator_group::eat_event (SCM sev) -{ - Stream_event *ev = unsmob_stream_event (sev); - SCM sm = ev->get_property ("music"); - Music *m = unsmob_music (sm); - try_music (m); -} - -bool -Translator_group::try_music (Music *m) -{ - SCM name = scm_sloppy_assq (ly_symbol2scm ("name"), - m->get_property_alist (false)); - - if (!scm_is_pair (name)) - return false; - - name = scm_cdr (name); - SCM accept_list = scm_hashq_ref (accept_hash_table_, name, SCM_UNDEFINED); - if (accept_list == SCM_BOOL_F) - { - accept_list = find_accept_translators (get_simple_trans_list (), - m->get_property ("types")); - scm_hashq_set_x (accept_hash_table_, name, accept_list); - } - - for (SCM p = accept_list; scm_is_pair (p); p = scm_cdr (p)) - { - Translator *t = unsmob_translator (scm_car (p)); - if (t && t->try_music (m)) - return true; - } - - // We couldn't swallow the event in this context. Try parent. - Context *p = context ()->get_parent_context (); - // Global context's translator group is a dummy, so don't try it. - if (p->get_parent_context()) - // ES todo: Make Translators listeners directly instead. - return p->implementation ()->try_music (m); - // 'junking event' warning is temporarily disabled during translator cleanup - /* - else - // We have tried all possible contexts. Give up. - m->origin ()->warning (_f ("junking event: `%s'", m->name ())); - */ - return false; -} - SCM Translator_group::get_simple_trans_list () { @@ -328,12 +247,9 @@ recurse_over_translators (Context *c, Translator_method ptr, Translator_group_me Translator_group::Translator_group () { simple_trans_list_ = SCM_EOL; - accept_hash_table_ = SCM_EOL; protected_events_ = SCM_EOL; context_ = 0; smobify_self (); - - accept_hash_table_ = scm_c_make_hash_table (19); } void @@ -410,7 +326,6 @@ Translator_group::mark_smob (SCM smob) Translator_group *me = (Translator_group *)SCM_CELL_WORD_1 (smob); me->derived_mark (); - scm_gc_mark (me->accept_hash_table_); scm_gc_mark (me->protected_events_); return me->simple_trans_list_; } diff --git a/lily/translator.cc b/lily/translator.cc index ec2b0f64a4..c9c8d874fb 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -52,12 +52,6 @@ Translator::Translator (Translator const &src) must_be_last_ = src.must_be_last_; } -bool -Translator::try_music (Music *) -{ - return false; -} - Moment Translator::now_mom () const { @@ -94,12 +88,9 @@ Translator::stop_translation_timestep () } /* - this function has 2 properties - - - It is called before try_music () - - - It is called before any user information enters the translators. - (i.e. any \property or event is not processed yet.) + this function is called once each moment, before any user + information enters the translators. (i.e. no \property or event has + been processed yet.) */ void Translator::start_translation_timestep () @@ -293,16 +284,17 @@ internal_event_assignment (Stream_event **old_ev, Stream_event *new_ev, const ch { /* extract event class from function name */ const char *prefix = "listen_"; - assert (!strncmp (function, "listen_", strlen (prefix))); - function += strlen (prefix); - char ev_class[strlen (function) + 1]; - strcpy (ev_class, function); - for (char *c = ev_class; *c; c++) - if (*c == '_') - *c = '-'; - - new_ev->origin ()->warning (_f ("Two simultaneous %s events, junking this one", ev_class)); - (*old_ev)->origin ()->warning (_f ("Previous %s event here", ev_class)); + string ev_class = function; + /* This assertion fails if EVENT_ASSIGNMENT was called outside a + translator listener. Don't do that. */ + assert (0 == ev_class.find (prefix)); + + /* "listen_foo_bar" -> "foo-bar" */ + ev_class.erase (0, strlen(prefix)); + replace_all (ev_class, '_', '-'); + + new_ev->origin ()->warning (_f ("Two simultaneous %s events, junking this one", ev_class.c_str ())); + (*old_ev)->origin ()->warning (_f ("Previous %s event here", ev_class.c_str ())); return false; } else diff --git a/lily/trill-spanner-engraver.cc b/lily/trill-spanner-engraver.cc index 54d3daa96b..8770ab9cef 100644 --- a/lily/trill-spanner-engraver.cc +++ b/lily/trill-spanner-engraver.cc @@ -55,7 +55,7 @@ void Trill_spanner_engraver::listen_trill_span (Stream_event *ev) { Direction d = to_dir (ev->get_property ("span-direction")); - event_drul_[d] = ev; + ASSIGN_EVENT_ONCE (event_drul_[d], ev); } void @@ -142,7 +142,7 @@ Trill_spanner_engraver::finalize () ADD_ACKNOWLEDGER (Trill_spanner_engraver, note_column); ADD_TRANSLATOR (Trill_spanner_engraver, - /* doc */ "Create trill spanner from a Music.", + /* doc */ "Create trill spanner from an event.", /* create */ "TrillSpanner", /* accept */ "trill-span-event", /* read */ "", diff --git a/lily/tuplet-engraver.cc b/lily/tuplet-engraver.cc index 3bd0948e48..7ac0e53322 100644 --- a/lily/tuplet-engraver.cc +++ b/lily/tuplet-engraver.cc @@ -6,12 +6,14 @@ (c) 1998--2006 Han-Wen Nienhuys */ -#include "tuplet-bracket.hh" -#include "note-column.hh" #include "beam.hh" #include "engraver.hh" +#include "international.hh" +#include "note-column.hh" #include "spanner.hh" #include "stream-event.hh" +#include "tuplet-bracket.hh" +#include "warn.hh" #include "translator.icc" @@ -61,11 +63,13 @@ Tuplet_engraver::listen_tuplet_span (Stream_event *ev) d.event_ = ev; tuplets_.push_back (d); } - if (dir == STOP && tuplets_.size ()) + else if (dir == STOP && tuplets_.size ()) { stopped_tuplets_.push_back (tuplets_.back ()); tuplets_.pop_back (); } + else + programming_error (_ ("invalid direction of tuplet-span-event")); } void diff --git a/lily/tweak-engraver.cc b/lily/tweak-engraver.cc index 9843dce725..a851c5a8ef 100644 --- a/lily/tweak-engraver.cc +++ b/lily/tweak-engraver.cc @@ -9,8 +9,8 @@ #include "engraver.hh" -#include "music.hh" #include "grob.hh" +#include "stream-event.hh" #include "translator.icc" class Tweak_engraver : public Engraver @@ -28,9 +28,9 @@ Tweak_engraver::Tweak_engraver() void Tweak_engraver::acknowledge_grob (Grob_info info) { - if (Music *music = info.music_cause ()) + if (Stream_event *ev = info.event_cause ()) { - for (SCM s = music->get_property ("tweaks"); + for (SCM s = ev->get_property ("tweaks"); scm_is_pair (s); s = scm_cdr (s)) { info.grob ()->internal_set_property (scm_caar (s), scm_cdar (s)); @@ -40,7 +40,7 @@ Tweak_engraver::acknowledge_grob (Grob_info info) ADD_ACKNOWLEDGER (Tweak_engraver, grob); ADD_TRANSLATOR (Tweak_engraver, - /* doc */ "Read the @code{tweaks} property from the originating Music event, and set properties." , + /* doc */ "Read the @code{tweaks} property from the originating event, and set properties." , /* create */ "", /* accept */ "", diff --git a/scm/define-event-classes.scm b/scm/define-event-classes.scm index 4050a388f7..808fcf716c 100644 --- a/scm/define-event-classes.scm +++ b/scm/define-event-classes.scm @@ -60,6 +60,10 @@ (define-public (ly:make-event-class leaf) (hashq-ref ancestor-lookup leaf)) +(define-public (ly:in-event-class? ev cl) + "Does event @var{ev} belong to event class @var{cl}?" + (memq cl (ly:make-event-class (ly:event-property ev 'class)))) + ;; does this exist in guile already? (define (map-tree f t) (cond @@ -128,7 +132,7 @@ ((pair? e) (cons (simplify (car e)) (simplify (cdr e)))) ((ly:stream-event? e) - (list 'unquote `(make-stream-event ,(simplify (Stream_event::dump e))))) + (list 'unquote (list 'make-stream-event (simplify (Stream_event::dump e))))) ((ly:music? e) (list 'unquote (music->make-music e))) ((ly:moment? e) diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index bfed38e04d..b3855c34db 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -8,8 +8,7 @@ ;; TODO: should link back into user manual. (define (mm-rest-child-list music) - "Check if we have R1*4-\\markup { .. }, and if applicable convert to -a property set for MultiMeasureRestNumber." + "Generate events for multimeasure rests, to be used by the sequential-iterator" (let ((location (ly:music-property music 'origin)) (duration (ly:music-property music 'duration))) (list (make-music 'BarCheck diff --git a/scm/translation-functions.scm b/scm/translation-functions.scm index 998d05e836..96a5c7ec27 100644 --- a/scm/translation-functions.scm +++ b/scm/translation-functions.scm @@ -60,9 +60,8 @@ ;; Bass figures. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define-public (format-bass-figure figure stream-event context) - (let* ((event (ly:event-property stream-event 'music-cause )) - (fig (ly:music-property event 'figure)) +(define-public (format-bass-figure figure event context) + (let* ((fig (ly:event-property event 'figure)) (fig-markup (if (number? figure) ;; this is not very elegant, but center-aligning all digits @@ -73,12 +72,12 @@ (lambda (y) (make-translate-scaled-markup (cons -0.7 0) y)) identity) - (if (eq? #t (ly:music-property event 'diminished)) + (if (eq? #t (ly:event-property event 'diminished)) (markup #:slashed-digit figure) (markup #:number (number->string figure 10)))) #f )) - (alt (ly:music-property event 'alteration)) + (alt (ly:event-property event 'alteration)) (alt-markup (if (number? alt) (markup @@ -88,7 +87,7 @@ (alteration->text-accidental-markup alt)) #f)) - (plus-markup (if (eq? #t (ly:music-property event 'augmented)) + (plus-markup (if (eq? #t (ly:event-property event 'augmented)) (markup #:number "+") #f))