]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/quote-iterator.cc
Run `make grand-replace'.
[lilypond.git] / lily / quote-iterator.cc
index 45e0f066a70d1dd8a1cc51e0aa81712a59f86aec..3eaf002c0b9557d1705e777cf8f077fb2e73931f 100644 (file)
@@ -3,14 +3,18 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2004--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
+#include "music-wrapper-iterator.hh"
+
 #include "context.hh"
-#include "event.hh"
-#include "music-sequence.hh"
+#include "dispatcher.hh"
+#include "input.hh"
+#include "international.hh"
 #include "lily-guile.hh"
-#include "music-wrapper-iterator.hh"
+#include "music-sequence.hh"
+#include "music.hh"
 #include "warn.hh"
 
 class Quote_iterator : public Music_wrapper_iterator
@@ -25,12 +29,12 @@ public:
   SCM event_vector_;
   int event_idx_;
   int end_idx_;
-
+  
   SCM transposed_musics_;
 
   DECLARE_SCHEME_CALLBACK (constructor, ());
   bool quote_ok () const;
-  bool accept_music_type (Music *) const;
+  bool accept_music_type (Stream_event *) const;
 
 protected:
   virtual void derived_mark () const;
@@ -49,16 +53,14 @@ Quote_iterator::do_quit ()
 }
 
 bool
-Quote_iterator::accept_music_type (Music *mus) const
+Quote_iterator::accept_music_type (Stream_event *ev) const
 {
-  SCM accept = get_outlet ()->get_property ("quotedEventTypes");
-  for (SCM s = mus->get_property ("types");
-       scm_is_pair (s); s = scm_cdr (s))
+  for (SCM accept = get_outlet ()->get_property ("quotedEventTypes");
+       scm_is_pair (accept); accept = scm_cdr (accept))
     {
-      if (scm_memq (scm_car (s), accept) != SCM_BOOL_F)
+      if (ev->internal_in_event_class (scm_car (accept)))
        return true;
     }
-
   return false;
 }
 
@@ -104,7 +106,7 @@ void
 Quote_iterator::construct_children ()
 {
   Music_wrapper_iterator::construct_children ();
-
+      
   SCM name = get_music ()->get_property ("quoted-context-type");
   SCM id = get_music ()->get_property ("quoted-context-id");
 
@@ -116,9 +118,7 @@ Quote_iterator::construct_children ()
       quote_outlet_.set_context (cue_context);
     }
   else
-    {
-      quote_outlet_.set_context (get_outlet ());
-    }
+    quote_outlet_.set_context (get_outlet ());
 
   event_vector_ = get_music ()->get_property ("quoted-events");
 
@@ -221,17 +221,20 @@ Quote_iterator::process (Moment m)
       /*
        The pitch that sounds like central C
       */
-      Pitch *me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition"));
+      Pitch *me_pitch = unsmob_pitch (get_music ()->get_property ("quoted-transposition"));
+      if (!me_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)
+         Stream_event *ev = unsmob_stream_event (scm_car (ev_acc));
+         if (!ev)
            programming_error ("no music found in quote");
-         else if (accept_music_type (mus))
+         else if (accept_music_type (ev))
            {
+             /* create a transposed copy if necessary */
              if (quote_pitch || me_pitch)
                {
                  Pitch qp, mp;
@@ -241,18 +244,12 @@ Quote_iterator::process (Moment m)
                    mp = *me_pitch;
 
                  Pitch diff = pitch_interval (qp, mp);
-
-                 SCM copy = ly_music_deep_copy (mus->self_scm ());
-                 mus = unsmob_music (copy);
-
-                 transposed_musics_ = scm_cons (copy, transposed_musics_);
-                 mus->transpose (diff);
+                 ev = ev->clone ();
+                 
+                 transpose_mutable (ev->get_property_alist (true), diff);
+                 transposed_musics_ = scm_cons (ev->unprotect (), transposed_musics_);
                }
-
-             bool b = quote_outlet_.get_outlet ()->try_music (mus);
-             if (!b)
-               mus->origin ()->warning (_f ("in quotation: junking event %s",
-                                            mus->name ()));
+             quote_outlet_.get_outlet ()->event_source ()->broadcast (ev);
            }
        }