From 11cba325e71f6c1bc720ae79d43739130a5f83ae Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Mon, 28 Dec 2009 14:34:33 +0100 Subject: [PATCH] Use different types of events for cueDuring and quoteDuring Typically, \quoteDuring is supposed to duplicate everything in a voice, while \cueDuring is supposed to only quote the notes, but not e.g. phrasing, slurs, accents, markup, etc. So, this commit adds an additional property quotedCueEventTypes in addition to quotedEventTypes, which allows to quote different types for \cueDuring than for \quoteDuring. By default, \quoteDuring now quotes everything (i.e. StreamEvent), while \cueDuring quotes only notes, rest, ties, beams and tuplets. Also document the difference between cue/quoteDuring and how to selected the quoted event types --- Documentation/notation/staff.itely | 57 ++++++++++++++++++++--- input/regression/quote-cue-event-types.ly | 37 +++++++++++++++ lily/quote-iterator.cc | 19 ++++++-- ly/engraver-init.ly | 4 +- scm/define-context-properties.scm | 6 ++- 5 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 input/regression/quote-cue-event-types.ly diff --git a/Documentation/notation/staff.itely b/Documentation/notation/staff.itely index 42220a34e3..02e15b637c 100644 --- a/Documentation/notation/staff.itely +++ b/Documentation/notation/staff.itely @@ -1085,12 +1085,13 @@ The @code{\quoteDuring} command is used to indicate the point where the quotation begins. It is followed by two arguments: the name of the quoted voice, as defined with @code{\addQuote}, and a music expression that indicates the duration of the quote, usually spacer rests or -multi-measure rests. The corresponding music from the quoted voice is -inserted into the music expression: +multi-measure rests. The corresponding music (including all articulations, +dynamics, markup, etc.) from the quoted voice is inserted into the music +expression: @lilypond[verbatim,quote] flute = \relative c'' { - a4 gis g gis + a4 gis g->\f gis^\markup{quoted} } \addQuote "flute" { \flute } @@ -1135,6 +1136,23 @@ It is possible to tag quotations with unique names in order to process them in different ways. For details about this procedure, see @ref{Using tags}. +It is also possible to adjust which objects from the original voice are quoted +by changing the @code{quotedEventTypes} property. By default, its value is +@code{#'(StreamEvent)}, which means that everything is quoted. Setting it +to e.g. @code{#'(note-event rest-event tie-event)} causes lilypond to quote +only notes, rests and ties, but no articulations, markup or dynamics. + +@lilypond[verbatim,quote] +clarinet = \relative c'' { + a4 gis g->\f gis^\markup{quoted} +} +\addQuote "clarinet" { \clarinet } + +\relative c' { + \set Score.quotedEventTypes = #'(note-event rest-event tie-event) + c4 cis \quoteDuring #"clarinet" { s2 } +} +@end lilypond @snippets @@ -1147,6 +1165,7 @@ see @ref{Using tags}. @cindex rest-event @funindex quotedEventTypes +@funindex quotedCueEventTypes @lilypondfile[verbatim,lilyquote,texidoc,doctitle] {quoting-another-voice.ly} @@ -1205,9 +1224,9 @@ notes into a part. The syntax is as follows: \cueDuring #@var{partname} #@var{voice} @var{music} @end example -This command copies the corresponding measures from @var{partname} -into a @code{CueVoice} context. The @code{CueVoice} is created -implicitly, and occurs simultaneously with @var{music}, which +This command copies only the notes and rests from the corresponding measures +from @var{partname} into a @code{CueVoice} context. The @code{CueVoice} is +created implicitly, and occurs simultaneously with @var{music}, which creates a polyphonic situation. The @var{voice} argument determines whether the cue notes should be notated as a first or second voice; @code{UP} corresponds to the first voice, and @@ -1215,7 +1234,7 @@ second voice; @code{UP} corresponds to the first voice, and @lilypond[verbatim,quote] oboe = \relative c'' { - r2 r8 d16 f e g f a + r2 r8 d16(\f f e g f a) g8 g16 g g2. } \addQuote "oboe" { \oboe } @@ -1231,6 +1250,30 @@ In the above example, the @code{Voice} context had to be explicitly declared, or else the entire music expression would belong to the @code{CueVoice} context. +It is possible to adjust which aspects of the music are quoted with +@code{\cueDuring} by setting the @code{quotedCueEventTypes} property. Its +default value is @code{#'(note-event rest-event tie-event beam-event +tuplet-span-event)}, which means that only notes, rest, ties, beams and +tuplets are quoted, but not articulations, dynamic marks, markup etc. + +@lilypond[verbatim,quote] +oboe = \relative c'' { + r2 r8 d16(\f f e g f a) + g8 g16 g g2. +} +\addQuote "oboe" { \oboe } + +\new Voice \relative c'' { + \set Score.quotedCueEventTypes = #'(note-event rest-event tie-event + beam-event tuplet-span-event + dynamic-event slur-event) + \cueDuring #"oboe" #UP { R1 } + g2 c, +} +@end lilypond + + + The name of the cued instrument can be printed by setting the @code{instrumentCueName} property in the @code{CueVoice} context. diff --git a/input/regression/quote-cue-event-types.ly b/input/regression/quote-cue-event-types.ly new file mode 100644 index 0000000000..f7971e33d0 --- /dev/null +++ b/input/regression/quote-cue-event-types.ly @@ -0,0 +1,37 @@ +\header { + + +texidoc = " The @code{cueDuring} and @code{quoteDuring} forms of quotation +will use the variables @code{quotedCueEventTypes} and @code{quotedEventTypes} +to determine which events are quoted. This allows different events to be +quoted for cue notes than for normal quotes. + +@code{quotedEventTypes} is also the fallback for cue notes if +@code{quotedCueEventTypes} is not set." + +} + +\version "2.13.10" + +quoteMe = \relative c' { fis8 r16-. a8.-> \acciaccatura c8 b4(-\ff~ b16 c8. b8) } +\addQuote quoteMe \quoteMe + +<< + \new Staff \with { instrumentName = "Quoted Voice" } { + \quoteMe + } + \new Staff \with { instrumentName = "quoteDuring" } { +% \set Staff.quotedEventTypes = #'(StreamEvent) + \relative c' { c8 \quoteDuring "quoteMe" { s8 s4 s2 } } + } + \new Staff \with { instrumentName = "cueDuring" } { + \relative c' { c8 \cueDuring "quoteMe" #UP { r8 r4 r2 } } + } +>> + +<< + \new Staff \with { instrumentName = "Fallback" } { + \unset Score.quotedCueEventTypes + \relative c' { c8 \cueDuring "quoteMe" #UP { r8 r4 r2 } } + } +>> diff --git a/lily/quote-iterator.cc b/lily/quote-iterator.cc index c61fd84c46..8c45a23227 100644 --- a/lily/quote-iterator.cc +++ b/lily/quote-iterator.cc @@ -45,7 +45,7 @@ public: DECLARE_SCHEME_CALLBACK (constructor, ()); bool quote_ok () const; - bool accept_music_type (Stream_event *) const; + bool accept_music_type (Stream_event *, bool is_cue = true) const; protected: virtual void derived_mark () const; @@ -64,10 +64,17 @@ Quote_iterator::do_quit () } bool -Quote_iterator::accept_music_type (Stream_event *ev) const +Quote_iterator::accept_music_type (Stream_event *ev, bool is_cue) const { - for (SCM accept = get_outlet ()->get_property ("quotedEventTypes"); - scm_is_pair (accept); accept = scm_cdr (accept)) + SCM accept = SCM_EOL; + // Cue notes use the quotedCueEventTypes property, otherwise (and as fallback + // for cue notes if quotedCueEventTypes is not set) use quotedEventTypes + if (is_cue) + accept = get_outlet ()->get_property ("quotedCueEventTypes"); + if (accept == SCM_EOL) + accept = get_outlet ()->get_property ("quotedEventTypes"); + + for (; scm_is_pair (accept); accept = scm_cdr (accept)) { if (ev->internal_in_event_class (scm_car (accept))) return true; @@ -235,6 +242,8 @@ Quote_iterator::process (Moment m) Pitch *me_pitch = unsmob_pitch (get_music ()->get_property ("quoted-transposition")); if (!me_pitch) me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition")); + SCM cid = get_music ()->get_property ("quoted-context-id"); + bool is_cue = scm_is_string (cid) && (ly_scm2string (cid) == "cue"); for (SCM s = scm_cdr (entry); scm_is_pair (s); s = scm_cdr (s)) { @@ -243,7 +252,7 @@ Quote_iterator::process (Moment m) Stream_event *ev = unsmob_stream_event (scm_car (ev_acc)); if (!ev) programming_error ("no music found in quote"); - else if (accept_music_type (ev)) + else if (accept_music_type (ev, is_cue)) { /* create a transposed copy if necessary */ if (quote_pitch || me_pitch) diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index d5411cbe4f..2afe312151 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -655,7 +655,9 @@ automatically when an output definition (a @code{\score} or ;; need this, as stanza numbers are items, and appear only once. stanza-number-interface ) - quotedEventTypes = #'( + % \quoteDuring is supposed to quote everything, cueDuring only the essentials + quotedEventTypes = #'(StreamEvent) + quotedCueEventTypes = #'( note-event rest-event tie-event diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index dac42fd3e2..6c8b01881a 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -588,8 +588,12 @@ detected.") middle@tie{}C in octavation brackets.") + (quotedCueEventTypes ,list? "A list of symbols, representing the +event types that should be duplicated for @code{\\cueDuring} commands.") (quotedEventTypes ,list? "A list of symbols, representing the -event types that should be duplicated for @code{\\quote} commands.") +event types that should be duplicated for @code{\\quoteDuring} commands. +This is also a fallback for @code{\\cueDuring} if @code{quotedCueEventTypes} +is not set") ; (quotes ,hash-table? "A hash table, mapping names to ;@code{music-event} vectors.") -- 2.39.2