From 0a8f98072c53d877cbb53dd490ba4394d03fa8d2 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 25 Sep 2002 23:21:49 +0000 Subject: [PATCH] * lily/musical-request.cc (music-duration-length, music-duration-compress): new functions. * lily/ : Remove Note_req, Rest_req, Busy_playing_req. Changes throughout. Warning doesn't work yet. * lily/translator-group.cc (try_music_on_nongroup_children): new implementation: store candidate acceptors in a hashTable. --- ChangeLog | 11 ++++ lily/accidental-engraver.cc | 14 +++-- lily/ambitus-engraver.cc | 4 +- lily/auto-beam-engraver.cc | 11 ++-- lily/auto-change-iterator.cc | 13 +++-- lily/beam-engraver.cc | 2 +- lily/chord-name-engraver.cc | 15 +++-- lily/command-request.cc | 6 -- lily/completion-note-heads-engraver.cc | 6 +- lily/custos-engraver.cc | 9 +-- lily/engraver-group-engraver.cc | 11 +++- lily/figured-bass-engraver.cc | 12 ++-- lily/grob-pitch-tuple.cc | 2 +- lily/include/grob-pitch-tuple.hh | 2 +- lily/include/lily-proto.hh | 1 - lily/include/music-constructor.hh | 2 +- lily/include/music.hh | 5 +- lily/include/musical-request.hh | 35 ----------- lily/main.cc | 2 +- lily/mensural-ligature-engraver.cc | 20 ++++--- lily/music.cc | 27 ++++----- lily/musical-request.cc | 52 ++++++++++------- lily/new-accidental-engraver.cc | 16 ++--- lily/note-heads-engraver.cc | 37 ++++++------ lily/note-name-engraver.cc | 6 +- lily/note-performer.cc | 12 ++-- lily/parser.yy | 6 +- lily/part-combine-music-iterator.cc | 18 +++--- lily/porrectus-engraver.cc | 11 ++-- lily/request-chord.cc | 9 +-- lily/rest-engraver.cc | 14 ++--- lily/stem-engraver.cc | 7 ++- lily/tab-note-heads-engraver.cc | 17 +++--- lily/tie-engraver.cc | 27 ++++----- lily/tie-performer.cc | 26 ++++----- lily/translator-group.cc | 81 ++++++++++++++++---------- lily/type-swallow-translator.cc | 28 ++++++--- lily/voice-devnull-engraver.cc | 4 +- scm/music-property-description.scm | 2 + scm/music-types.scm | 57 ++++++++++++------ 40 files changed, 334 insertions(+), 306 deletions(-) diff --git a/ChangeLog b/ChangeLog index b417f0b136..8f7e1bdd78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-09-26 Han-Wen Nienhuys + + * lily/musical-request.cc (music-duration-length, + music-duration-compress): new functions. + + * lily/ : Remove Note_req, Rest_req, Busy_playing_req. Changes + throughout. Warning doesn't work yet. + + * lily/translator-group.cc (try_music_on_nongroup_children): + new implementation: store candidate acceptors in a hashTable. + 2002-09-25 Han-Wen Nienhuys * scm/music-types.scm (music-descriptions): change name to diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index 96d90b21b6..4549a30547 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -32,7 +32,7 @@ tweakable. struct Accidental_entry { bool done_; - Note_req * melodic_; + Music * melodic_; Grob * accidental_; Translator_group *origin_; Grob* head_; @@ -125,7 +125,7 @@ calculates the number of accidentals on basis of the current local key sig */ static int -number_accidentals (SCM sig, Note_req * note, Pitch *pitch, SCM curbarnum, SCM lazyness, +number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazyness, bool ignore_octave_b) { int n = pitch->notename_; @@ -171,7 +171,7 @@ number_accidentals (SCM sig, Note_req * note, Pitch *pitch, SCM curbarnum, SCM l } static int -number_accidentals (Note_req * note, Pitch *pitch, Translator_group * origin, +number_accidentals (Music * note, Pitch *pitch, Translator_group * origin, SCM accidentals, SCM curbarnum) { int number = 0; @@ -249,7 +249,7 @@ Accidental_engraver::process_acknowledged_grobs () continue; accidentals_[i].done_ = true; Grob * support = accidentals_[i].head_; - Note_req * note = accidentals_[i].melodic_; + Music * note = accidentals_[i].melodic_; Translator_group * origin = accidentals_[i].origin_; Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch")); @@ -428,9 +428,11 @@ Accidental_engraver::stop_translation_timestep () void Accidental_engraver::acknowledge_grob (Grob_info info) { - Note_req * note = dynamic_cast (info.music_cause ()); + Music * note = info.music_cause (); - if (note && Rhythmic_head::has_interface (info.grob_)) + if (note + && note->is_mus_type("note-event") + && Rhythmic_head::has_interface (info.grob_)) { Accidental_entry entry ; entry.head_ = info.grob_; diff --git a/lily/ambitus-engraver.cc b/lily/ambitus-engraver.cc index d0086505d1..eda824188c 100644 --- a/lily/ambitus-engraver.cc +++ b/lily/ambitus-engraver.cc @@ -136,8 +136,8 @@ Ambitus_engraver::acknowledge_grob (Grob_info info) { if (Note_head::has_interface (info.grob_)) { - Note_req *nr = dynamic_cast (info.music_cause ()); - if (nr) + Music *nr = info.music_cause (); + if (nr && nr->is_mus_type ("note-event")) { Pitch pitch = *unsmob_pitch (nr->get_mus_property ("pitch")); if (Pitch::compare (pitch_min, pitch_max) > 0) // already init'd? diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 7a37e5d3e7..aff46accf1 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -375,9 +375,8 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) if (Stem::has_interface (info.grob_)) { Item* stem = dynamic_cast (info.grob_); - - Rhythmic_req *rhythmic_req = dynamic_cast (info.music_cause ()); - if (!rhythmic_req) + Music* m = info.music_cause (); + if (!m->is_mus_type ("rhythmic-event")) { programming_error ("Stem must have rhythmic structure"); return; @@ -400,7 +399,7 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) return ; } - int durlog = unsmob_duration (rhythmic_req->get_mus_property ("duration"))->duration_log (); + int durlog = unsmob_duration (m->get_mus_property ("duration"))->duration_log (); if (durlog <= 2) { @@ -417,7 +416,7 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) return ; - Moment dur = unsmob_duration (rhythmic_req->get_mus_property ("duration"))->length_mom (); + Moment dur = unsmob_duration (m->get_mus_property ("duration"))->length_mom (); /* FIXME: This comment has been here since long: @@ -453,7 +452,7 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) durlog - 2); stems_->push (stem); last_add_mom_ = now; - extend_mom_ = (extend_mom_ >? now) + rhythmic_req->length_mom (); + extend_mom_ = (extend_mom_ >? now) + m->length_mom (); } } diff --git a/lily/auto-change-iterator.cc b/lily/auto-change-iterator.cc index 74d345ee14..a2ab5be5e5 100644 --- a/lily/auto-change-iterator.cc +++ b/lily/auto-change-iterator.cc @@ -86,11 +86,14 @@ Auto_change_iterator::pending_pitch (Moment m) const { SCM muses = iter->get_pending_events (m); for (SCM s = muses; gh_pair_p (s); s=ly_cdr (s)) - if (Note_req* nr = dynamic_cast (unsmob_music (ly_car (s)))) - { - ps.push (*unsmob_pitch (nr->get_mus_property ("pitch"))); - } - + { + Music * m = unsmob_music (ly_car (s)); + if (m && m->is_mus_type ("note-event")) + { + ps.push (*unsmob_pitch (m->get_mus_property ("pitch"))); + } + } + if (ps.size ()) break; diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index a126111fba..3d6b29bb7b 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -348,7 +348,7 @@ be printed with flags instead of beams. Only engraves beams when we are at grace points in time. ", /* creats*/ "Beam", -/* accepts */ "general-music", +/* accepts */ "beam-event abort-event", /* acks */ "stem-interface rest-interface", /* reads */ "beamMelismaBusy beatLength subdivideBeams", /* write */ ""); diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index 10bff134a9..79ad18fc2b 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -28,7 +28,7 @@ protected: virtual bool try_music (Music *); private: - void add_note (Note_req *); + void add_note (Music *); Item* chord_name_; @@ -46,7 +46,7 @@ Chord_name_engraver::Chord_name_engraver () } void -Chord_name_engraver::add_note (Note_req* n) +Chord_name_engraver::add_note (Music * n) { SCM pitches = ly_car (chord_); SCM modifiers = ly_cdr (chord_); @@ -66,9 +66,12 @@ Chord_name_engraver::add_note (Note_req* n) bool Chord_name_engraver::try_music (Music* m) { - if (Note_req* n = dynamic_cast (m)) + /* + hmm. Should check? + */ + if (m->is_mus_type ("note-event")) { - add_note (n); + add_note (m); return true; } return false; @@ -104,10 +107,10 @@ Chord_name_engraver::stop_translation_timestep () } ENTER_DESCRIPTION(Chord_name_engraver, -/* descr */ "Catch Note_req's, Tonic_reqs, Inversion_reqs, Bass_req +/* descr */ "Catch note-events, Tonic_reqs, Inversion_reqs, Bass_req and generate the appropriate chordname.", /* creats*/ "ChordName", -/* accepts */ "general-music", +/* accepts */ "note-event busy-playing-event", /* acks */ "", /* reads */ "chordChanges", /* write */ ""); diff --git a/lily/command-request.cc b/lily/command-request.cc index 65add7878c..5892d04022 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -102,12 +102,10 @@ Mark_req::do_equal_b (Request const * r) const get_mus_property ("label")) == SCM_BOOL_T; } -ADD_MUSIC(Bass_figure_req); ADD_MUSIC (Arpeggio_req); ADD_MUSIC (Articulation_req); ADD_MUSIC (Break_req); ADD_MUSIC (Breathing_sign_req); -ADD_MUSIC (Busy_playing_req); ADD_MUSIC (Extender_req); ADD_MUSIC (Glissando_req); ADD_MUSIC (Hyphen_req); @@ -116,15 +114,11 @@ ADD_MUSIC (Lyric_req); ADD_MUSIC (Mark_req); ADD_MUSIC (Melisma_playing_req); ADD_MUSIC (Melisma_req); -ADD_MUSIC (Melodic_req); -ADD_MUSIC (Note_req); ADD_MUSIC (Porrectus_req); -ADD_MUSIC (Rest_req); ADD_MUSIC (Rhythmic_req); ADD_MUSIC (Script_req); ADD_MUSIC (Skip_req); ADD_MUSIC (Span_req); ADD_MUSIC (Tempo_req); ADD_MUSIC (Text_script_req); -ADD_MUSIC (Tie_req); ADD_MUSIC (Tremolo_req); diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index ebae8d888c..95fa36461f 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -68,9 +68,9 @@ Completion_heads_engraver::initialize () bool Completion_heads_engraver::try_music (Music *m) { - if (Note_req * n =dynamic_cast (m)) + if (m->is_mus_type ("note-event")) { - note_reqs_.push (n); + note_reqs_.push (m); first_b_ = true; Moment musiclen = m->length_mom (); @@ -86,7 +86,7 @@ Completion_heads_engraver::try_music (Music *m) return true; } - else if (dynamic_cast (m)) + else if (m->is_mus_type ("busy-playing-event")) { return note_reqs_.size (); } diff --git a/lily/custos-engraver.cc b/lily/custos-engraver.cc index e8d9a820df..6af09938e3 100644 --- a/lily/custos-engraver.cc +++ b/lily/custos-engraver.cc @@ -72,9 +72,12 @@ Custos_engraver::acknowledge_grob (Grob_info info) Item *item = dynamic_cast (info.grob_); if (item) { + Music * m = info.music_cause(); if (Bar_line::has_interface (info.grob_)) custos_permitted = true; - else if (Note_head::has_interface (info.grob_)) + else if (Note_head::has_interface (info.grob_) + && m + && m->is_mus_type ("note-event")) { /* @@ -85,9 +88,7 @@ Custos_engraver::acknowledge_grob (Grob_info info) don't look at the staff-position, since we can't be sure whether Clef_engraver already applied a vertical shift. */ - Note_req * nr = dynamic_cast (info.music_cause ()); - if (nr) - pitches_.push (*unsmob_pitch (nr->get_mus_property ("pitch"))); + pitches_.push (*unsmob_pitch (m->get_mus_property ("pitch"))); } } } diff --git a/lily/engraver-group-engraver.cc b/lily/engraver-group-engraver.cc index 403d620489..50a9e67ddd 100644 --- a/lily/engraver-group-engraver.cc +++ b/lily/engraver-group-engraver.cc @@ -65,6 +65,8 @@ acks. */ SCM find_acknowledge_engravers (SCM gravlist, SCM meta); +SCM find_accept_engravers (SCM gravlist, SCM music_descr); + void Engraver_group_engraver::acknowledge_grobs () { @@ -163,7 +165,11 @@ Engraver_group_engraver::process_music () void Engraver_group_engraver::initialize () { - SCM tab = scm_make_vector (gh_int2scm (61), SCM_BOOL_F); // magic -> + /* + docme: why bool_f. + + */ + SCM tab = scm_make_vector (gh_int2scm (61), SCM_BOOL_F); set_property ("acknowledgeHashTable", tab); Translator_group::initialize (); @@ -195,6 +201,7 @@ bool engraver_valid (Translator*tr, SCM ifaces) } + SCM find_acknowledge_engravers (SCM gravlist, SCM meta_alist) { @@ -211,3 +218,5 @@ find_acknowledge_engravers (SCM gravlist, SCM meta_alist) return l; } + + diff --git a/lily/figured-bass-engraver.cc b/lily/figured-bass-engraver.cc index 1cf1cc5cf2..1a4f310e98 100644 --- a/lily/figured-bass-engraver.cc +++ b/lily/figured-bass-engraver.cc @@ -8,8 +8,8 @@ class Figured_bass_engraver : public Engraver TRANSLATOR_DECLARATIONS(Figured_bass_engraver); protected: - Link_array figures_; - Rest_req * rest_req_; + Link_array figures_; + Music * rest_req_; Grob * figure_; @@ -41,14 +41,14 @@ Figured_bass_engraver::stop_translation_timestep () bool Figured_bass_engraver::try_music (Music*m) { - if (Bass_figure_req* bfr = dynamic_cast (m)) + if (m->is_mus_type ("bass-figure-event")) { - figures_.push (bfr); + figures_.push (m); return true; } - else if (Rest_req * r = dynamic_cast (m)) + else if (m->is_mus_type ("rest-event")) { - rest_req_ = r; + rest_req_ = m; return true; } return false; diff --git a/lily/grob-pitch-tuple.cc b/lily/grob-pitch-tuple.cc index 2bfc994269..fc6e450f99 100644 --- a/lily/grob-pitch-tuple.cc +++ b/lily/grob-pitch-tuple.cc @@ -25,7 +25,7 @@ Grob_pitch_tuple::Grob_pitch_tuple () end_ = 0; } -Grob_pitch_tuple::Grob_pitch_tuple (Grob *h, Melodic_req*m, Moment mom) +Grob_pitch_tuple::Grob_pitch_tuple (Grob *h, Music *m, Moment mom) { head_ = h; pitch_ = *unsmob_pitch (m->get_mus_property ("pitch")); diff --git a/lily/include/grob-pitch-tuple.hh b/lily/include/grob-pitch-tuple.hh index e174ed668e..ec798c8cf8 100644 --- a/lily/include/grob-pitch-tuple.hh +++ b/lily/include/grob-pitch-tuple.hh @@ -20,7 +20,7 @@ struct Grob_pitch_tuple { Moment end_; Grob_pitch_tuple (); - Grob_pitch_tuple (Grob*, Melodic_req*, Moment); + Grob_pitch_tuple (Grob*, Music*, Moment); static int pitch_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &); static int time_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &); }; diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index e02c5120ab..3dea8a1b68 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -123,7 +123,6 @@ class Pitch; class Musical_req; class My_lily_lexer; class Note_performer; -class Note_req; class Output_property; class Paper_column; class Paper_def; diff --git a/lily/include/music-constructor.hh b/lily/include/music-constructor.hh index 1e9dc262ff..c6a20d7399 100644 --- a/lily/include/music-constructor.hh +++ b/lily/include/music-constructor.hh @@ -22,7 +22,7 @@ Music * _ ## type ## _ctor ()\ static void _ ## type ## _adder () {\ add_music_ctor (#type, & _ ## type ## _ctor);\ }\ -ADD_GLOBAL_CTOR (_ ## type ## _adder); +ADD_SCM_INIT_FUNC( _ ## type ## _adder_prefix, _ ## type ## _adder); void add_music_ctor (String, Music* (*) ()); Music*make_music (String); diff --git a/lily/include/music.hh b/lily/include/music.hh index 13e79e65b3..a8457dee8b 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -21,6 +21,7 @@ #define get_mus_property(x) internal_get_mus_property(ly_symbol2scm(x)) #define set_mus_property(x,y) internal_set_mus_property(ly_symbol2scm (x), y) +#define is_mus_type(x) internal_is_music_type(ly_symbol2scm (x)) /** Music is anything that has duration and supports both time compression and transposition. @@ -42,8 +43,8 @@ public: SCM internal_get_mus_property (SCM) const; void internal_set_mus_property (SCM , SCM val); - void add_music_type (SCM); - bool is_music_type (SCM) const; + SCM get_property_alist (bool mut) const; + bool internal_is_music_type (SCM) const; virtual Pitch to_relative_octave (Pitch); diff --git a/lily/include/musical-request.hh b/lily/include/musical-request.hh index d9b67bb9b6..488f080de5 100644 --- a/lily/include/musical-request.hh +++ b/lily/include/musical-request.hh @@ -21,7 +21,6 @@ */ class Rhythmic_req : public virtual Request { public: - bool do_equal_b (Request const*) const; void compress (Moment); virtual Moment length_mom () const; static int compare (Rhythmic_req const&,Rhythmic_req const&); @@ -41,7 +40,6 @@ struct Tremolo_req : public Request { struct Chord_tremolo_notify_req : public Request { - Rational factor_; VIRTUAL_COPY_CONS(Chord_tremolo_notify_req); Chord_tremolo_notify_req(); @@ -64,7 +62,6 @@ public: String get_articulation_string (); protected: virtual bool do_equal_b (Request const*) const; - VIRTUAL_COPY_CONS (Music); }; @@ -93,24 +90,6 @@ protected: VIRTUAL_COPY_CONS (Music); }; -/* - Put a note of specified type, height, and with accidental on the staff. - /// force/supress printing of accidental. - bool forceacc_b_; - /// Cautionary, i.e. parenthesized accidental. - bool cautionary_b_; - - */ -class Note_req : public Rhythmic_req, virtual public Melodic_req { -public: - - Note_req (); -protected: - - bool do_equal_b (Request const*) const; - VIRTUAL_COPY_CONS (Music); -}; - /** Put a rest on the staff. Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded. */ @@ -132,15 +111,6 @@ public: VIRTUAL_COPY_CONS (Music); }; -/** is anyone playing a note? - Used for communication between Music & Lyrics - */ -class Busy_playing_req : public Request -{ -public: - VIRTUAL_COPY_CONS (Music); -}; - /** @@ -173,10 +143,5 @@ public: VIRTUAL_COPY_CONS (Music); }; -class Bass_figure_req: public Rhythmic_req -{ -public: - VIRTUAL_COPY_CONS(Music); -}; #endif // MUSICALREQUESTS_HH diff --git a/lily/main.cc b/lily/main.cc index 573409e831..ff00e7c334 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -340,10 +340,10 @@ main_prog (void *, int, char **) dirinfo (stderr); ly_init_guile (); + call_constructors (); progress_indication ("\n"); - call_constructors (); all_fonts_global = new All_font_metrics (global_path.string ()); init_scheme_code_string += ")"; diff --git a/lily/mensural-ligature-engraver.cc b/lily/mensural-ligature-engraver.cc index 0672e9b8d9..4678e9bf26 100644 --- a/lily/mensural-ligature-engraver.cc +++ b/lily/mensural-ligature-engraver.cc @@ -341,8 +341,15 @@ Mensural_ligature_engraver::transform_heads () Grob_info info = primitives_[i]; int duration_log = Note_head::get_balltype (dynamic_cast (info.grob_)); - Note_req *nr = dynamic_cast (info.music_cause ()); - if (!nr) + + Music * nr = info.music_cause (); + + + /* + + ugh. why not simply check for pitch? + */ + if (!nr->is_mus_type ("note-event")) { info.music_cause ()->origin ()->warning (_f ("can not determine pitch of ligature primitive -> skipping")); i++; @@ -395,10 +402,8 @@ Mensural_ligature_engraver::transform_heads () void set_delta_pitch (Item *primitive, Grob_info info1, Grob_info info2) { - Note_req *nr1 = dynamic_cast (info1.music_cause ()); - Note_req *nr2 = dynamic_cast (info2.music_cause ()); - Pitch pitch1 = *unsmob_pitch (nr1->get_mus_property ("pitch")); - Pitch pitch2 = *unsmob_pitch (nr2->get_mus_property ("pitch")); + Pitch pitch1 = *unsmob_pitch (info1.music_cause ()->get_mus_property ("pitch")); + Pitch pitch2 = *unsmob_pitch (info2.music_cause ()->get_mus_property ("pitch")); int delta_pitch = (pitch2.steps () - pitch1.steps ()); primitive->set_grob_property ("delta-pitch", gh_int2scm (delta_pitch)); } @@ -510,8 +515,7 @@ Mensural_ligature_engraver::join_primitives () for (int i = 0; i < primitives_.size (); i++) { Grob_info info = primitives_[i]; - Note_req *nr = dynamic_cast (info.music_cause ()); - Pitch pitch = *unsmob_pitch (nr->get_mus_property ("pitch")); + Pitch pitch = *unsmob_pitch (info.music_cause ()->get_mus_property ("pitch")); if (i > 0) { Item *primitive = dynamic_cast (info.grob_); diff --git a/lily/music.cc b/lily/music.cc index d87be5881e..159f431090 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -34,18 +34,10 @@ ly_deep_mus_copy (SCM m) -void -Music::add_music_type (SCM sym) -{ - assert (gh_symbol_p (sym)); - SCM types= get_mus_property ("types"); - types = scm_cons (sym, types); - set_mus_property ("types", types); -} bool -Music::is_music_type (SCM k)const +Music::internal_is_music_type (SCM k)const { SCM ifs = get_mus_property ("types"); @@ -66,12 +58,8 @@ Music::Music (Music const &m) smobify_self (); mutable_property_alist_ = ly_deep_mus_copy (m.mutable_property_alist_); set_spot (*m.origin ()); - - add_music_type (ly_symbol2scm ("general-music")); } - - Music::Music () { self_scm_ = SCM_EOL; @@ -80,6 +68,11 @@ Music::Music () smobify_self (); } +SCM +Music::get_property_alist (bool m) const +{ + return (m) ? mutable_property_alist_ : immutable_property_alist_; +} SCM Music::mark_smob (SCM m) @@ -91,12 +84,16 @@ Music::mark_smob (SCM m) } void -Music::compress (Moment) +Music::compress (Moment f) { + SCM l = get_mus_property ("compress-procedure"); + if (gh_procedure_p (l)) + { + SCM res = gh_call2 (l, self_scm (), f.smobbed_copy()); + } } - Moment Music::length_mom () const { diff --git a/lily/musical-request.cc b/lily/musical-request.cc index c4a58d0ed2..ff1f9ad557 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -16,21 +16,44 @@ Tremolo_req::Tremolo_req () { } -bool -Melodic_req::do_equal_b (Request const* r) const +LY_DEFINE(music_duration_length, "music-duration-length", 1, 0,0, + (SCM mus), + "Extract the duration field from @var{mus}, and return the length.") { - Melodic_req const* m= dynamic_cast (r); - return m; // && !compare (*m, *this); + Music* m = unsmob_music(mus); + SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "Music"); + + Duration *d = unsmob_duration (m->get_mus_property ("duration")); + + Moment l ; + + if (d) + { + l = d->length_mom (); + } + else + programming_error("Rhythmic_req has no duration"); + return l.smobbed_copy(); + } -bool -Rhythmic_req::do_equal_b (Request const* r) const -{ - Rhythmic_req const* rh = dynamic_cast (r); - return rh; // ; && !compare (*this, *rh); +LY_DEFINE(music_duration_compress, "music-duration-compress", 2, 0,0, + (SCM mus, SCM factor), + "Extract the duration field from @var{mus}, and compress it.") +{ + Music* m = unsmob_music(mus); + Moment * f = unsmob_moment (factor); + SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "Music"); + SCM_ASSERT_TYPE(f, factor, SCM_ARG2, __FUNCTION__, "Moment"); + + Duration *d = unsmob_duration (m->get_mus_property ("duration")); + if (d) + m->set_mus_property ("duration", d->compressed (f->main_part_).smobbed_copy()); + return SCM_UNSPECIFIED; } + Moment Rhythmic_req::length_mom () const { @@ -52,17 +75,6 @@ Rhythmic_req::compress (Moment m) set_mus_property ("duration", d ->compressed (m.main_part_).smobbed_copy ()); } -bool -Note_req::do_equal_b (Request const* r) const -{ - Note_req const* n = dynamic_cast (r); - return n&& Rhythmic_req::do_equal_b (n) && Melodic_req::do_equal_b (n); -} - - -Note_req::Note_req () -{ -} bool diff --git a/lily/new-accidental-engraver.cc b/lily/new-accidental-engraver.cc index 0bc51dff5c..1e5fd92acc 100644 --- a/lily/new-accidental-engraver.cc +++ b/lily/new-accidental-engraver.cc @@ -39,7 +39,7 @@ struct New_accidental_entry { int number_accidentals_; int number_cautionaries_; bool different_; - Note_req * melodic_; + Music * melodic_; Grob * accidental_; Translator_group *origin_; Grob* head_; @@ -182,7 +182,7 @@ calculates the number of accidentals on basis of the current local key sig */ static int -number_accidentals (SCM sig, Note_req * note, Pitch *pitch, SCM curbarnum, SCM lazyness, +number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazyness, bool ignore_octave_b) { int n = pitch->notename_; @@ -228,7 +228,7 @@ number_accidentals (SCM sig, Note_req * note, Pitch *pitch, SCM curbarnum, SCM l } static int -number_accidentals (Note_req * note, Pitch *pitch, Translator_group * origin, +number_accidentals (Music * note, Pitch *pitch, Translator_group * origin, SCM accidentals, SCM curbarnum) { int number = 0; @@ -307,7 +307,7 @@ New_accidental_engraver::process_grobs_first_pass () accidentals_[i].pass_done_ = 1; Grob * support = accidentals_[i].head_; - Note_req * note = accidentals_[i].melodic_; + Music * note = accidentals_[i].melodic_; Translator_group * origin = accidentals_[i].origin_; Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch")); @@ -383,7 +383,7 @@ New_accidental_engraver::process_grobs_second_pass () continue; accidentals_[i].pass_done_ = 2; Grob * support = accidentals_[i].head_; - Note_req * note = accidentals_[i].melodic_; + Music * note = accidentals_[i].melodic_; Translator_group * origin = accidentals_[i].origin_; Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch")); @@ -505,9 +505,11 @@ New_accidental_engraver::stop_translation_timestep () void New_accidental_engraver::acknowledge_grob (Grob_info info) { - Note_req * note = dynamic_cast (info.music_cause ()); + Music * note = info.music_cause (); - if (note && Rhythmic_head::has_interface (info.grob_)) + if (note + && note->is_mus_type ("note-event") + && Rhythmic_head::has_interface (info.grob_)) { New_accidental_entry entry ; entry.head_ = info.grob_; diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index 243783adb2..7ce9a433de 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -23,7 +23,7 @@ class Note_heads_engraver : public Engraver Link_array notes_; Link_array dots_; - Link_array note_reqs_; + Link_array note_reqs_; public: TRANSLATOR_DECLARATIONS(Note_heads_engraver); @@ -47,27 +47,25 @@ Note_heads_engraver::Note_heads_engraver() bool Note_heads_engraver::try_music (Music *m) { - if (Note_req * n =dynamic_cast (m)) + if (m->is_mus_type ("note-event")) { - note_reqs_.push (n); + note_reqs_.push (m); return true; } - else if (dynamic_cast (m)) + else if (m->is_mus_type ("busy-playing-event")) + return note_reqs_.size (); + else if (m->is_mus_type ("abort-event")) { - return note_reqs_.size (); + in_ligature = 0; } - else if (Span_req *req_ = dynamic_cast (m)) + else if (m->is_mus_type ("ligature-event")) { - if (scm_equal_p (req_->get_mus_property ("span-type"), - scm_makfrom0str ("abort")) == SCM_BOOL_T) - { - in_ligature = 0; - } - else if (scm_equal_p (req_->get_mus_property ("span-type"), - scm_makfrom0str ("ligature")) == SCM_BOOL_T) - { - in_ligature = (req_->get_span_dir () == START); - } + /* + Urg ; this is not protocol. We should accept and return + true, or ignore. + */ + in_ligature = (m->get_mus_property("span-direction") + == gh_int2scm (START)); } return false; @@ -129,7 +127,6 @@ Note_heads_engraver::stop_translation_timestep () typeset_grob (dots_[i]); } dots_.clear (); - note_reqs_.clear (); } @@ -140,9 +137,9 @@ Note_heads_engraver::start_translation_timestep () ENTER_DESCRIPTION(Note_heads_engraver, -/* descr */ "Generate one or more noteheads from Music of type Note_req.", -/* creats*/ "NoteHead Dots", -/* accepts */ "general-music", +/* descr */ "Generate noteheads (also serves a double functions: makes ligatures.", +/* creats*/ "NoteHead LigatureHead Dots", +/* accepts */ "note-event busy-playing-event ligature-event abort-event", /* acks */ "", /* reads */ "centralCPosition", /* write */ ""); diff --git a/lily/note-name-engraver.cc b/lily/note-name-engraver.cc index 0ffa2d00b0..bfd6fafb49 100644 --- a/lily/note-name-engraver.cc +++ b/lily/note-name-engraver.cc @@ -16,7 +16,7 @@ class Note_name_engraver : public Engraver public: TRANSLATOR_DECLARATIONS(Note_name_engraver); - Link_array reqs_; + Link_array reqs_; Link_array texts_; virtual bool try_music (Music*m); virtual void process_acknowledged_grobs (); @@ -26,9 +26,9 @@ public: bool Note_name_engraver::try_music (Music *m) { - if (Note_req *r = dynamic_cast (m)) + if (m->is_mus_type ("note-event")) { - reqs_.push (r); + reqs_.push (m); return true; } return false; diff --git a/lily/note-performer.cc b/lily/note-performer.cc index ae8b1adf17..91509a9734 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -28,9 +28,9 @@ protected: Global_translator* get_global_translator (); private: - Array note_reqs_; - Array notes_; - Array delayeds_; + Link_array note_reqs_; + Link_array notes_; + Link_array delayeds_; }; void @@ -46,7 +46,7 @@ Note_performer::create_audio_elements () while (note_reqs_.size ()) { - Note_req* n = note_reqs_.pop (); + Music* n = note_reqs_.pop (); Pitch pit = * unsmob_pitch (n->get_mus_property ("pitch")); Audio_note* p = new Audio_note (pit, n->length_mom (), transposing_i); Audio_element_info info (p, n); @@ -117,9 +117,9 @@ Note_performer::stop_translation_timestep () bool Note_performer::try_music (Music* req) { - if (Note_req *nr = dynamic_cast (req)) + if (req->is_mus_type ("note-event")) { - note_reqs_.push (nr); + note_reqs_.push (req); return true; } return false; diff --git a/lily/parser.yy b/lily/parser.yy index 1808045c87..f67fa5363d 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1172,9 +1172,8 @@ command_element: $1-> set_spot (THIS->here_input ()); } | E_LEFTSQUARE { - Music *l = MY_MAKE_MUSIC("SpanEvent"); + Music *l = MY_MAKE_MUSIC("LigatureEvent"); l->set_mus_property ("span-direction", gh_int2scm (START)); - l->set_mus_property ("span-type", scm_makfrom0str ("ligature")); l->set_spot (THIS->here_input ()); $$ = MY_MAKE_MUSIC("RequestChord"); @@ -1183,9 +1182,8 @@ command_element: $$->set_spot (THIS->here_input ()); } | E_RIGHTSQUARE { - Music *l = MY_MAKE_MUSIC("SpanEvent"); + Music *l = MY_MAKE_MUSIC("LigatureEvent"); l->set_mus_property ("span-direction", gh_int2scm (STOP)); - l->set_mus_property ("span-type", scm_makfrom0str ("ligature")); l->set_spot (THIS->here_input ()); $$ = MY_MAKE_MUSIC("RequestChord"); diff --git a/lily/part-combine-music-iterator.cc b/lily/part-combine-music-iterator.cc index 8f38b48205..fcc99f05ba 100644 --- a/lily/part-combine-music-iterator.cc +++ b/lily/part-combine-music-iterator.cc @@ -153,16 +153,15 @@ get_music_info (Moment m, Music_iterator* iter, SCM *pitches, SCM *durations) for (SCM i = iter->get_pending_events (m); gh_pair_p (i); i = ly_cdr (i)) { Music *m = unsmob_music (ly_car (i)); - if (Melodic_req *r = dynamic_cast (m)) - *pitches = gh_cons (r->get_mus_property ("pitch"), *pitches); - if (Rhythmic_req *r = dynamic_cast (m)) + if (m->is_mus_type ("melodic-event")) + *pitches = gh_cons (m->get_mus_property ("pitch"), *pitches); + if (m->is_mus_type ("rhythmic-event")) { - SCM d = r->get_mus_property ("duration"); + SCM d = m->get_mus_property ("duration"); if (d == SCM_EOL) - r->origin ()->warning ("Rhythmic_req has no duration\n"); - else - // *durations = gh_cons (r->get_mus_property ("duration"), *durations); - *durations = gh_cons (d, *durations); + m->origin ()->warning ("Rhythmic_req has no duration\n"); + else + *durations = gh_cons (d, *durations); } } } @@ -394,8 +393,7 @@ s Consider thread switching: threads "one", "two" and "both". if (!abort_req) { - abort_req = make_music_by_name (ly_symbol2scm ("SpanEvent")); - abort_req->set_mus_property ("span-type", scm_makfrom0str ("abort")); + abort_req = make_music_by_name (ly_symbol2scm ("AbortEvent")); } if (combine_b && combine_b != previously_combined_b) diff --git a/lily/porrectus-engraver.cc b/lily/porrectus-engraver.cc index 578389b1ab..eb5737d1db 100644 --- a/lily/porrectus-engraver.cc +++ b/lily/porrectus-engraver.cc @@ -92,12 +92,11 @@ Porrectus_engraver::acknowledge_grob (Grob_info info_) { if (Rhythmic_head::has_interface (info_.grob_)) { - Note_req *note_req_ = dynamic_cast (info_.music_cause ()); - if (!note_req_) - return; - right_heads_.push (Grob_pitch_tuple (info_.grob_, note_req_, - now_mom () + - note_req_->length_mom ())); + Music * m = info_.music_cause (); + if (m->is_mus_type ("note-event")) + right_heads_.push (Grob_pitch_tuple (info_.grob_, m, + now_mom () + + m->length_mom ())); } } diff --git a/lily/request-chord.cc b/lily/request-chord.cc index 7d9cb184f4..2cf46c91cd 100644 --- a/lily/request-chord.cc +++ b/lily/request-chord.cc @@ -13,14 +13,9 @@ Request_chord::to_relative_octave (Pitch last) for (SCM s = music_list (); gh_pair_p (s); s = ly_cdr (s)) { Music * mus = unsmob_music (ly_car (s)); - Melodic_req *m= dynamic_cast (mus); - /* - kLudge: rests have pitches now as well. - */ - Rest_req *r = dynamic_cast (mus); - - if (r || m) + if (mus->is_mus_type ("melodic-event") + || mus->is_mus_type ("rest-event")) { Pitch *old_pit = unsmob_pitch (mus->get_mus_property ("pitch")); if (!old_pit) diff --git a/lily/rest-engraver.cc b/lily/rest-engraver.cc index dc617ef3b7..3aabd92441 100644 --- a/lily/rest-engraver.cc +++ b/lily/rest-engraver.cc @@ -15,7 +15,7 @@ class Rest_engraver : public Engraver { - Rest_req *rest_req_; + Music *rest_req_; Item * dot_; Grob* rest_; protected: @@ -67,8 +67,6 @@ Rest_engraver::process_music () { rest_ = new Item (get_property ("Rest")); - - int durlog = unsmob_duration (rest_req_->get_mus_property ("duration"))-> duration_log (); rest_->set_grob_property ("duration-log", @@ -109,20 +107,18 @@ Rest_engraver::process_music () bool Rest_engraver::try_music (Music *m) { - if (Rest_req *r = dynamic_cast (m)) + if (m->is_mus_type ("rest-event")) { - rest_req_ = r; + rest_req_ = m; return true; - } + } return false; } - - ENTER_DESCRIPTION(Rest_engraver, /* descr */ "", /* creats*/ "Rest Dots", -/* accepts */ "general-music", +/* accepts */ "rest-event", /* acks */ "", /* reads */ "centralCPosition", /* write */ ""); diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index b18a94074f..8d08ee0dd8 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -57,9 +57,10 @@ Stem_engraver::acknowledge_grob (Grob_info i) /* Reverted to the old method so chord tremolos work again. /MB */ int duration_log = 0; - Rhythmic_req *rhythmic_req = dynamic_cast (i.music_cause ()); - if (rhythmic_req) - duration_log = unsmob_duration (rhythmic_req->get_mus_property ("duration"))-> duration_log (); + + Music * m = i.music_cause (); + if (m->is_mus_type ("rhythmic-event")) + duration_log = unsmob_duration (m->get_mus_property ("duration"))-> duration_log (); if (!stem_) { diff --git a/lily/tab-note-heads-engraver.cc b/lily/tab-note-heads-engraver.cc index 603074d234..fb2b29101a 100644 --- a/lily/tab-note-heads-engraver.cc +++ b/lily/tab-note-heads-engraver.cc @@ -24,8 +24,8 @@ class Tab_note_heads_engraver : public Engraver Link_array notes_; Link_array dots_; - Link_array note_reqs_; - Link_array tabstring_reqs_; + Link_array note_reqs_; + Link_array tabstring_reqs_; public: TRANSLATOR_DECLARATIONS(Tab_note_heads_engraver); @@ -45,19 +45,20 @@ Tab_note_heads_engraver::Tab_note_heads_engraver() bool Tab_note_heads_engraver::try_music (Music *m) { - if (Note_req * n =dynamic_cast (m)) + if (m->is_mus_type ("note-event")) { - note_reqs_.push (n); + note_reqs_.push (m); return true; } - else if (String_number_req * ts = dynamic_cast (m)) + else if (m->is_mus_type ("string-number-event")) { while(tabstring_reqs_.size () < note_reqs_.size ()-1) tabstring_reqs_.push(0); - tabstring_reqs_.push(ts); + + tabstring_reqs_.push (m); return true; } - else if (dynamic_cast (m)) + else if (m->is_mus_type ("busy-playing-event")) { return note_reqs_.size (); } @@ -173,7 +174,7 @@ Tab_note_heads_engraver::start_translation_timestep () ENTER_DESCRIPTION(Tab_note_heads_engraver, /* descr */ "Generate one or more tablature noteheads from Music of type Note_req.", /* creats*/ "TabNoteHead Dots", -/* accepts */ "general-music", +/* accepts */ "note-event string-number-event busy-playing-event", /* acks */ "", /* reads */ "centralCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost", /* write */ ""); diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 2e97956165..64d17c63ff 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -21,7 +21,7 @@ /** Manufacture ties. Acknowledge noteheads, and put them into a - priority queue. If we have a Tie_req, connect the notes that finish + priority queue. If we have a TieEvent, connect the notes that finish just at this time, and note that start at this time. TODO: Remove the dependency on musical info. We should tie on the @@ -33,7 +33,7 @@ class Tie_engraver : public Engraver Moment end_mom_; Moment next_end_mom_; - Tie_req *req_; + Music *req_; Link_array now_heads_; Link_array stopped_heads_; Link_array ties_; @@ -63,23 +63,16 @@ Tie_engraver::Tie_engraver () bool -Tie_engraver::try_music (Music *m) +Tie_engraver::try_music (Music *mus) { - if (Tie_req * c = dynamic_cast (m)) + req_ = mus; + SCM m = get_property ("automaticMelismata"); + bool am = gh_boolean_p (m) &&gh_scm2bool (m); + if (am) { - /* if (end_mom_ > now_mom ()) - return false; - */ - req_ = c; - SCM m = get_property ("automaticMelismata"); - bool am = gh_boolean_p (m) &&gh_scm2bool (m); - if (am) - { - set_melisma (true); - } - return true; + set_melisma (true); } - return false; + return true; } void @@ -281,7 +274,7 @@ Tie_engraver::start_translation_timestep () ENTER_DESCRIPTION(Tie_engraver, /* descr */ "Generate ties between noteheads of equal pitch.", /* creats*/ "Tie TieColumn", -/* accepts */ "general-music", +/* accepts */ "tie-event", /* acks */ "rhythmic-head-interface", /* reads */ "sparseTies tieMelismaBusy", /* write */ ""); diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index eb7b0f3c78..d76b71c4d8 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -14,11 +14,11 @@ #include "performer.hh" struct CNote_melodic_tuple { - Melodic_req *req_ ; + Music *req_ ; Audio_note *note_; Moment end_; CNote_melodic_tuple (); - CNote_melodic_tuple (Audio_note*, Melodic_req*, Moment); + CNote_melodic_tuple (Audio_note*, Music*, Moment); static int pitch_compare (CNote_melodic_tuple const &, CNote_melodic_tuple const &); static int time_compare (CNote_melodic_tuple const &, CNote_melodic_tuple const &); }; @@ -31,7 +31,7 @@ inline int compare (CNote_melodic_tuple const &a, CNote_melodic_tuple const &b) /** Manufacture ties. Acknowledge notes, and put them into a - priority queue. If we have a Tie_req, connect the notes that finish + priority queue. If we have a Music, connect the notes that finish just at this time, and note that start at this time. TODO: should share code with Tie_engraver ? @@ -43,7 +43,7 @@ public: private: bool done_; PQueue past_notes_pq_; - Tie_req *req_; + Music *req_; Array now_notes_; Array stopped_notes_; Link_array ties_; @@ -65,7 +65,7 @@ Tie_performer::Tie_performer () } ENTER_DESCRIPTION (Tie_performer, "", "", - "general-music", + "tie-event", "", "", ""); @@ -81,11 +81,8 @@ Tie_performer::try_music (Music *m) { if (!req_) { - if (Tie_req * c = dynamic_cast (m)) - { - req_ = c; - return true; - } + req_ = m; + return true; } return false; } @@ -95,10 +92,9 @@ Tie_performer::acknowledge_audio_element (Audio_element_info i) { if (Audio_note *nh = dynamic_cast (i.elem_)) { - Note_req * m = dynamic_cast (i.req_); - if (!m) - return; - now_notes_.push (CNote_melodic_tuple (nh, m, now_mom ()+ m->length_mom ())); + Music *m = i.req_; + if (m->is_mus_type ("note-event")) + now_notes_.push (CNote_melodic_tuple (nh, m, now_mom ()+ m->length_mom ())); } } @@ -201,7 +197,7 @@ CNote_melodic_tuple::CNote_melodic_tuple () end_ = 0; } -CNote_melodic_tuple::CNote_melodic_tuple (Audio_note *h, Melodic_req*m, Moment mom) +CNote_melodic_tuple::CNote_melodic_tuple (Audio_note *h, Music*m, Moment mom) { note_ = h; req_ = m; diff --git a/lily/translator-group.cc b/lily/translator-group.cc index 6768de18c7..957ca17f0b 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -14,6 +14,7 @@ #include "scm-hash.hh" #include "translator-def.hh" #include "main.hh" +#include "music.hh" Translator_group::Translator_group (Translator_group const&s) : Translator (s) @@ -162,18 +163,6 @@ Translator_group::find_create_translator (String n, String id) return ret; } -bool -Translator_group::try_music_on_nongroup_children (Music *m) -{ - bool hebbes_b =false; - - for (SCM p = simple_trans_list_; !hebbes_b && gh_pair_p (p); p = ly_cdr (p)) - { - hebbes_b = unsmob_translator (ly_car (p))->try_music (m); - } - return hebbes_b; -} - bool Translator_group::try_music (Music* m) { @@ -399,6 +388,8 @@ Translator_group::do_announces () void Translator_group::initialize () { + SCM tab = scm_make_vector (gh_int2scm (19), SCM_BOOL_F); + set_property ("acceptHashTable", tab); each (&Translator::initialize); } @@ -408,31 +399,57 @@ Translator_group::finalize () each (&Translator::removal_processing); } -LY_DEFINE(ly_get_context_property, - "ly-get-context-property", 2, 0, 0, - (SCM context, SCM name), - "retrieve the value of @var{sym} from context @var{tr}") + + +bool translator_accepts_any_of (Translator*tr, SCM ifaces) { - Translator *t = unsmob_translator (context); - Translator_group* tr= dynamic_cast (t); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Translator group"); - SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol"); + SCM ack_ifs = scm_assoc (ly_symbol2scm ("events-accepted"), + tr->translator_description()); + ack_ifs = gh_cdr (ack_ifs); + for (SCM s = ifaces; ly_pair_p (s); s = ly_cdr (s)) + if (scm_memq (ly_car (s), ack_ifs) != SCM_BOOL_F) + return true; + return false; +} - return tr->internal_get_property (name); - +SCM +find_accept_translators (SCM gravlist, SCM ifaces) +{ + SCM l = SCM_EOL; + for (SCM s = gravlist; ly_pair_p (s); s = ly_cdr (s)) + { + Translator* tr = unsmob_translator (ly_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; } -LY_DEFINE(ly_set_context_property, - "ly-set-context-property", 3, 0, 0, - (SCM context, SCM name, SCM val), - "set value of property @var{sym} in context @var{tr} to @var{val}. -") +bool +Translator_group::try_music_on_nongroup_children (Music *m ) { - Translator *t = unsmob_translator (context); - Translator_group* tr= dynamic_cast (t); + SCM tab = get_property ("acceptHashTable"); + SCM name = scm_assq ( ly_symbol2scm ("name"), m->get_property_alist (false)); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); - tr->internal_set_property (name, val); + if (!gh_pair_p (name)) + return false; - return SCM_UNSPECIFIED; + name = gh_car (name); + SCM accept_list = scm_hashq_ref (tab, name, SCM_UNDEFINED); + if (accept_list == SCM_BOOL_F) + { + accept_list = find_accept_translators (simple_trans_list_, + m->get_mus_property ("types")); + scm_hashq_set_x (tab, name, accept_list); + } + + for (SCM p = accept_list; gh_pair_p (p); p = ly_cdr (p)) + { + Translator * t = unsmob_translator (ly_car (p)); + if (t && t->try_music (m)) + return true; + } + return false; } diff --git a/lily/type-swallow-translator.cc b/lily/type-swallow-translator.cc index b483c39c18..0c77e982a9 100644 --- a/lily/type-swallow-translator.cc +++ b/lily/type-swallow-translator.cc @@ -6,16 +6,26 @@ (c) 1997--2002 Han-Wen Nienhuys */ -#include "type-swallow-translator.hh" +#include "translator.hh" #include "musical-request.hh" - -bool -Type_swallow_translator::try_music (Music*r) +class Skip_req_swallow_translator : public virtual Translator { - if (classname (r) == swallow_string_) - return true; - return false; -} +protected: + virtual bool try_music (Music*) { return true; } + +public: + TRANSLATOR_DECLARATIONS(Skip_req_swallow_translator); +}; + + +Skip_req_swallow_translator::Skip_req_swallow_translator(){} -DECLARE_REQUEST_SWALLOWER(Skip_req); +ENTER_DESCRIPTION(Skip_req_swallow_translator, + "Swallow \\skip.", + "", + "skip-event", + "", + "", + ""); + diff --git a/lily/voice-devnull-engraver.cc b/lily/voice-devnull-engraver.cc index 70204ee2f5..e8a5a3aa15 100644 --- a/lily/voice-devnull-engraver.cc +++ b/lily/voice-devnull-engraver.cc @@ -60,7 +60,7 @@ Voice_devnull_engraver::try_music (Music *m) } } /* Ugh. Should eat other requests, script etc. too. */ - else if (dynamic_cast (m)) + else if (m->is_mus_type ("tie-event")) return true; } return false; @@ -123,7 +123,7 @@ Voice_devnull_engraver::Voice_devnull_engraver(){} ENTER_DESCRIPTION(Voice_devnull_engraver, /* descr */ "Kill off certain items and spanners if we're Voice `two' and unison or unisilence is set.", /* creats*/ "", -/* accepts */ "general-music", +/* accepts */ "general-music tie-event", /* acks */ "grob-interface", /* reads */ "", /* write */ ""); diff --git a/scm/music-property-description.scm b/scm/music-property-description.scm index aef7bf664e..fc9e5b9cdd 100644 --- a/scm/music-property-description.scm +++ b/scm/music-property-description.scm @@ -34,6 +34,7 @@ TODO: consider making type into symbol ") (music-property-description 'cautionary boolean? "If set, this alteration needs cautionary accidental") (music-property-description 'change-to-id string? "name of the context to change to ") (music-property-description 'change-to-type string? "type of the context to change to.") +(music-property-description 'compress-procedure procedure? "compress this music expression. Argument 1: the music, arg 2: factor") (music-property-description 'context-id string? "name of context") (music-property-description 'context-type string? "type of context") (music-property-description 'denominator integer? "denominator in a time signature") @@ -49,6 +50,7 @@ TODO: consider making type into symbol ") (music-property-description 'last-pitch pitch? "The last pitch after relativization.") (music-property-description 'length procedure? "How to compute the duration of this music") (music-property-description 'internal-class-name string? "C++ class to use for this Music object") +(music-property-description 'name symbol? "Name of this music object") (music-property-description 'numerator integer? "numerator of a time signature") (music-property-description 'once boolean? "Apply this operation only during one time step?") (music-property-description 'origin ly-input-location? "where was this piece of music defined?") diff --git a/scm/music-types.scm b/scm/music-types.scm index c96ea36fdd..9c87866994 100644 --- a/scm/music-types.scm +++ b/scm/music-types.scm @@ -1,6 +1,12 @@ (define-public music-descriptions `( + (AbortEvent + . ( + (internal-class-name . "Span_req") + (span-type . "abort") + (types . (general-music event abort-event)) + )) (ArpeggioEvent . ( (internal-class-name . "Arpeggio_req") @@ -14,8 +20,10 @@ (BassFigureEvent . ( (internal-class-name . "Bass_figure_req") + (compress-procedure . ,music-duration-compress) + (length . ,music-duration-length) (types . (general-music event rhythmic-event bass-figure-event)) - )) + )) (BreakEvent . ( (internal-class-name . "Break_req") @@ -64,7 +72,13 @@ . ( (internal-class-name . "Lyric_req") (types . (general-music rhythmic-event event)) - )) + )) + (LigatureEvent + . ( + (internal-class-name . "Span_req") + (span-type . ligature) + (types . (general-music event span-event ligature-event)) + )) (MarkEvent . ( (internal-class-name . "Mark_req") @@ -87,8 +101,10 @@ )) (NoteEvent . ( - (internal-class-name . "Note_req") - (types . (general-music event rhythmic-event melodic-event)) + (internal-class-name . "Request") + (length . ,music-duration-length) + (compress-procedure . ,music-duration-compress) + (types . (general-music event note-event rhythmic-event melodic-event)) )) (PorrectusEvent . ( @@ -108,12 +124,16 @@ )) (RestEvent . ( - (internal-class-name . "Rest_req") - (types . (general-music event rhythmic-event )) + (internal-class-name . "Request") + (length . ,music-duration-length) + (compress-procedure . ,music-duration-compress) + (types . (general-music event rhythmic-event rest-event)) )) (RhythmicEvent . ( (internal-class-name . "Rhythmic_req") + (length . ,music-duration-length) + (compress-procedure . ,music-duration-compress) (types . (general-music rhythmic-event event)) )) (SequentialMusic @@ -160,7 +180,6 @@ (types . (general-music layout-instruction)) (iterator-ctor . , Push_property_iterator::constructor) )) - (RevertProperty . ( (internal-class-name . "Music") @@ -191,8 +210,6 @@ (iterator-ctor . , Change_iterator::constructor) (types . (general-music translator-change-instruction)) )) - - (TimeScaledMusic . ( (internal-class-name . "Time_scaled_music") @@ -252,9 +269,8 @@ )) (SkipEvent . ( - (internal-class-name . "Skip_req") - - (types . (general-music event rhythmic-event )) + (internal-class-name . "Request") + (types . (general-music event rhythmic-event skip-event)) )) (SpanEvent . ( @@ -280,29 +296,36 @@ )) (TieEvent . ( - (internal-class-name . "Tie_req") + (internal-class-name . "Request") (types . (general-music tie-event event)) )) )) -(define music-name-to-property-table (make-vector 59)) +(define music-name-to-property-table (make-vector 59 '())) + (map (lambda (x) - (hashq-set! music-name-to-property-table (car x) (cdr x)) + (hashq-set! music-name-to-property-table (car x) + (assoc-set! (cdr x) 'name (car x))) ) music-descriptions) + + (define-public (make-music-by-name x) (if (not (symbol? x)) (misc-error "Not a symbol: ~s" x)) (let* ( (props (hashq-ref music-name-to-property-table x '())) - (name (if (pair? props) (cdr (assoc 'internal-class-name props)) "Music")) + (name (if (pair? props) + (cdr (assoc 'internal-class-name props)) + (misc-error "Can not find music object ~s" x))) ) -, + (if (eq? props '()) (ly-warn (format "Could not find music type `~a'" x))) (ly-make-bare-music name props) )) + -- 2.39.5