From: Han-Wen Nienhuys Date: Sun, 7 Nov 2004 22:16:09 +0000 (+0000) Subject: * lily/new-quote-iterator.cc (quote_ok): new function. X-Git-Tag: release/2.5.14~604 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=728e41a1741382885396935663e35f9dceaf1d49;p=lilypond.git * lily/new-quote-iterator.cc (quote_ok): new function. * input/regression/quote-cue-during.ly: new file. * input/regression/quote-grace.ly: new file. * lily/grace-engraver.cc: new file. Set properties for grobs based on the grace-ness of now_moment(). * lily/new-quote-iterator.cc (construct_children): set quote_outlet_ if no quoted-context-{id,type} specified. --- diff --git a/ChangeLog b/ChangeLog index c534fec62c..b370fd91af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2004-11-07 Han-Wen Nienhuys + * lily/new-quote-iterator.cc (quote_ok): new function. + + * input/regression/quote-cue-during.ly: new file. + + * input/regression/quote-grace.ly: new file. + * scm/define-context-properties.scm (Module): change definition of graceSettings diff --git a/input/regression/quote-cue-during.ly b/input/regression/quote-cue-during.ly new file mode 100644 index 0000000000..16821ab8de --- /dev/null +++ b/input/regression/quote-cue-during.ly @@ -0,0 +1,40 @@ +\header { texidoc = " The @code{cueDuring} form of quotation will set +stem directions on both quoted and main voice, and deliver the quoted +voice in the @code{cue} @code{Voice}." + +} +\version "2.4.0" +\layout { + raggedright = ##t +} + + +quoteMe = \relative c' { fis4 r16 a8.-> b4-\ff } + +\addquote quoteMe \quoteMe +original = \relative c'' { c8 d s2 es8 gis8 } + +<< + \new Staff { + \set Staff.instrument = "quoteMe" + \quoteMe + } + \new Staff { + \set Staff.instrument = "orig" + \original + } + \new Staff \relative c'' << + + % setup cue note layout. + \context Voice = cue { + \set fontSize = #-4 + \override Stem #'lengths = #'(2.5 2.5 3.0 3.0) + \skip 1 + } + + \set Staff.instrument = "orig+quote" + \set Staff.quotedEventTypes = #'(note-event articulation-event) + \original + { s4 \cueDuring #"quoteMe" #1 { r2. } } + >> +>> diff --git a/input/regression/quote-during.ly b/input/regression/quote-during.ly index 9f9c376e91..7d51fccc90 100644 --- a/input/regression/quote-during.ly +++ b/input/regression/quote-during.ly @@ -1,10 +1,11 @@ \header { - texidoc = "With @code{\\quoteDuring}, fragments of previously -entered music may be quoted. @code{quotedEventTypes} will determines -what things are quoted. In this example, a 16th rests is not quoted, -since @code{rest-event} is not in @code{quotedEventTypes}." + texidoc = "With @code{\\cueDuring} and @code{\\quoteDuring}, +fragments of previously entered music may be +quoted. @code{quotedEventTypes} will determines what things are +quoted. In this example, a 16th rests is not quoted, since +@code{rest-event} is not in @code{quotedEventTypes}." } \version "2.4.0" @@ -28,17 +29,10 @@ original = \relative c'' { c8 d s2 es8 gis8 } \original } \new Staff \relative c'' << - - % setup cue note layout. - \context Voice = cue { - \set fontSize = #-4 - \override Stem #'lengths = #'(2.5 2.5 3.0 3.0) - \skip 1 - } \set Staff.instrument = "orig+quote" \set Staff.quotedEventTypes = #'(note-event articulation-event) \original - { s4 \quoteDuring #"quoteMe" #1 { r2. } } + { s4 \quoteDuring #"quoteMe" { s2. } } >> >> diff --git a/input/regression/quote-grace.ly b/input/regression/quote-grace.ly new file mode 100644 index 0000000000..074ecb7295 --- /dev/null +++ b/input/regression/quote-grace.ly @@ -0,0 +1,30 @@ + +\header { + + texidoc = "Quotes may contain grace notes. The grace note leading up + to an unquoted note is not quoted." + +} +\paper { raggedright= ##t } + +\version "2.4.0" +quoted = \relative c'' { + R1 + \grace g16 f4 \grace a16 bes4 \grace b16 c4 c4 +} + +\addquote quoted \quoted + + +<< + \new Staff { + \set Staff.instrument = "quoted" + \quoted + } + \new Staff \new Voice \relative c'' { + \set Staff.instrument = "quoted" + R1 + \cueDuring #"quoted" #1 { \grace s16. r2 } + c2^"original" + } +>> diff --git a/lily/grace-engraver.cc b/lily/grace-engraver.cc new file mode 100644 index 0000000000..352fc840fd --- /dev/null +++ b/lily/grace-engraver.cc @@ -0,0 +1,102 @@ +/* + grace-engraver.cc -- implement Grace_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2004 Han-Wen Nienhuys + +*/ + +#include "engraver.hh" +#include "context.hh" +#include "warn.hh" + +class Grace_engraver : public Engraver +{ +protected: + virtual void start_translation_timestep (); + virtual void derived_mark (); + + TRANSLATOR_DECLARATIONS (Grace_engraver); + Moment last_moment_; + SCM grace_settings_; +public: +}; + + +Grace_engraver::Grace_engraver() +{ + grace_settings_ = SCM_EOL; +} + +void +Grace_engraver::derived_mark () +{ + scm_gc_mark (grace_settings_); +} + +void +Grace_engraver::start_translation_timestep () +{ + Moment now = now_mom (); + if (last_moment_.grace_part_ && !now.grace_part_) + { + for (SCM s = grace_settings_; scm_is_pair (s); s = scm_cdr (s)) + { + SCM context = scm_caar (s); + SCM entry = scm_cdar (s); + SCM grob = scm_cadr (entry); + SCM sym = scm_caddr (entry); + + execute_pushpop_property (unsmob_context (context), + grob, sym, SCM_UNDEFINED); + } + + grace_settings_ = SCM_EOL; + } + else if (!last_moment_.grace_part_ && now.grace_part_) + { + SCM settings = get_property ("graceSettings"); + + grace_settings_ = SCM_EOL; + for (SCM s = settings; scm_is_pair (s); s = scm_cdr (s)) + { + SCM entry = scm_car (s); + SCM context_name = scm_car (entry); + SCM grob = scm_cadr (entry); + SCM sym = scm_caddr (entry); + SCM val = scm_cadddr (entry); + + Context *c = context (); + while (c + && c->context_name_symbol () != context_name) + { + c = c->get_parent_context (); + } + + if (c) + { + execute_pushpop_property (c, + grob, sym, val); + grace_settings_ + = scm_cons (scm_cons (c->self_scm(), entry), grace_settings_); + } + else + { + programming_error ("Cannot find context"); + scm_display (context_name, scm_current_error_port()); + } + } + } + + last_moment_ = now; +} + + +ENTER_DESCRIPTION (Grace_engraver, + /* descr */ "Set font size and other properties for grace notes.", + /* creats*/ "", + /* accepts */ "", + /* acks */ "", + /* reads */ "graceSettings", + /* write */ ""); diff --git a/lily/grace-music.cc b/lily/grace-music.cc index e34d1ff279..895764682b 100644 --- a/lily/grace-music.cc +++ b/lily/grace-music.cc @@ -1,11 +1,11 @@ /* - grace-music.cc -- implement Grace_music + grace-music.cc -- implement Grace_music - source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter - (c) 1999--2004 Han-Wen Nienhuys + (c) 1999--2004 Han-Wen Nienhuys - */ +*/ #include "grace-music.hh" #include "grace-iterator.hh" @@ -29,7 +29,7 @@ Grace_music::start_mom () const Grace_music::Grace_music () { set_property ("iterator-ctor", - Grace_iterator::constructor_proc); + Grace_iterator::constructor_proc); } ADD_MUSIC (Grace_music); diff --git a/lily/new-quote-iterator.cc b/lily/new-quote-iterator.cc index e1bdf20805..de4cc8954b 100644 --- a/lily/new-quote-iterator.cc +++ b/lily/new-quote-iterator.cc @@ -25,6 +25,7 @@ public: Interpretation_context_handle quote_outlet_; Moment start_moment_; + Moment stop_moment_; SCM event_vector_; int event_idx_; int end_idx_ ; @@ -32,7 +33,7 @@ public: SCM transposed_musics_; DECLARE_SCHEME_CALLBACK (constructor, ()); - + bool quote_ok () const; bool accept_music_type (Music*) const; protected: virtual void derived_mark () const; @@ -116,21 +117,15 @@ New_quote_iterator::construct_children () quote_outlet_.set_context (get_outlet ()); } - Moment now = get_outlet ()->now_mom (); - Moment stop = now + get_music()->get_length (); - start_moment_ = now; event_vector_ = get_music ()->get_property ("quoted-events"); - - if (ly_c_vector_p (event_vector_)) - { - event_idx_ = binsearch_scm_vector (event_vector_, now.smobbed_copy (), &moment_less); - end_idx_ = binsearch_scm_vector (event_vector_, stop.smobbed_copy (), &moment_less); - } - else - { - get_music ()->origin()->warning (_("No events found for \\quote")); - } + + /* + We have to delay initting event_idx_ , since we have to + take starting grace notes into account. Those may offset + event_idx_. + */ + event_idx_ = -1; } @@ -139,16 +134,41 @@ New_quote_iterator::ok () const { return Music_wrapper_iterator::ok() - && ly_c_vector_p (event_vector_) && (event_idx_ <= end_idx_); + || quote_ok (); +} + +bool +New_quote_iterator::quote_ok () const +{ + return (event_idx_ >= 0 + && ly_c_vector_p (event_vector_) + && event_idx_ <= end_idx_ + + /* + Don't quote the grace notes leading to an unquoted note. + */ + && vector_moment (event_idx_).main_part_ < stop_moment_.main_part_ + ); } Moment New_quote_iterator::pending_moment () const { - return - Music_wrapper_iterator::pending_moment() - now_mom ().smobbed_copy (), + &moment_less); + start_moment_ = get_outlet ()->now_mom () - music_start_mom(); + stop_moment_ = start_moment_ + get_music()->get_length (); + + end_idx_ = binsearch_scm_vector (event_vector_, + stop_moment_.smobbed_copy (), + &moment_less); + } m += start_moment_; while (event_idx_ <= end_idx_) @@ -177,7 +210,7 @@ New_quote_iterator::process (Moment m) event_idx_++; } - if (event_idx_ <= end_idx_) + if (quote_ok ()) { SCM entry = SCM_VECTOR_REF (event_vector_, event_idx_); Pitch * quote_pitch = unsmob_pitch (scm_cdar (entry)); @@ -218,8 +251,9 @@ New_quote_iterator::process (Moment m) mus->origin ()->warning (_f ("In quotation: junking event %s", mus->name ())); } } + + event_idx_ ++; } - event_idx_ ++; } IMPLEMENT_CTOR_CALLBACK (New_quote_iterator); diff --git a/scm/part-combiner.scm b/scm/part-combiner.scm index 7a96393f1b..94872ae657 100644 --- a/scm/part-combiner.scm +++ b/scm/part-combiner.scm @@ -505,7 +505,7 @@ the mark when there are no spanners active." part-combine-listener)) (first-voice-handle (last-pair noticed))) - ; (display (last-pair noticed)) + ;; (display (last-pair noticed)) (if (pair? first-voice-handle) (hash-set! tab name ;; cdr : skip name string diff --git a/scm/safe-lily.scm b/scm/safe-lily.scm index ae751fd02f..31af516b8c 100644 --- a/scm/safe-lily.scm +++ b/scm/safe-lily.scm @@ -183,8 +183,6 @@ sequential-music-to-chord-exceptions set-default-paper-size set-part-combine-listener - set-start-grace-properties - set-stop-grace-properties Accidental_interface::after_line_breaking Accidental_interface::print