From: Graham Percival Date: Wed, 7 Jun 2006 21:59:11 +0000 (+0000) Subject: \applyMusic to music functions update, thanks to Michael Meixner. X-Git-Tag: release/2.10.0-2~551 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=646a2bafb22bf6c43305c5313d9f3ed3d4cf74c7;p=lilypond.git \applyMusic to music functions update, thanks to Michael Meixner. --- diff --git a/ChangeLog b/ChangeLog index 5f5c2b58b8..e51eb71e7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-06-07 Graham Percival + + * input/test/ add-staccato.ly, add-text-script.ly, + unfold-all-repeats.ly, music-box.ly: \applyMusic to + music functions update, thanks to Michael Meixner. + 2006-06-07 Jan Nieuwenhuizen * SConstruct (LILYPONDPREFIX): Bootstrap fix. diff --git a/THANKS b/THANKS index dc1ba89fd6..c44741fb8e 100644 --- a/THANKS +++ b/THANKS @@ -54,6 +54,7 @@ J. Leung Harald Wellmann Karl Hammar Keith Packard +Michael Meixner Orm Finnendahl Quentin Spencer Rick Hansen diff --git a/input/test/add-staccato.ly b/input/test/add-staccato.ly index 3a8668c5b8..45d61d4db1 100644 --- a/input/test/add-staccato.ly +++ b/input/test/add-staccato.ly @@ -1,8 +1,7 @@ - -\version "2.7.39" +\version "2.9.7" +\sourcefilename "add-staccato.ly" \header { - texidoc= "@cindex Add Stacato Using @code{make-music}, you can add various stuff to notes. In this example staccato dots are added to the notes." @@ -11,7 +10,7 @@ example staccato dots are added to the notes." #(define (make-script x) (make-music 'ArticulationEvent 'articulation-type x)) - + #(define (add-script m x) (if (equal? (ly:music-property m 'name) 'EventChord) @@ -23,11 +22,15 @@ example staccato dots are added to the notes." #(define (add-staccato m) (add-script m "staccato")) +addStacc = +#(define-music-function (parser location music) + (ly:music?) + (music-map add-staccato music)) + \score { \relative c'' { - a b \applyMusic #(lambda (x) (music-map add-staccato x)) { c c } + a b \addStacc { c c } } \layout{ ragged-right = ##t } } - diff --git a/input/test/add-text-script.ly b/input/test/add-text-script.ly index 12a0604cb3..6d66b21fe7 100644 --- a/input/test/add-text-script.ly +++ b/input/test/add-text-script.ly @@ -1,12 +1,10 @@ -\version "2.7.39" +\version "2.9.7" +\sourcefilename "add-text-script.ly" \header { texidoc= "@cindex make-music Fingering You can add various stuff to notes using @code{make-music}. In this example, an extra fingering is attached to a note. - -In general, first do a @code{display} of the music you want to -create, then write a function that will structure the music for you. " } @@ -14,7 +12,7 @@ create, then write a function that will structure the music for you. (make-music 'TextScriptEvent 'direction DOWN 'text (make-simple-markup x))) - + #(define (add-text-script m x) (if (equal? (ly:music-property m 'name) 'EventChord) (set! (ly:music-property m 'elements) @@ -27,9 +25,14 @@ create, then write a function that will structure the music for you. (add-text-script e x)))) m) +addScript = +#(define-music-function (parser location script music ) + ( string? ly:music? ) + (add-text-script music script)) + \score { - \applyMusic #(lambda (x) (add-text-script x "6") (display-music x) x ) { c'4-3 } - \layout{ ragged-right = ##t } + { + \addScript "6" { c'4-3 } + } } - diff --git a/input/test/music-box.ly b/input/test/music-box.ly index 4d11043f62..9d8fe6fabd 100644 --- a/input/test/music-box.ly +++ b/input/test/music-box.ly @@ -1,4 +1,6 @@ -\version "2.7.39" +\version "2.9.7" +\sourcefilename "music-box.ly" + \include "deutsch.ly" % possible rename to scheme- something. -gp % TODO: ask if it needs to have so many empty bars in the middle. -gp @@ -21,7 +23,7 @@ using Scheme functions to avoid typing work. " } (recurse (cdr elts)) ))))) music - )) + )) #(define ((trans pitches) music) (let* ((es (ly:music-property music 'elements)) @@ -50,11 +52,6 @@ using Scheme functions to avoid typing work. " } music)) - - - -\version "2.7.39" - pat = \transpose c c' \repeat unfold 2 { << { \context Staff = "up" {r8 e16 f g e f g } } { \context Staff = "down" << @@ -71,15 +68,21 @@ enda = { r8 f,16 a, c f c a, \stemUp c \change Staff = down endb = {\stemUp \tieUp r16 c,8.~c,4~c,2 r16 h,,8.~h,,4~h,,2 c,1 \bar "|."} endc = {\stemDown \tieDown c,,2~c,, c,,~c,, c,,1_\fermata } + +prelude = +#(define-music-function (parser location patterns) (ly:music?) + (transform patterns)) + + \score { \transpose c c' \context PianoStaff << \new Staff = "up" { \clef "G" } \new Staff = "down" { \clef "F" } - { \applyMusic #transform { + { \prelude { \pat {c e g c' e' } \pat {c d a d' f' } } - + %{ %Etc. @@ -121,7 +124,7 @@ endc = {\stemDown \tieDown c,,2~c,, c,,~c,, c,,1_\fermata } %} } >> - + \layout { \context { \PianoStaff @@ -129,7 +132,7 @@ endc = {\stemDown \tieDown c,,2~c,, c,,~c,, c,,1_\fermata } } line-width = 18.0 \cm } - + \midi { \tempo 4 = 80 } diff --git a/input/test/unfold-all-repeats.ly b/input/test/unfold-all-repeats.ly index 522bb38ade..8c0f1ebbed 100644 --- a/input/test/unfold-all-repeats.ly +++ b/input/test/unfold-all-repeats.ly @@ -1,11 +1,19 @@ -\version "2.7.39" +\version "2.9.7" +\sourcefilename "unfold-all-repeats.ly" \header { texidoc = "Applying the standard function @code{unfold-repeats} unfolds recursively all repeats for a correct MIDI output." } -mel = \context Staff { +unfoldAll = + #(define-music-function (parser location music ) + (ly:music?) + #{ + \unfoldRepeats $music + #}) + +mel = \context Staff { \repeat tremolo 8 {c'32 e' } \repeat percent 2 { c''8 d'' } \repeat volta 2 {c'4 d' e' f'} @@ -18,10 +26,7 @@ mel = \context Staff { \score { { \mel \break - \applyMusic #unfold-repeats \mel + \unfoldAll \mel } } - - -