X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fmusic-functions.scm;h=479c28b79f2bc5b2dcba253426fd0db149115d07;hb=bcbcf02fdbddaca8f090471055f98588b8c9b8ca;hp=a878dfde5f3231a863645f924d6e552d873e743d;hpb=ae7aed00f38a400d24c498a8779c9aa0c6ba6b0e;p=lilypond.git diff --git a/scm/music-functions.scm b/scm/music-functions.scm index a878dfde5f..479c28b79f 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -1,11 +1,11 @@ -;;;; music-functions.scm -- implement Scheme output routines for PostScript +;;;; music-functions.scm -- ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; ;;;; (c) 1998--2004 Jan Nieuwenhuizen -;;;; Han-Wen Nienhuys +;;;; Han-Wen Nienhuys -(use-modules (ice-9 optargs)) +;; (use-modules (ice-9 optargs)) ;;; ly:music-property with setter ;;; (ly:music-property my-music 'elements) @@ -374,9 +374,10 @@ of beat groupings " (define-public (set-time-signature num den . rest) (ly:export (apply make-time-signature-set `(,num ,den . ,rest)))) -(define-public (make-penalty-music pen) +(define-public (make-penalty-music pen page-pen) (make-music 'BreakEvent - 'penalty pen)) + 'penalty pen + 'page-penalty page-pen)) (define-public (make-articulation name) (make-music 'ArticulationEvent @@ -579,6 +580,27 @@ without context specification. Called from parser." (if (vector? props) (vector-reverse-map execute-1 props)))) + + +(defmacro-public def-grace-function (start stop) + `(def-music-function (location music) (ly:music?) + (make-music 'GraceMusic + 'origin location + 'element (make-music 'SequentialMusic + 'elements (list (ly:music-deep-copy ,start) + music + (ly:music-deep-copy ,stop)))))) + +(defmacro-public def-music-function (args signature . body) + "Helper macro for `ly:make-music-function'. +Syntax: + (def-music-function (location arg1 arg2 ...) (arg1-type? arg2-type? ...) + ...function body...) +" + `(ly:make-music-function (list ,@signature) + (lambda (,@args) + ,@body))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; switch it on here, so parsing and init isn't checked (too slow!) ;; @@ -645,11 +667,11 @@ without context specification. Called from parser." (define-public (set-accidental-style style . rest) "Set accidental style to STYLE. Optionally takes a context argument, e.g. 'Staff or 'Voice. The context defaults to Voice, except for piano styles, which -use PianoStaff as a context. " +use GrandStaff as a context. " (let ((context (if (pair? rest) (car rest) 'Staff)) (pcontext (if (pair? rest) - (car rest) 'PianoStaff))) + (car rest) 'GrandStaff))) (ly:export (cond ;; accidentals as they were common in the 18th century. @@ -693,14 +715,14 @@ use PianoStaff as a context. " ((equal? style 'piano) (set-accidentals-properties #f '( Staff (same-octave . 0) (any-octave . 0) (same-octave . 1) - PianoStaff (any-octave . 0) (same-octave . 1)) + GrandStaff (any-octave . 0) (same-octave . 1)) '() pcontext)) ((equal? style 'piano-cautionary) (set-accidentals-properties #f '(Staff (same-octave . 0)) '(Staff (any-octave . 0) (same-octave . 1) - PianoStaff (any-octave . 0) (same-octave . 1)) + GrandStaff (any-octave . 0) (same-octave . 1)) pcontext)) ;; do not set localKeySignature when a note alterated differently from ;; localKeySignature is found. @@ -720,7 +742,31 @@ use PianoStaff as a context. " '() context)) (else - (ly:warn (string-append "Unknown accidental style: " (symbol->string style))) + (ly:warn "Unknown accidental style: ~S" (symbol->string style)) (make-sequential-music '())))))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define-public (skip-of-length mus) + "Create a skip of exactly the same length as MUS." + (let* + ((skip + (make-music + 'SkipEvent + 'duration (ly:make-duration 0 0)))) + + (make-event-chord (list (ly:music-compress skip (ly:music-length mus)))) +)) + + +(define-public (mmrest-of-length mus) + "Create a mmrest of exactly the same length as MUS." + + (let* + ((skip + (make-multi-measure-rest + (ly:make-duration 0 0) '() ))) + (ly:music-compress skip (ly:music-length mus)) + skip +))