2004-11-07 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/quote-iterator.cc (Module): remove old quote-iterator
+
+ * scm/define-music-types.scm (music-descriptions): move
+ NewQuoteMusic over QuoteMusic
+
+ * Documentation/user/notation.itely (Formatting cue notes): use
+ \cueDuring.
+
* lily/new-quote-iterator.cc (quote_ok): new function.
* input/regression/quote-cue-during.ly: new file.
blocks.
After calling @code{\addquote}, the quotation may then be done with
-@code{\quote},
+@code{\quoteDuring} or @code{\cueDuring},
@example
-\quote @var{name} @var{duration}
+\quoteDuring #@var{name} @var{music}
@end example
-During a part, a piece of music can be quoted with the @code{\quote}
+During a part, a piece of music can be quoted with the @code{\quoteDuring}
command.
@example
-\quote clarinet 2.
+\quoteDuring #"clarinet" @{ s2. @}
@end example
-This would cite three quarter notes (@code{2.} is a dotted half note)
-of the previously added @code{clarinet} voice.
+This would cite three quarter notes (the duration of @code{s2.}) of
+the previously added @code{clarinet} voice.
+
More precisely, it takes the current time-step of the part being
printed, and extracts the notes at the corresponding point of the
}
{
- e'8 f'8 \quote clarinet 2
+ e'8 f'8 \quoteDuring #"clarinet" { s2 }
}
@end lilypond
The type of events that are present in cue notes can be trimmed with
the @code{quotedEventTypes} property. The default value is
@code{(note-event rest-event)}, which means that only notes of and
-rests of the cued voice end up in the @code{\quote}.
+rests of the cued voice end up in the @code{\quoteDuring}.
Setting
@example
@node Formatting cue notes
@subsection Formatting cue notes
+The previous section deals with inserting notes from another voice.
+There is a more advanced music function called @code{\cueDuring},
+which makes formatting cue notes easier.
+
+The syntax is
+
+@example
+ \cueDuring #@var{name} #@var{updown} @var{music}
+@end example
-The previous section deals with inserting notes from another
-voice. When making a part, these notes need to be specially formatted.
-Here is an example of formatted cue notes
+This will insert notes from the part @var{name} into a
+@internalsref{Voice} called @code{cue}. This happens simultaneously
+with @var{music}, which usually is a rest. When the cue notes start,
+the staff in effect becomes polyphonic for a moment. The argument
+@var{updown} determines whether the cue notes should be notated as a
+first or second voice.
-@c TODO: This should be done with \quote stuff, not manually.
-@lilypond[raggedright,verbatim]
+@lilypond[verbatim,raggedright]
smaller = {
\set fontSize = #-2
\override Stem #'length = #5.5
#(lambda (beam mult) (* 0.8 (Beam::space_function beam mult)))
}
-{
- \set Staff.instrument = #"Horn in F"
+\addquote clarinet \relative {
+ R1*20
+ r2 r8 c f f
+}
+
+\new Staff \relative <<
+
+ % setup a context for cue notes.
+ \context Voice = cue { \smaller \skip 1*21 }
+
\set Score.skipBars = ##t
- R1*21
- << {
- \once \override Staff.MultiMeasureRest #'staff-position = #-6
- R1
- }
+
\new Voice {
- s2
- \clef tenor
- \smaller
- r8^"Bsn." c'8 f'8[ f'8]
- \clef treble
+ R1*20
+ \cueDuring #"clarinet" #1 {
+ R1
+ }
+ g4 g2.
}
- >>
- c'8^"Horn" cis'
- eis'4 fis'4
-}
-@end lilypond
+>>
+@end lilypond
-There are a couple of points to take care of:
+Here are a couple of hints for successful cue notes
@itemize @bullet
@item
-The multi rest of the original part should be moved up or down during
-the cue.
-@item
Cue notes have smaller font sizes.
@item
-When cued notes have a clef change relative to the original part, the
-clef should be restored after the cue section. This minimizes
-confusion for the reader,
+ the cued part is marked with the instrument playing the cue.
@item
-When the original part starts, this should be marked with the name of
-the instrument, in this case ``Horn.'' Of course, the cue part is
-marked with the instrument playing the cue.
+ when the original part takes over again, this should be marked with
+ the name of the original instrument.
+
+ @c really? Are you sure about that last point? I'll check after 3.0 -gp
+
+@c Yes, this is good practice. Otherwise, the start of the original
+@c part can only be seen from the font size. This is not good enough
+@c for sight-reading. It is possilbe to use other
+@c markers (eg. a big close-bracket over the staff) to indicate the cue notes are
+@c finished.
+@c -hwn
+
+
+ any other changes introduced by the cued part should also be
+undone. For example, if the cued instrument plays in a different clef,
+the original clef should be stated once again.
+
@end itemize
-@c really? Are you sure about that last point? I'll check after 3.0 -gp
+
+
@node Ancient notation
@section Ancient notation
+++ /dev/null
-/*
- quote-iterator.cc -- implement Quote_iterator
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
-*/
-
-#include "context.hh"
-#include "event.hh"
-#include "music-sequence.hh"
-#include "lily-guile.hh"
-#include "music-iterator.hh"
-#include "music.hh"
-#include "input.hh"
-#include "warn.hh"
-
-
-class Quote_iterator : public Music_iterator
-{
-public:
- Quote_iterator ();
- Moment vector_moment (int idx) const;
-
- Moment start_moment_;
- SCM event_vector_;
- int event_idx_;
- int end_idx_ ;
-
- SCM transposed_musics_;
-
- DECLARE_SCHEME_CALLBACK (constructor, ());
-
- bool accept_music_type (Music*) const;
-protected:
- virtual void derived_mark () const;
- virtual void construct_children ();
- virtual Moment pending_moment () const;
- virtual void process (Moment);
- virtual bool ok () const;
-};
-
-bool
-Quote_iterator::accept_music_type (Music *mus) const
-{
- SCM accept = get_outlet()->get_property ("quotedEventTypes");
- for (SCM s = mus->get_property ("types");
- scm_is_pair (s); s = scm_cdr (s))
- {
- if (scm_memq (scm_car (s), accept) != SCM_BOOL_F)
- return true;
- }
-
- return false;
-}
-
-
-void
-Quote_iterator::derived_mark () const
-{
- scm_gc_mark (transposed_musics_ );
-}
-
-Quote_iterator::Quote_iterator ()
-{
- transposed_musics_ = SCM_EOL;
- event_vector_ = SCM_EOL;
- event_idx_ = 0;
- end_idx_ = 0;
-}
-
-int
-binsearch_scm_vector (SCM vec, SCM key, bool (*is_less)(SCM a,SCM b));
-
-
-void
-Quote_iterator::construct_children ()
-{
- SCM dur = get_music ()->get_property ("duration");
- if (!unsmob_duration (dur))
- return ;
-
- set_context (get_outlet ()->get_default_interpreter ());
-
- Moment now = get_outlet ()->now_mom ();
- Moment stop = now + unsmob_duration (dur)->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"));
- }
-}
-
-
-bool
-Quote_iterator::ok () const
-{
- return ly_c_vector_p (event_vector_) && (event_idx_ <= end_idx_);
-}
-
-Moment
-Quote_iterator::pending_moment () const
-{
- return vector_moment (event_idx_) - start_moment_;
-}
-
-Moment
-Quote_iterator::vector_moment (int idx) const
-{
- SCM entry = SCM_VECTOR_REF (event_vector_, idx);
- return *unsmob_moment (scm_caar (entry));
-}
-
-
-void
-Quote_iterator::process (Moment m)
-{
- m += start_moment_;
- while (event_idx_ <= end_idx_)
- {
- Moment em = vector_moment (event_idx_);
- if (em > m)
- return ;
-
- if (em == m)
- break ;
-
- event_idx_++;
- }
-
- if (event_idx_ <= end_idx_)
- {
- SCM entry = SCM_VECTOR_REF (event_vector_, event_idx_);
- Pitch * quote_pitch = unsmob_pitch (scm_cdar (entry));
-
- /*
- The pitch that sounds like central C
- */
- Pitch * me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition"));
-
- for (SCM s = scm_cdr (entry); scm_is_pair (s); s = scm_cdr (s))
- {
- SCM ev_acc = scm_car (s);
-
- Music * mus = unsmob_music (scm_car (ev_acc));
- if (!mus)
- programming_error ("need music in quote.");
- else if (accept_music_type (mus))
- {
- if (quote_pitch || me_pitch)
- {
- Pitch qp, mp;
- if (quote_pitch)
- qp = *quote_pitch;
- if (me_pitch)
- mp = *me_pitch;
-
- Pitch diff = pitch_interval (qp, mp);
-
- SCM copy = ly_deep_mus_copy (mus->self_scm ());
- mus = unsmob_music (copy);
- transposed_musics_ = scm_cons (copy, transposed_musics_);
-
-
- mus->transpose (diff);
- }
-
-
- bool b = get_outlet ()->try_music (mus);
-
- if (!b)
- mus->origin ()->warning (_f ("In quotation: junking event %s", mus->name ()));
- }
- }
- }
- event_idx_ ++;
-}
-
-IMPLEMENT_CTOR_CALLBACK (Quote_iterator);
))
(QuoteMusic
- . (
- (description . "Quote preprocessed snippets of music. ")
- (internal-class-name . "Event") ;; so we get Event::get_length ().
- (iterator-ctor . ,Quote_iterator::constructor)
- (types . (general-music))
- ))
- (NewQuoteMusic
. (
(description . "Quote preprocessed snippets of music. ")
(internal-class-name . "Music_wrapper") ;; so we get Event::get_length ().