From b8c39657c1a6afc1445a3e0afa7d7eb7039f1608 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Thu, 17 Jan 2013 19:55:43 +0100 Subject: [PATCH] Add make-relative regtest This steals a bit of the Bach prelude #1 in the Well-Tempered Piano for demonstrating how to create a relative-cooperating utility macro. --- input/regression/make-relative.ly | 82 +++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 input/regression/make-relative.ly diff --git a/input/regression/make-relative.ly b/input/regression/make-relative.ly new file mode 100644 index 0000000000..706bdb9adc --- /dev/null +++ b/input/regression/make-relative.ly @@ -0,0 +1,82 @@ +\version "2.17.11" +\header { + + texidoc = "@code{make-relative} is a Scheme utility macro mainly +useful for creating music functions accepting pitches as arguments. +Its purpose is to make music functions taking pitch arguments for +producing complex music fragments integrate nicely within a +@code{\\relative} section. This regtest typesets a short music +fragment twice, once without using @code{\\relative}, once using it. +The fragment should appear identical in both cases." + +} + +\layout { ragged-right= ##t } + +ph = +#(define-music-function (parser location p1 p2 p3 p4 p5) + (ly:pitch? ly:pitch? ly:pitch? ly:pitch? ly:pitch?) + (make-relative (p1 p2 p3 p4 p5) p1 + #{ + \repeat unfold 2 { $p1 2 } | + \repeat unfold 2 { r16 $p2 8. ~ $p2 4 } | + \repeat unfold 2 { r8 $p3 16 $p4 $p5 $p3 $p4 $p5 } | + #})) + +\parallelMusic #'(low middle high) +{ + \ph c' e' g' c'' e'' + R1*7 | \skip 1*7 | \oneVoice R1*7 \voiceOne | + \ph a c' e' g' c'' + \voiceTwo | \change Staff = "down" \voiceOne | \oneVoice | + \ph d a d' fis' c'' + \oneVoice R1*21 \voiceTwo | \skip 1*21 | R1*21 | + \ph c, c g bes e' + c,2~ c, | r16 c8. ~ c4 ~ c2 + | r8 f16 a c' f' c' a c' a f a f d f d | + c,2~ c, | r16 b,8. ~ b,4 ~ b,2 + | r8 g'16 b' d'' f'' d'' b' d'' b' g' b' d' f' e' d' | + c,1\fermata | c1 | 1\fermata \bar "|." | +} + +\score { + \new PianoStaff << + \compressFullBarRests + \new Staff = "up" { + << \high \\ \middle >> + } + \new Staff = "down" { + \clef bass + \low + } + >> +} + +\parallelMusic #'(low middle high) +\relative c' { + \ph c e g c e + R1*7 | \skip 1*7 | \oneVoice R1*7 \voiceOne | + \ph a c e g c + \voiceTwo | \change Staff = "down" \voiceOne | \oneVoice | + \ph d, a' d fis c' + \oneVoice R1*21 \voiceTwo | \skip 1*21 | R1*21 | + \ph c, c' g' bes e + c2~ c | r16 c'8. ~ c4 ~ c2 + | r8 f16 a c f c' a c a f a f d f d | + c,,2~ c | r16 b'8. ~ b4 ~ b2 + | r8 g'16 b d f d b d b g b d f e d | + c,,1\fermata | c'1 | 1\fermata \bar "|." | +} + +\score { + \new PianoStaff << + \compressFullBarRests + \new Staff = "up" { + << \high \\ \middle >> + } + \new Staff = "down" { + \clef bass + \low + } + >> +} -- 2.39.5