]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/music-functions.scm (unfold-repeats): undo music compression
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 31 Mar 2004 11:47:49 +0000 (11:47 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 31 Mar 2004 11:47:49 +0000 (11:47 +0000)
too.

* lily/music.cc (LY_DEFINE): rename to music-mutable-properties
(LY_DEFINE): ly:music-compress new function.

* scm/music-functions.scm (make-non-relative-music): new function.

ChangeLog
input/regression/repeat-unfold-all.ly
lily/music.cc
lily/parser.yy
scm/music-functions.scm
scripts/convert-ly.py

index 09041daa4cf3c1f12a723fe88a99c877c3114fc4..9889cded71a75dc2254bc3e59609e59703b73800 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2004-03-31  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * scm/music-functions.scm (unfold-repeats): undo music compression
+       too.
+
+       * lily/music.cc (LY_DEFINE): rename to music-mutable-properties
+       (LY_DEFINE): ly:music-compress new function.
+
        * scm/part-combiner.scm (determine-split-list): split for voice
        crossings
 
index 40c7b1c5397a47d28c0c21cffa1295326d9cea2b..e184c24ddb9568d83a72b865507a352451bf2431 100644 (file)
@@ -1,18 +1,20 @@
 \version "2.1.30"
 
-\header {
-    texidoc = "Repeats may be unfolded through the Scheme function @code{unfold-repeats}."
+\header { texidoc = "Volta repeats may be unfolded through the Scheme
+    function @code{unfold-repeats}."
+
 }
 
 nots = \notes\relative c'   {
     c4 \repeat volta 2 c4 \alternative { d e  }
-    \repeat tremolo 4 { c16 d }
 }
 
-\score { \notes \context Voice {
-\nots
-\apply #unfold-repeats \nots
+\score {
+    \notes \context Voice {
+       \nots
+       \bar "||"
+       \apply #unfold-repeats \nots
+    }
+    \paper {raggedright = ##t} 
 }
-\paper {raggedright = ##t} 
-     }
 
index df19f5cb36f4140cdceb9c9897219c00353f464b..a8cc060e9441b72d2511c36cbcd08592885ef54a 100644 (file)
@@ -283,7 +283,7 @@ LY_DEFINE (ly_extended_make_music, "ly:make-bare-music",
 }
 
 /* todo: property args */
-LY_DEFINE (ly_mutable_music_properties, "ly:mutable-music-properties",
+LY_DEFINE (ly_music_mutable_properties, "ly:music-mutable-properties",
          1, 0, 0, (SCM mus),
          "Return an alist containing the mutable properties of @var{mus}.\n"
          "The immutable properties are not available, since "
@@ -342,12 +342,27 @@ LY_DEFINE (ly_music_transpose, "ly:music-transpose",
   return sc->self_scm ();
 }
 
+/*
+  TODO: should take moment factor?
+ */
+LY_DEFINE (ly_music_compress, "ly:music-compress",
+         3, 0, 0, (SCM m, SCM factor),
+         "Compress music object @var{m} by moment @var{factor}."
+          )
+{
+  Music * sc = unsmob_music (m);
+
+  SCM_ASSERT_TYPE (sc, m, SCM_ARG1, __FUNCTION__, "music");
+  SCM_ASSERT_TYPE (unsmob_moment (factor), factor, SCM_ARG2, __FUNCTION__, "moment");
+  
+  sc->compress (*unsmob_moment (factor));
+  return sc->self_scm ();
+}
 
 Music*
 make_music_by_name (SCM sym)
 {
   SCM make_music_proc = ly_scheme_function ("make-music");
-       
   SCM rv = scm_call_1 (make_music_proc, sym);
 
   /* UGH. */
index f5eed1ba3b688e33257667b7343d480baa1ad3d5..549093937e7a9aef75450eed042c56cbaa2816d3 100644 (file)
@@ -140,7 +140,7 @@ is_regular_identifier (SCM id)
 SCM
 make_simple_markup (SCM a)
 {
SCM simple = scm_c_eval_string ("simple-markup");
      SCM simple = ly_scheme_function ("simple-markup");
 
        return scm_list_2 (simple, a);
 }
@@ -796,10 +796,7 @@ Repeated_music:
                        we can not get durations and other stuff correct down the line, so we have to
                        add to the duration log here.
                        */
-                       static SCM func;
-
-                       if (!func)
-                               func = scm_primitive_eval (ly_symbol2scm ("shift-duration-log"));
+                       SCM func = ly_scheme_function ("shift-duration-log");
 
                        int dots = ($3 % 3) ? 0 : 1;
                        int shift = -intlog2 ((dots) ? ($3*2/3) : $3);
index 85d95339ad87657584be6c01b6bcc2870eade940..5699cb48d22d05a0a4e123ab92b1c940805a1f16 100644 (file)
   "
 This function replaces all repeats  with unfold repeats. It was 
 written by Rune Zedeler. "
+  
   (let ((es (ly:music-property music 'elements))
        (e  (ly:music-property music 'element))
        (n  (ly:music-name music)))
     (if (equal? n "Repeated_music")
-       (begin
+       (let*
+           ((seq-arg? (memq 'sequential-music
+                                                  (ly:music-property e 'types))))
+         
          (if (equal? (ly:music-property music 'iterator-ctor)
                      Chord_tremolo_iterator::constructor)
-             (shift-duration-log music (ly:intlog2 (ly:music-property music 'repeat-count)) 0))
+             (begin
+               (shift-duration-log music (+ (if seq-arg? 1 0)
+                                            (ly:intlog2 (ly:music-property music 'repeat-count))) 0)
+               (if seq-arg?
+                   (ly:music-compress e (ly:make-moment (length (ly:music-property e 'elements)) 1)))
+               ))
+         
          (set! (ly:music-property music 'length)
                Repeated_music::unfolded_music_length)
          (set! (ly:music-property music 'start-moment-function)
                Repeated_music::first_start)
          (set! (ly:music-property music 'iterator-ctor)
                Unfolded_repeat_iterator::constructor)))
+    
     (if (pair? es)
        (set! (ly:music-property music 'elements)
              (map unfold-repeats es)))
index f649d0bb5c425d2ca2927823b79ebc0b0ffa6808..2d5d0e7a9b96bd8b8a03f5d96d0bee2552cc0271 100644 (file)
@@ -2054,6 +2054,14 @@ def conv (str):
 conversions.append (((2,1,34), conv,
                     '''set-paper-size -> set-default-paper-size.'''))
 
+def conv (str):
+       str = re.sub (r"ly:mutable-music-properties",
+                     "ly:music-mutable-properties", str)
+       return str
+
+conversions.append (((2,1, 36), conv,
+                    '''ly:mutable-music-properties -> ly:music-mutable-properties'''))
+
 ################################
 #      END OF CONVERSIONS      
 ################################