From: Thomas Morley Date: Thu, 30 Jul 2015 18:39:22 +0000 (+0200) Subject: Let \autochange accept optional arguments for the turning-point and clefs X-Git-Tag: release/2.19.25-1~18 X-Git-Url: https://git.donarmstrong.com/?p=lilypond.git;a=commitdiff_plain;h=e6e59e19a164f0d3af53b0bde3798940de162d66 Let \autochange accept optional arguments for the turning-point and clefs 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. --- diff --git a/Documentation/notation/keyboards.itely b/Documentation/notation/keyboards.itely index 631268ec9e..3d2919edc7 100644 --- a/Documentation/notation/keyboards.itely +++ b/Documentation/notation/keyboards.itely @@ -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 index 0000000000..def22f2aa3 --- /dev/null +++ b/input/regression/autochange-clefs.ly @@ -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 index 0000000000..f71e234f10 --- /dev/null +++ b/input/regression/autochange-turning-pitch.ly @@ -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 + } +>> diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 7699d638d4..045262c049 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -18,7 +18,7 @@ %%%% You should have received a copy of the GNU General Public License %%%% along with LilyPond. If not, see . -\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) diff --git a/scm/autochange.scm b/scm/autochange.scm index 3e1d4b9775..5810f3292a 100644 --- a/scm/autochange.scm +++ b/scm/autochange.scm @@ -1,9 +1,25 @@ - +;;;; This file is part of LilyPond, the GNU music typesetter. +;;;; +;;;; Copyright (C) 2000--2015 Han-Wen Nienhuys +;;;; Jan Nieuwenhuizen +;;;; +;;;; 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 . ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 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 @@ -16,7 +32,10 @@ (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