From cf6201863b691be9b361049f76b80024e34b029b Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Fri, 9 Sep 2011 15:24:16 +0200 Subject: [PATCH] music-functions-init.ly et al: Reduce abuse of ly:music? arguments for getting pitches. --- ly/music-functions-init.ly | 51 +++++++++++++++----------------------- scm/modal-transforms.scm | 21 +++++----------- 2 files changed, 26 insertions(+), 46 deletions(-) diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 5e1225431a..a95701c4bf 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -517,7 +517,7 @@ makeClusters = modalInversion = #(define-music-function (parser location around to scale music) - (ly:music? ly:music? ly:music? ly:music?) + (ly:pitch? ly:pitch? ly:music? ly:music?) (_i "Invert @var{music} about @var{around} using @var{scale} and transpose from @var{around} to @var{to}.") (let ((inverter (make-modal-inverter around to scale))) @@ -526,7 +526,7 @@ transpose from @var{around} to @var{to}.") modalTranspose = #(define-music-function (parser location from to scale music) - (ly:music? ly:music? ly:music? ly:music?) + (ly:pitch? ly:pitch? ly:music? ly:music?) (_i "Transpose @var{music} from pitch @var{from} to pitch @var{to} using @var{scale}.") (let ((transposer (make-modal-transposer from to scale))) @@ -535,7 +535,7 @@ using @var{scale}.") inversion = #(define-music-function - (parser location around to music) (ly:music? ly:music? ly:music?) + (parser location around to music) (ly:pitch? ly:pitch? ly:music?) (_i "Invert @var{music} about @var{around} and transpose from @var{around} to @var{to}.") (music-invert around to music)) @@ -570,10 +570,10 @@ markups), or inside a score.") octaveCheck = -#(define-music-function (parser location pitch-note) (ly:music?) +#(define-music-function (parser location pitch) (ly:pitch?) (_i "Octave check.") (make-music 'RelativeOctaveCheck - 'pitch (pitch-of-note pitch-note))) + 'pitch pitch)) ottava = #(define-music-function (parser location octave) (integer?) @@ -843,18 +843,12 @@ removeWithTag = music)) resetRelativeOctave = -#(define-music-function (parser location reference-note) (ly:music?) +#(define-music-function (parser location pitch) (ly:pitch?) (_i "Set the octave inside a \\relative section.") - (let* ((notes (ly:music-property reference-note 'elements)) - (pitch (ly:music-property (car notes) 'pitch))) - - (set! (ly:music-property reference-note 'elements) '()) - (set! (ly:music-property reference-note 'to-relative-callback) - (lambda (music last-pitch) - pitch)) - - reference-note)) + (make-music 'SequentialMusic + 'to-relative-callback + (lambda (music last-pitch) pitch))) retrograde = #(define-music-function (parser location music) @@ -875,16 +869,11 @@ rightHandFinger = #(define-music-function (parser location finger) (number-or-string?) (_i "Apply @var{finger} as a fingering indication.") - (apply make-music - (append - (list - 'StrokeFingerEvent - 'origin location) - (if (string? finger) - (list 'text finger) - (list 'digit finger))))) - - + (make-music + 'StrokeFingerEvent + 'origin location + (if (string? finger) 'text 'digit) + finger)) scaleDurations = #(define-music-function (parser location fraction music) @@ -954,11 +943,11 @@ transpose = transposedCueDuring = #(define-music-function - (parser location what dir pitch-note main-music) - (string? ly:dir? ly:music? ly:music?) + (parser location what dir pitch main-music) + (string? ly:dir? ly:pitch? ly:music?) (_i "Insert notes from the part @var{what} into a voice called @code{cue}, -using the transposition defined by @var{pitch-note}. This happens +using the transposition defined by @var{pitch}. This happens simultaneously with @var{main-music}, which is usually a rest. The argument @var{dir} determines whether the cue notes should be notated as a first or second voice.") @@ -969,15 +958,15 @@ as a first or second voice.") 'quoted-context-id "cue" 'quoted-music-name what 'quoted-voice-direction dir - 'quoted-transposition (pitch-of-note pitch-note))) + 'quoted-transposition pitch)) transposition = -#(define-music-function (parser location pitch-note) (ly:music?) +#(define-music-function (parser location pitch) (ly:pitch?) (_i "Set instrument transposition") (context-spec-music (make-property-set 'instrumentTransposition - (ly:pitch-negate (pitch-of-note pitch-note))) + (ly:pitch-negate pitch)) 'Staff)) tweak = diff --git a/scm/modal-transforms.scm b/scm/modal-transforms.scm index 151fb8c3be..2d604fc948 100644 --- a/scm/modal-transforms.scm +++ b/scm/modal-transforms.scm @@ -176,21 +176,15 @@ Typically used to construct a scale for input to transposer-factory ;; ------------- PUBLIC FUNCTIONS ----------------------------- -(define-public (make-modal-transposer from-pitch to-pitch scale) +(define-public (make-modal-transposer from to scale) "Wrapper function for transposer-factory." - (let ((transposer (transposer-factory (make-extended-scale scale))) - (from (car (extract-pitch-sequence from-pitch))) - (to (car (extract-pitch-sequence to-pitch)))) - + (let ((transposer (transposer-factory (make-extended-scale scale)))) (lambda (p) (transposer from to p)))) -(define-public (make-modal-inverter around-pitch to-pitch scale) +(define-public (make-modal-inverter around to scale) "Wrapper function for inverter-factory" - (let ((inverter (inverter-factory (make-extended-scale scale))) - (around (car (extract-pitch-sequence around-pitch))) - (to (car (extract-pitch-sequence to-pitch)))) - + (let ((inverter (inverter-factory (make-extended-scale scale)))) (lambda (p) (inverter around to p)))) @@ -231,9 +225,6 @@ and transposes from @var{around} to @var{to}." (ly:pitch-transpose to (ly:pitch-diff around p)))) music)) -(define-public (music-invert around-pitch to-pitch music) +(define-public (music-invert around to music) "Applies pitch-invert to all pitches in @var{music}." - (let ((around (car (extract-pitch-sequence around-pitch))) - (to (car (extract-pitch-sequence to-pitch)))) - (music-map (lambda (x) (pitch-invert around to x)) music))) - + (music-map (lambda (x) (pitch-invert around to x)) music)) -- 2.39.2