From 98e7b0a30008cfea6e80b69e2d94c41ea4cd0f02 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Fri, 6 Feb 2004 22:38:47 +0000 Subject: [PATCH] * Documentation/user/refman.itely (More stanzas): document slur deficiency. * lily/melisma-performer.cc (try_music): new file. Handle melismata to help lyrics. * lily/beam-performer.cc (try_music): new file. Handle beam events to help lyrics. * lily/score-performer.cc (one_time_step): reinstate process_music(). * lily/performer.cc (process_music): add to interface. * lily/performer-group-performer.cc (process_music): new function. * lily/dot-column.cc (do_shifts): do collision resolution before dot positioning. --- ChangeLog | 20 +++++ Documentation/user/refman.itely | 3 +- lily/beam-engraver.cc | 29 ++---- lily/beam-performer.cc | 105 ++++++++++++++++++++++ lily/dot-column.cc | 20 +++++ lily/include/performer-group-performer.hh | 1 + lily/include/performer.hh | 1 + lily/include/translator.hh | 3 - lily/melisma-engraver.cc | 5 +- lily/melisma-performer.cc | 49 ++++++++++ lily/performer-group-performer.cc | 29 +++++- lily/performer.cc | 7 ++ lily/score-performer.cc | 3 +- lily/translator.cc | 2 +- ly/performer-init.ly | 3 + make/ly-rules.make | 4 +- 16 files changed, 252 insertions(+), 32 deletions(-) create mode 100644 lily/beam-performer.cc create mode 100644 lily/melisma-performer.cc diff --git a/ChangeLog b/ChangeLog index 6d8affe3e8..fe7ae09503 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,25 @@ 2004-02-06 Han-Wen Nienhuys + * Documentation/user/refman.itely (More stanzas): document slur + deficiency. + + * lily/melisma-performer.cc (try_music): new file. Handle + melismata to help lyrics. + + * lily/beam-performer.cc (try_music): new file. Handle beam events + to help lyrics. + + * lily/score-performer.cc (one_time_step): reinstate + process_music(). + + + * lily/performer.cc (process_music): add to interface. + + * lily/performer-group-performer.cc (process_music): new function. + + * lily/dot-column.cc (do_shifts): do collision resolution before + dot positioning. + * scripts/lilypond-book.py (Snippet.output_print_filename): new file, process printfilename option. (Snippet.__init__): rewrite: do not use global variables h or diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index ace7cf0593..2d5b100334 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -3540,7 +3540,8 @@ making or a music identifier @code{\foo} containing the syllable foo = \lyrics bar4 @end example - +The MIDI version of @code{\lyricsto} doesn't detect melismata caused +by slurs. @node Ambitus diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index cad222eef8..868ddcbfc9 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -22,7 +22,7 @@ class Beam_engraver : public Engraver { protected: - Drul_array evs_drul_; + Music * start_ev_; Spanner *finished_beam_; Spanner *beam_; @@ -87,7 +87,7 @@ Beam_engraver::Beam_engraver () finished_beam_info_=0; beam_info_ =0; now_stop_ev_ = 0; - evs_drul_[LEFT] = evs_drul_[RIGHT] =0; + start_ev_ = 0; prev_start_ev_ =0; } @@ -104,7 +104,7 @@ Beam_engraver::try_music (Music *m) if (d == START) { - evs_drul_[d] = m; + start_ev_ = m; } else if (d==STOP) { @@ -126,31 +126,21 @@ Beam_engraver::set_melisma (bool ml) void Beam_engraver::process_music () { - if (evs_drul_[STOP]) - { - prev_start_ev_ =0; - finished_beam_ = beam_; - finished_beam_info_ = beam_info_; - - beam_info_ =0; - beam_ = 0; - } - if (beam_ && !to_boolean (get_property ("allowBeamBreak"))) { top_engraver ()->forbid_breaks (); } - if (evs_drul_[START]) + if (start_ev_) { if (beam_) { - evs_drul_[START]->origin ()->warning (_ ("already have a beam")); + start_ev_->origin ()->warning (_ ("already have a beam")); return; } set_melisma (true); - prev_start_ev_ = evs_drul_[START]; + prev_start_ev_ = start_ev_; beam_ = make_spanner ("Beam"); SCM smp = get_property ("measurePosition"); Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0); @@ -161,7 +151,7 @@ Beam_engraver::process_music () beam_info_ = new Beaming_info_list; /* urg, must copy to Auto_beam_engraver too */ - announce_grob (beam_, evs_drul_[START]->self_scm()); + announce_grob (beam_, start_ev_->self_scm()); } } @@ -184,8 +174,7 @@ Beam_engraver::typeset_beam () void Beam_engraver::start_translation_timestep () { - evs_drul_ [START] =0; - evs_drul_[STOP] = 0; + start_ev_ = 0; if (beam_) { @@ -209,7 +198,7 @@ Beam_engraver::stop_translation_timestep () beam_ = 0; beam_info_ = 0; typeset_beam(); - set_melisma (false); + set_melisma (false); } } diff --git a/lily/beam-performer.cc b/lily/beam-performer.cc new file mode 100644 index 0000000000..24662aa4e6 --- /dev/null +++ b/lily/beam-performer.cc @@ -0,0 +1,105 @@ +/* + beam-performer.cc -- implement Beam_performer + + source file of the GNU LilyPond music typesetter + + (c) 1996--2004 Jan Nieuwenhuizen + */ + +#include "performer.hh" +#include "event.hh" +#include "audio-item.hh" +#include "audio-column.hh" +#include "global-translator.hh" +#include "warn.hh" + +/** +Convert evs to audio beams. +*/ +class Beam_performer : public Performer { +public: + TRANSLATOR_DECLARATIONS(Beam_performer); + +protected: + virtual bool try_music (Music *ev) ; + virtual void start_translation_timestep (); + virtual void process_music (); + void set_melisma (bool); +private: + Music *start_ev_; + Music *now_stop_ev_; + bool beam_; +}; + +void +Beam_performer::process_music () +{ + if (now_stop_ev_) + { + beam_ = false; + } + + if (start_ev_) + { + if (beam_) + { + start_ev_->origin ()->warning (_ ("already have a beam")); + return; + } + + beam_ = true; + set_melisma (true); + } +} + + +void +Beam_performer::set_melisma (bool ml) +{ + SCM b = get_property ("autoBeaming"); + if (!to_boolean (b)) + daddy_trans_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F); +} + + +void +Beam_performer::start_translation_timestep () +{ + if (beam_) + { + set_melisma (true); + } + + start_ev_ = 0; + now_stop_ev_ = 0; +} + + + +bool +Beam_performer::try_music (Music *m) +{ + if (m->is_mus_type ("beam-event")) + { + Direction d = to_dir (m->get_mus_property ("span-direction")); + + if (d == START) + { + start_ev_ = m; + } + else if (d==STOP) + { + now_stop_ev_ = m; + } + return true; + } + return false; +} + +ENTER_DESCRIPTION(Beam_performer,"","", + "beam-event","","",""); + +Beam_performer::Beam_performer() +{ + beam_ = false; +} diff --git a/lily/dot-column.cc b/lily/dot-column.cc index 0f3d4f98dc..4cb993c719 100644 --- a/lily/dot-column.cc +++ b/lily/dot-column.cc @@ -231,6 +231,26 @@ Dot_column::do_shifts (Grob*me) { Link_array dots = Pointer_group_interface__extract_grobs (me, (Grob*)0, "dots"); + + { /* + Trigger note collision resolution first, since that may kill off + dots when merging. + */ + Grob * c = 0; + for (int i = dots.size (); i-- ; ) + { + Grob * n = dots[i]->get_parent (Y_AXIS); + if (c) + c = n->common_refpoint (c, X_AXIS); + else + c = n; + } + for (int i = dots.size (); i-- ; ) + { + Grob * n = dots[i]->get_parent (Y_AXIS); + n->relative_coordinate (c , X_AXIS); + } + } dots.sort (compare_position); for (int i = dots.size (); i--;) diff --git a/lily/include/performer-group-performer.hh b/lily/include/performer-group-performer.hh index 0bf2ae4e2d..4a52277351 100644 --- a/lily/include/performer-group-performer.hh +++ b/lily/include/performer-group-performer.hh @@ -22,6 +22,7 @@ public: TRANSLATOR_DECLARATIONS(Performer_group_performer); virtual void do_announces (); + virtual void process_music (); virtual void announce_element (Audio_element_info); protected: Array announce_infos_; diff --git a/lily/include/performer.hh b/lily/include/performer.hh index 961769ba4a..de5731a207 100644 --- a/lily/include/performer.hh +++ b/lily/include/performer.hh @@ -31,6 +31,7 @@ protected: virtual void create_audio_elements (); virtual int get_tempo () const; virtual void play_element (Audio_element * elem ); + virtual void process_music (); }; diff --git a/lily/include/translator.hh b/lily/include/translator.hh index 16a77c6bee..7b17db61b9 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -44,9 +44,6 @@ public: Translator_group * daddy_trans_ ; void removal_processing (); - /** - ask daddy for a feature - */ Music_output_def *get_output_def () const; SCM internal_get_property (SCM symbol) const; diff --git a/lily/melisma-engraver.cc b/lily/melisma-engraver.cc index 6fa0653071..7513fb4e22 100644 --- a/lily/melisma-engraver.cc +++ b/lily/melisma-engraver.cc @@ -7,6 +7,9 @@ */ +/* + duplicated in melisma-performer + */ #include "engraver.hh" #include "event.hh" #include "grob.hh" @@ -15,7 +18,7 @@ /** Signal existence of melismas. */ -class Melisma_engraver:public Engraver +class Melisma_engraver : public Engraver { public: TRANSLATOR_DECLARATIONS(Melisma_engraver); diff --git a/lily/melisma-performer.cc b/lily/melisma-performer.cc new file mode 100644 index 0000000000..2ad44badf9 --- /dev/null +++ b/lily/melisma-performer.cc @@ -0,0 +1,49 @@ + +/* + melisma-performer.cc -- implement Melisma_performer + + source file of the GNU LilyPond music typesetter + + (c) 1999--2004 Han-Wen Nienhuys + + */ + +/* + copy of melisma-engraver - see there. + */ +#include "performer.hh" +#include "event.hh" +#include "grob.hh" +#include "translator-group.hh" + +/** + Signal existence of melismas. + */ +class Melisma_performer : public Performer +{ +public: + TRANSLATOR_DECLARATIONS(Melisma_performer); + bool try_music (Music *); +}; + + +bool +Melisma_performer::try_music (Music *) +{ + /* + This can only be melisma-playing-event. + */ + return melisma_busy (this); +} + +Melisma_performer::Melisma_performer() +{ +} + +ENTER_DESCRIPTION(Melisma_performer, +/* descr */ "This performer collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code. ", +/* creats*/ "", +/* accepts */ "melisma-playing-event", +/* acks */ "", +/* reads */ "melismaBusy melismaBusyProperties slurMelismaBusy tieMelismaBusy beamMelismaBusy", +/* write */ ""); diff --git a/lily/performer-group-performer.cc b/lily/performer-group-performer.cc index f6dbca818f..55776074c0 100644 --- a/lily/performer-group-performer.cc +++ b/lily/performer-group-performer.cc @@ -90,4 +90,31 @@ Performer_group_performer::do_announces () } } -Performer_group_performer::Performer_group_performer(){} +Performer_group_performer::Performer_group_performer() +{ +} + +/* + C & P from Engraver. + + Should move into Translator ? + */ +void +Performer_group_performer::process_music () +{ + for (SCM p = get_simple_trans_list (); gh_pair_p (p); p =ly_cdr (p)) + { + Translator * t = unsmob_translator (ly_car (p)); + Performer * eng = dynamic_cast (t); + + if (eng) + eng->process_music (); + } + for (SCM p = trans_group_list_; gh_pair_p (p); p =ly_cdr (p)) + { + Translator * t = unsmob_translator (ly_car (p)); + Performer*eng = dynamic_cast (t); + if (eng) + eng->process_music (); + } +} diff --git a/lily/performer.cc b/lily/performer.cc index 42d365de00..6d618346ea 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -49,3 +49,10 @@ Performer::announce_element (Audio_element_info i) i.origin_trans_= this; get_daddy_perf ()->announce_element (i); } + + +void +Performer::process_music () +{ + +} diff --git a/lily/score-performer.cc b/lily/score-performer.cc index a3b1abf6c6..c8aaaa13d7 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -75,8 +75,7 @@ Score_performer::prepare (Moment m) void Score_performer::one_time_step () { - // fixme: put this back. - // process_music (); + process_music (); do_announces (); stop_translation_timestep (); check_removal (); diff --git a/lily/translator.cc b/lily/translator.cc index f4bcc566ae..d71a73fb98 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -85,7 +85,7 @@ Translator::internal_get_property (SCM sym) const } void -Translator:: stop_translation_timestep () +Translator::stop_translation_timestep () { } diff --git a/ly/performer-init.ly b/ly/performer-init.ly index 9255018689..a356de3602 100644 --- a/ly/performer-init.ly +++ b/ly/performer-init.ly @@ -40,6 +40,8 @@ \type "Performer_group_performer" \name Voice \consists "Note_performer" + \consists "Beam_performer" + \consists "Melisma_performer" } \translator { @@ -84,6 +86,7 @@ \name Score \alias Timing + melismaBusyProperties = #default-melisma-properties instrument = #"bright acoustic" \accepts Staff \accepts DrumStaff diff --git a/make/ly-rules.make b/make/ly-rules.make index 8eef144810..d513ae3dcf 100644 --- a/make/ly-rules.make +++ b/make/ly-rules.make @@ -15,8 +15,6 @@ $(outdir)/%.texi: %.tely $(outdir)/%.texi: $(outdir)/%.tely if [ -f $@ ]; then chmod a+w $@; fi -# debugging: -# set|egrep '(TEX|LILY)' $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND) $(LILYPOND_BOOK_INCLUDES)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) --verbose $(LILYPOND_BOOK_FLAGS) $< # # DON'T REMOVE SOURCE FILES, otherwise the .TEXI ALWAYS OUT OF DATE. @@ -27,7 +25,7 @@ $(outdir)/%.texi: $(outdir)/%.tely # for plain info doco: don't run lily $(outdir)/%.nexi: %.tely if [ -f $@ ]; then chmod a+w $@; fi - time $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) --verbose $(LILYPOND_BOOK_FLAGS) --process='true' $< + $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) --verbose $(LILYPOND_BOOK_FLAGS) --process='true' $< mv $(outdir)/$*.texinfo $@ 2>/dev/null || mv $(outdir)/$*.texi $@ chmod -w $@ -- 2.39.2