- Pitch * quote_pitch = unsmob_pitch (gh_cdar (entry));
- Pitch * me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition"));
-
- for (SCM s = gh_cdr (entry); gh_pair_p (s); s = gh_cdr (s))
- {
- SCM ev_acc = gh_car (s);
-
-
- Music * mus = unsmob_music (gh_car (ev_acc));
- if (mus)
- {
- if (quote_pitch || me_pitch)
- {
- Pitch qp, mp;
- if (quote_pitch)
- qp = *quote_pitch;
- if (me_pitch)
- mp = *me_pitch;
-
- Pitch diff = interval (mp, qp);
-
- SCM copy = ly_deep_mus_copy (mus->self_scm ());
- mus = unsmob_music (copy);
- transposed_musics_ = gh_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()));
- }
- else
- programming_error ("need music in quote.");
- }
+ SCM entry = scm_c_vector_ref (event_vector_, event_idx_);
+ Pitch *quote_pitch = Pitch::unsmob (scm_cdar (entry));
+
+ /*
+ The pitch that sounds when written central C is played.
+ */
+ Pitch temp_pitch;
+ Pitch *me_pitch = Pitch::unsmob (get_music ()->get_property ("quoted-transposition"));
+ if (!me_pitch)
+ me_pitch = Pitch::unsmob (get_outlet ()->get_property ("instrumentTransposition"));
+ else
+ {
+ // We are not going to win a beauty contest with this one,
+ // but it is slated for replacement and touches little code.
+ // quoted-transposition currently has a different sign
+ // convention than instrumentTransposition
+ temp_pitch = me_pitch->negated ();
+ me_pitch = &temp_pitch;
+ }
+ 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))
+ {
+ SCM ev_acc = scm_car (s);
+
+ Stream_event *ev = Stream_event::unsmob (scm_car (ev_acc));
+ if (!ev)
+ programming_error ("no music found in quote");
+ else if (accept_music_type (ev, is_cue))
+ {
+ /* create a transposed copy if necessary */
+ if (quote_pitch || me_pitch)
+ {
+ Pitch qp, mp;
+ if (quote_pitch)
+ qp = *quote_pitch;
+ if (me_pitch)
+ mp = *me_pitch;
+
+ Pitch diff = pitch_interval (mp, qp);
+ ev = ev->clone ();
+ ev->make_transposable ();
+
+ transpose_mutable (ev->get_property_alist (true), diff);
+ transposed_musics_ = scm_cons (ev->unprotect (), transposed_musics_);
+ }
+ quote_outlet_.get_context ()->event_source ()->broadcast (ev);
+ }
+ }
+
+ event_idx_++;