]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/quote-iterator.cc
Configure only pristine build tree or on user
[lilypond.git] / lily / quote-iterator.cc
index 8439e5698fe865ce8646a0596cabeff5dcff173e..8e0affdf282c19bb2a6457f77c1656f43e0865b7 100644 (file)
@@ -27,15 +27,24 @@ public:
   int event_idx_;
   int end_idx_ ;
 
-  DECLARE_SCHEME_CALLBACK(constructor, ()); 
+  SCM transposed_musics_;
+  
+  DECLARE_SCHEME_CALLBACK (constructor, ()); 
 
 protected:
+  virtual void derived_mark ();
   virtual void construct_children ();
   virtual Moment pending_moment () const;
   virtual void process (Moment);
   virtual bool ok () const;
 };
 
+void
+Quote_iterator::derived_mark ()
+{
+  scm_gc_mark (transposed_musics_ );
+}
+
 Quote_iterator::Quote_iterator ()
 {
   event_vector_ = SCM_EOL;
@@ -63,7 +72,7 @@ binsearch_scm_vector (SCM vec, SCM key, bool (*is_less)(SCM a,SCM b))
   {
     int cmp = (lo + hi) / 2;
 
-      SCM when = gh_car (SCM_VECTOR_REF(vec, cmp));
+      SCM when = ly_caar (SCM_VECTOR_REF (vec, cmp));
       bool result =  (*is_less) (key, when);
       if (result)
           hi = cmp;
@@ -79,7 +88,7 @@ binsearch_scm_vector (SCM vec, SCM key, bool (*is_less)(SCM a,SCM b))
 void
 Quote_iterator::construct_children ()
 {
-  SCM dur = get_music ()->get_mus_property ("duration");
+  SCM dur = get_music ()->get_property ("duration");
   if (!unsmob_duration (dur))
     return ;
 
@@ -89,9 +98,9 @@ Quote_iterator::construct_children ()
   Moment stop = now + unsmob_duration (dur)->get_length ();
 
   start_moment_ = now;
-  event_vector_ = get_music ()->get_mus_property ("quoted-events");
+  event_vector_ = get_music ()->get_property ("quoted-events");
 
-  if (scm_vector_p (event_vector_) == SCM_BOOL_T)
+  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);
@@ -110,7 +119,7 @@ Moment
 Quote_iterator::pending_moment () const
 {
   SCM entry = SCM_VECTOR_REF (event_vector_, event_idx_);
-  return *unsmob_moment (gh_car (entry)) - start_moment_;
+  return *unsmob_moment (ly_caar (entry)) - start_moment_;
 }
 
 
@@ -124,7 +133,7 @@ Quote_iterator::process (Moment m)
     {
       entry = SCM_VECTOR_REF (event_vector_, event_idx_);
 
-      Moment em = *unsmob_moment (gh_car (entry));
+      Moment em = *unsmob_moment (ly_caar (entry));
 
       if (em > m)
        return ;
@@ -135,20 +144,41 @@ Quote_iterator::process (Moment m)
       event_idx_++;
     }
 
-  if (gh_pair_p (entry))
+  if (ly_c_pair_p (entry))
     {
-      for (SCM s = gh_cdr (entry); gh_pair_p (s); s = gh_cdr (s))
+      Pitch * quote_pitch = unsmob_pitch (ly_cdar (entry));
+      Pitch * me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition"));
+      
+      for (SCM s = ly_cdr (entry); ly_c_pair_p (s); s = ly_cdr (s))
        {
-         SCM ev_acc = gh_car (s);
+         SCM ev_acc = ly_car (s);
 
 
-         Music * mus = unsmob_music (gh_car (ev_acc));
+         Music * mus = unsmob_music (ly_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_ = 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()));
+               mus->origin ()->warning (_f ("In quotation: junking event %s", mus->name ()));
            }
          else
            programming_error ("need music in quote.");