]> git.donarmstrong.com Git - lilypond.git/commitdiff
Let \autochange accept optional arguments for the turning-point and clefs
authorThomas Morley <thomasmorley65@gmail.com>
Thu, 30 Jul 2015 18:39:22 +0000 (20:39 +0200)
committerThomas Morley <thomasmorley65@gmail.com>
Wed, 5 Aug 2015 13:23:19 +0000 (15:23 +0200)
Issue 4530

With the fix for issue 4465 bassStaffProperties and trebleStaffProperties are gone.
This patch reimplements the functionality to set clefs for the staves and offers the
possibility to set another turning-point apart from middle-C.
This is done with optional arguments for \autochange.

Two regtests are added to reflect these possibilities.
Documentation/notation/keyboards.itely is extended accordingly.

Also inserting the usual remarks about license, etc in autochange.scm.

Documentation/notation/keyboards.itely
input/regression/autochange-clefs.ly [new file with mode: 0644]
input/regression/autochange-turning-pitch.ly [new file with mode: 0644]
ly/music-functions-init.ly
scm/autochange.scm

index 631268ec9efed19eec277c9071f202d10de0543e..3d2919edc7391fe85ffc49991ba85c6d4ae1dca6 100644 (file)
@@ -7,7 +7,7 @@
     Guide, node Updating translation committishes..
 @end ignore
 
-@c \version "2.19.21"
+@c \version "2.19.25"
 
 @node Keyboard and other multi-staff instruments
 @section Keyboard and other multi-staff instruments
@@ -289,6 +289,21 @@ in advance.
 }
 @end lilypond
 
+@noindent
+It is possible to specify other pitches for the turning point.
+If the staves are not instantiated explicitly, other clefs may be used.
+
+@lilypond[quote,verbatim]
+music = {
+  g8 b a c' b8 d' c'8 e'
+  d'8 r f' g' a'2
+}
+
+\autochange d' \music
+\autochange b \with { \clef soprano } \music
+\autochange d' \with { \clef alto } \with { \clef tenor } \music
+@end lilypond
+
 @cindex relative music and autochange
 @cindex autochange and relative music
 
diff --git a/input/regression/autochange-clefs.ly b/input/regression/autochange-clefs.ly
new file mode 100644 (file)
index 0000000..def22f2
--- /dev/null
@@ -0,0 +1,22 @@
+
+\version "2.19.25"
+
+\header {
+  texidoc=" Other clefs for the autochanger may be set.  This works for
+implicitly created staves only.
+The first example should turn at b with soprano-clef in the upper Staff.
+The second example should turn at d' with alto-clef in the upper and tenor-clef
+in the lower Staff.
+"
+}
+
+\layout { ragged-right= ##t }
+
+music = {
+  g8 b a c'
+  b8 d' c'8 e'
+  d'8 r f' g' a'2
+}
+
+\autochange b \with { \clef soprano } \music
+\autochange d' \with { \clef alto } \with { \clef tenor } \music
diff --git a/input/regression/autochange-turning-pitch.ly b/input/regression/autochange-turning-pitch.ly
new file mode 100644 (file)
index 0000000..f71e234
--- /dev/null
@@ -0,0 +1,19 @@
+
+\version "2.19.25"
+
+\header {
+  texidoc=" Other turning points for the autochanger are possible."
+}
+
+\layout { ragged-right= ##t }
+
+\context PianoStaff <<
+  \context Staff = "up" {
+    \autochange  \relative { <>^"default c' " b4 c d e }
+    \autochange d' \relative { <>^"switch after d' " b c d e }
+  }
+  \context Staff = "down" {
+    \clef bass
+    s1*2
+  }
+>>
index 7699d638d44a832a8a63100377723d519ae4cf6b..045262c0498c3cb1b1a42d84a970dda79f181fe0 100644 (file)
@@ -18,7 +18,7 @@
 %%%% You should have received a copy of the GNU General Public License
 %%%% along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 
-\version "2.19.22"
+\version "2.19.25"
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -182,27 +182,26 @@ assertBeamSlope =
    (make-grob-property-override 'Beam 'positions (check-slope-callbacks comp)))
 
 autochange =
-#(define-music-function (music) (ly:music?)
-   (_i "Make voices that switch between staves automatically")
-   (let ;; keep the contexts alive for the full duration
-       ((skip (make-skip-music (make-duration-of-length 
-                                (ly:music-length music)))))
-     #{
-       <<
-         \context Staff = "up" <<
-           #(make-autochange-music music)
-           \new Voice { #skip }
-         >>
-         \context Staff = "down" \with {
-           clefGlyph = "clefs.F"
-           clefPosition = 2
-           middleCPosition = 6
-           middleCClefPosition = 6
-         } {
-           \new Voice { #skip }
-         }
-       >>
-     #} ))
+#(define-music-function (pitch clef-1 clef-2 music)
+  ((ly:pitch? (ly:make-pitch 0 0)) (ly:context-mod?)(ly:context-mod?) ly:music?)
+  (_i "Make voices that switch between staves automatically.  As an option the
+pitch where to switch staves may be specified.  The clefs for the staves are
+optional as well.  Setting clefs  works only for implicitly instantiated
+staves.")
+  (let ;; keep the contexts alive for the full duration
+       ((skip (make-skip-music (make-duration-of-length
+                                     (ly:music-length music)))))
+    #{
+      <<
+        \context Staff = "up" $(or clef-1 #{ \with { \clef "treble" } #})
+          <<
+          #(make-autochange-music pitch music)
+          \new Voice { #skip }
+          >>
+        \context Staff = "down" $(or clef-2 #{ \with { \clef "bass" } #})
+          \new Voice { #skip }
+      >>
+    #}))
 
 balloonGrobText =
 #(define-music-function (grob-name offset text)
index 3e1d4b9775d146a8e2b09e4dda748814a4a2e484..5810f3292af1e8c3d227bd44e3629eecf54697b8 100644 (file)
@@ -1,9 +1,25 @@
-
+;;;; This file is part of LilyPond, the GNU music typesetter.
+;;;;
+;;;; Copyright (C) 2000--2015  Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;;;                  Jan Nieuwenhuizen <janneke@gnu.org>
+;;;;
+;;;; LilyPond is free software: you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation, either version 3 of the License, or
+;;;; (at your option) any later version.
+;;;;
+;;;; LilyPond is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;; GNU General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; autochange.scm - fairly related to part combining.
 
-(define-public (make-autochange-music music)
+(define-public (make-autochange-music ref-pitch music)
   (define (generate-split-list change-moment prev-dir event-list acc)
     (if (null? event-list)
         acc
                (pitch (if (pair? notes)
                           (ly:event-property (car notes) 'pitch)
                           #f))
-               (dir (if pitch (sign (ly:pitch-steps pitch)) 0)))
+               (dir (if pitch
+                        (sign
+                          (- (ly:pitch-steps pitch) (ly:pitch-steps ref-pitch)))
+                        0)))
           ;; tail recursive.
           (if (and (not (= dir 0))
                    (not (= dir prev-dir)))
@@ -24,7 +43,6 @@
                                    dir
                                    (cdr event-list)
                                    (cons (cons
-
                                           (if change-moment
                                               change-moment
                                               now)
@@ -36,8 +54,9 @@
 
   (let* ((m (make-music 'AutoChangeMusic))
          (m1 (context-spec-music (make-non-relative-music music) 'Voice ""))
-         (context-list (recording-group-emulate m1
-                                                (ly:parser-lookup 'partCombineListener)))
+         (context-list
+           (recording-group-emulate m1
+                                    (ly:parser-lookup 'partCombineListener)))
          (rev (reverse! (cdar context-list)))
          (split (reverse! (generate-split-list
                            #f