From 2e6a66941b94a9bc0a988f91a8c77ae952c167d6 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 31 Mar 2004 11:47:49 +0000 Subject: [PATCH] * 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/music-functions.scm (make-non-relative-music): new function. --- ChangeLog | 6 ++++++ input/regression/repeat-unfold-all.ly | 18 ++++++++++-------- lily/music.cc | 19 +++++++++++++++++-- lily/parser.yy | 7 ++----- scm/music-functions.scm | 15 +++++++++++++-- scripts/convert-ly.py | 8 ++++++++ 6 files changed, 56 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 09041daa4c..9889cded71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2004-03-31 Han-Wen Nienhuys + * 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 diff --git a/input/regression/repeat-unfold-all.ly b/input/regression/repeat-unfold-all.ly index 40c7b1c539..e184c24ddb 100644 --- a/input/regression/repeat-unfold-all.ly +++ b/input/regression/repeat-unfold-all.ly @@ -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} - } diff --git a/lily/music.cc b/lily/music.cc index df19f5cb36..a8cc060e94 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -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. */ diff --git a/lily/parser.yy b/lily/parser.yy index f5eed1ba3b..549093937e 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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); diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 85d95339ad..5699cb48d2 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -132,20 +132,31 @@ " 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))) diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index f649d0bb5c..2d5d0e7a9b 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -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 ################################ -- 2.39.5