]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/music.cc
* lily/include/music.hh (class Music): unvirtualize transpose().
[lilypond.git] / lily / music.cc
index 5889b8e46e305e53868a39a60a61036ddb9a7fd3..958eedc221bcb1092a3161709c5678b8c12fdf30 100644 (file)
@@ -39,12 +39,15 @@ Music::name () const
     }
 }
 
-Music::Music ()
+Music::Music (SCM init)
 {
   self_scm_ = SCM_EOL;
-  immutable_property_alist_ = SCM_EOL;
+  immutable_property_alist_ = init;
   mutable_property_alist_ = SCM_EOL;
   smobify_self ();
+
+  length_callback_ = get_property ("length-callback");
+  start_callback_ = get_property ("start-callback");
 }
 
 Music::Music (Music const &m)
@@ -58,6 +61,8 @@ Music::Music (Music const &m)
      that they won't be protected from GC. */
   smobify_self ();
   mutable_property_alist_ = ly_music_deep_copy (m.mutable_property_alist_);
+  length_callback_ = m.length_callback_;
+  start_callback_ = m.start_callback_;
   set_spot (*m.origin ());
 }
 
@@ -88,19 +93,20 @@ Music::get_length () const
   SCM lst = get_property ("length");
   if (unsmob_moment (lst))
     return *unsmob_moment (lst);
-  else if (ly_c_procedure_p (lst))
+
+  if (ly_c_procedure_p (length_callback_))
     {
-      SCM res = scm_call_1 (lst, self_scm ());
+      SCM res = scm_call_1 (length_callback_, self_scm ());
       return *unsmob_moment (res);
     }
 
-  return 0;
+  return Moment(0);
 }
 
 Moment
 Music::start_mom () const
 {
-  SCM lst = get_property ("start-moment-function");
+  SCM lst = get_property ("start-callback");
   if (ly_c_procedure_p (lst))
     {
       SCM res = scm_call_1 (lst, self_scm ());
@@ -165,11 +171,17 @@ Music::compress (Moment factor)
     m->compress (factor);
 
   compress_music_list (get_property ("elements"), factor);
+  Duration *d =  unsmob_duration (get_property ("duration"));
+  if (d)
+    set_property ("duration", d ->compressed (factor.main_part_).smobbed_copy ());
 }
 
 void
 Music::transpose (Pitch delta)
 {
+  if (to_boolean (get_property ("untransposable")))
+    return ;
+  
   for (SCM s = this->get_property_alist (true); scm_is_pair (s); s = scm_cdr (s))
     {
       SCM entry = scm_car (s);
@@ -182,7 +194,7 @@ Music::transpose (Pitch delta)
 
          if (abs (transposed.get_alteration ()) > DOUBLE_SHARP)
            {
-             warning (_f ("Transposition by %s makes alteration larger than two",
+             warning (_f ("Transposition by %s makes alteration larger than double",
                           delta.to_string ()));
            }
        }
@@ -214,7 +226,7 @@ Music::internal_get_property (SCM sym) const
 void
 Music::internal_set_property (SCM s, SCM v)
 {
-  if (internal_type_checking_global_b)
+  if (do_internal_type_checking_global)
     if (!type_check_assignment (s, v, ly_symbol2scm ("music-type?")))
       abort ();