From e4c229e52b6e102676b1bcae5aff89bf21401225 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Fri, 6 Feb 2004 23:49:41 +0000 Subject: [PATCH] * input/no-notation/midi-lyric-barcheck.ly: new file. * input/regression/collision-dots-invert.ly: new file. * lily/note-collision.cc (check_meshing_chords): add stem_to_stem case. * lily/new-lyric-combine-music-iterator.cc (process): let iterator die if melody died too. --- ChangeLog | 19 ++++- Documentation/user/refman.itely | 3 - input/no-notation/midi-lyric-barcheck.ly | 20 +++++ input/regression/collision-dots-invert.ly | 14 ++++ lily/beam-performer.cc | 12 --- lily/lyric-extender.cc | 5 +- lily/new-lyric-combine-music-iterator.cc | 9 ++- lily/note-collision.cc | 18 +++-- lily/slur-performer.cc | 95 +++++++++++++++++++++++ lily/source-file.cc | 1 + lily/stem.cc | 3 + scm/music-functions.scm | 4 +- 12 files changed, 174 insertions(+), 29 deletions(-) create mode 100644 input/no-notation/midi-lyric-barcheck.ly create mode 100644 input/regression/collision-dots-invert.ly create mode 100644 lily/slur-performer.cc diff --git a/ChangeLog b/ChangeLog index fe7ae09503..730b35772a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,21 @@ +2004-02-07 Han-Wen Nienhuys + + * input/no-notation/midi-lyric-barcheck.ly: new file. + + * input/regression/collision-dots-invert.ly: new file. + + * lily/note-collision.cc (check_meshing_chords): add stem_to_stem + case. + + * lily/new-lyric-combine-music-iterator.cc (process): let iterator + die if melody died too. + 2004-02-06 Han-Wen Nienhuys - * Documentation/user/refman.itely (More stanzas): document slur - deficiency. + * lily/source-file.cc (load_stdin): add trailing 0. Fixes problem + with reading from stdin. + + * lily/slur-performer.cc (try_music): new file. * lily/melisma-performer.cc (try_music): new file. Handle melismata to help lyrics. @@ -11,7 +25,6 @@ * lily/score-performer.cc (one_time_step): reinstate process_music(). - * lily/performer.cc (process_music): add to interface. diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 2d5b100334..467b40f3af 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -3540,9 +3540,6 @@ 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 @subsection Ambitus diff --git a/input/no-notation/midi-lyric-barcheck.ly b/input/no-notation/midi-lyric-barcheck.ly new file mode 100644 index 0000000000..8bfa01d234 --- /dev/null +++ b/input/no-notation/midi-lyric-barcheck.ly @@ -0,0 +1,20 @@ +\header { + + texidoc = "Lyrics in MIDI are aligned to ties and beams: +this examples causes no bar checks in MIDI. +TODO: slurs. +" + + + } +\score { + + <<\notes\relative c'' \context Voice = A { + \autoBeamOff + c8[ c] c2. + c1~c4 c2. c1 } + \lyricsto "A" \lyrics\new LyricsVoice { bla bla | bla bla | bla } + >> + \paper {} + \midi {} + } diff --git a/input/regression/collision-dots-invert.ly b/input/regression/collision-dots-invert.ly new file mode 100644 index 0000000000..e7842f4b81 --- /dev/null +++ b/input/regression/collision-dots-invert.ly @@ -0,0 +1,14 @@ +\header { + + texidoc = "When notes are colliding, the resolution depends on the + dots: notes with dots should go to the right, if there could be + confusion to which notes the dots belong." +} +\version "2.1.19" +\score { + \notes \relative c'' { + << 2\\ { 4 4 } >> + << { 2 } \\ { 4. 8 } >> + } + \paper { raggedright = ##t } +} diff --git a/lily/beam-performer.cc b/lily/beam-performer.cc index 24662aa4e6..4010502032 100644 --- a/lily/beam-performer.cc +++ b/lily/beam-performer.cc @@ -13,9 +13,6 @@ #include "global-translator.hh" #include "warn.hh" -/** -Convert evs to audio beams. -*/ class Beam_performer : public Performer { public: TRANSLATOR_DECLARATIONS(Beam_performer); @@ -41,12 +38,6 @@ Beam_performer::process_music () if (start_ev_) { - if (beam_) - { - start_ev_->origin ()->warning (_ ("already have a beam")); - return; - } - beam_ = true; set_melisma (true); } @@ -61,7 +52,6 @@ Beam_performer::set_melisma (bool ml) daddy_trans_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F); } - void Beam_performer::start_translation_timestep () { @@ -73,8 +63,6 @@ Beam_performer::start_translation_timestep () start_ev_ = 0; now_stop_ev_ = 0; } - - bool Beam_performer::try_music (Music *m) diff --git a/lily/lyric-extender.cc b/lily/lyric-extender.cc index 1fdce62b9a..c2f33dbc36 100644 --- a/lily/lyric-extender.cc +++ b/lily/lyric-extender.cc @@ -18,7 +18,6 @@ #include "note-head.hh" #include "group-interface.hh" - bool Lyric_extender::is_visible (Grob *gr) { @@ -82,8 +81,10 @@ Lyric_extender::brew_molecule (SCM smob) Real h = sl * robust_scm2double (me->get_grob_property ("thickness"), 0); Real pad = 2* h; - if (!r->break_status_dir ()) + if (r->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface"))) right_point = right_point extent (common, X_AXIS)[LEFT] - pad); + else if (Note_head::has_interface (r)) + ; else if (!last_line) { /* diff --git a/lily/new-lyric-combine-music-iterator.cc b/lily/new-lyric-combine-music-iterator.cc index 1bf41b8710..b54c02da8d 100644 --- a/lily/new-lyric-combine-music-iterator.cc +++ b/lily/new-lyric-combine-music-iterator.cc @@ -195,7 +195,7 @@ New_lyric_combine_music_iterator::find_voice () String name = ly_scm2string (voice_name); Translator_group *voice = find_context_below (t, "Voice", name); if (!voice) - get_music ()->origin ()->warning (_f ("Cannot find Voice: %s\n", + get_music ()->origin ()->warning (_f ("cannot find Voice: %s\n", name.to_str0 ())); else music_context_ = voice; @@ -223,9 +223,14 @@ New_lyric_combine_music_iterator::process (Moment ) if (!music_context_->daddy_trans_) { - music_context_ = 0; + /* + The melody has died. + We die too. + */ if (lyrics_context_) lyrics_context_->unset_property (ly_symbol2scm ("associatedVoiceContext")); + lyric_iter_ = 0; + music_context_ = 0; } if (music_context_ diff --git a/lily/note-collision.cc b/lily/note-collision.cc index d664121daa..9683378af8 100644 --- a/lily/note-collision.cc +++ b/lily/note-collision.cc @@ -160,6 +160,9 @@ check_meshing_chords (Grob *me, } } + full_collide = full_collide || (close_half_collide + && distant_half_collide); + Drul_array center_note_shifts; center_note_shifts[LEFT] = 0.0; center_note_shifts[RIGHT] = 0.0; @@ -167,16 +170,19 @@ check_meshing_chords (Grob *me, Real shift_amount = 1; - bool touch = (ups[0] - dps.top () >= 0); + bool touch = (ups[0] >= dps.top ()); if (touch) shift_amount *= -1; /* For full collisions, the right hand head may obscure dots, so make sure the dotted heads go to the right. */ - if (Rhythmic_head::dot_count (nu) > Rhythmic_head::dot_count (nd) - && full_collide) - shift_amount = 1; - + bool stem_to_stem = false; + if (full_collide) + if (Rhythmic_head::dot_count (nu) > Rhythmic_head::dot_count (nd)) + shift_amount = 1; + else if (Rhythmic_head::dot_count (nu) < Rhythmic_head::dot_count (nd)) + stem_to_stem = true; + if (merge_possible) { shift_amount = 0; @@ -206,6 +212,8 @@ check_meshing_chords (Grob *me, } /* TODO: these numbers are magic; should devise a set of grob props to tune this behavior. */ + else if (stem_to_stem) + shift_amount *= -0.65; else if (close_half_collide && !touch) shift_amount *= 0.52; else if (distant_half_collide && !touch) diff --git a/lily/slur-performer.cc b/lily/slur-performer.cc new file mode 100644 index 0000000000..ac086bee88 --- /dev/null +++ b/lily/slur-performer.cc @@ -0,0 +1,95 @@ +/* + slur-performer.cc -- implement Slur_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" + +/* + this is C&P from beam_performer. + */ + +class Slur_performer : public Performer { +public: + TRANSLATOR_DECLARATIONS(Slur_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 slur_; +}; + +void +Slur_performer::process_music () +{ + if (now_stop_ev_) + { + slur_ = false; + } + + if (start_ev_) + { + slur_ = true; + set_melisma (true); + } +} + + +void +Slur_performer::set_melisma (bool ml) +{ + daddy_trans_->set_property ("slurMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F); +} + +void +Slur_performer::start_translation_timestep () +{ + if (slur_) + { + set_melisma (true); + } + + start_ev_ = 0; + now_stop_ev_ = 0; +} + +bool +Slur_performer::try_music (Music *m) +{ + if (m->is_mus_type ("slur-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(Slur_performer,"","", + "slur-event","","",""); + +Slur_performer::Slur_performer() +{ + slur_ = false; +} diff --git a/lily/source-file.cc b/lily/source-file.cc index 8c36ef47cc..0ef67667b5 100644 --- a/lily/source-file.cc +++ b/lily/source-file.cc @@ -34,6 +34,7 @@ Source_file::load_stdin () while ((c = fgetc (stdin)) != EOF) chs.push (c); + chs.push (0); length_ = chs.size (); contents_str0_ = chs.remove_array (); } diff --git a/lily/stem.cc b/lily/stem.cc index 49c907879e..6a2656ed2a 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -215,6 +215,9 @@ icmp (int const &a, int const &b) return a-b; } +/* + The positions, in ascending order. + */ Array Stem::note_head_positions (Grob *me) { diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 91c6bbaaaf..f343098560 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -518,7 +518,7 @@ Rest can contain a list of beat groupings (make-simultaneous-music (car lst)))) 'Voice (number->string number)) - (voicify-list (cdr lst) (+ number 1)) + (voicify-list (cdr lst) (1+ number)) )) ) @@ -549,7 +549,7 @@ Rest can contain a list of beat groupings (if (and (equal? (ly:music-name m) "Simultaneous_music") (reduce (lambda (x y ) (or x y)) #f (map music-separator? es))) - (voicify-chord m) + (set! m (context-spec-music (voicify-chord m) 'Staff)) ) m -- 2.39.2