]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/modal-transforms.scm
Run grand-replace for 2012
[lilypond.git] / scm / modal-transforms.scm
index cdaa015ccc08099c251c51304ece2c77a66c61d9..737d7e2a9f37dc8c9bf8a957678e902fe13b3656 100644 (file)
@@ -1,6 +1,6 @@
 ;;; modal-transforms.scm --- Modal transposition, inversion, and retrograde.
 
-;; Copyright (C) 2011 Ellis & Grant, Inc.
+;; Copyright (C) 2011--2012 Ellis & Grant, Inc.
 
 ;; Author: Michael Ellis <michael.f.ellis@gmail.com>
 
@@ -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))))
 
@@ -220,3 +214,17 @@ Typically used to construct a scale for input to transposer-factory
     (map retrograde-music reversed)
 
     music))
+
+(define-public (pitch-invert around to music)
+  "If @var{music} is a single pitch, inverts it about @var{around}
+and transposes from @var{around} to @var{to}."
+  (let ((p (ly:music-property music 'pitch)))
+    (if (ly:pitch? p)
+       (ly:music-set-property!
+        music 'pitch
+        (ly:pitch-transpose to (ly:pitch-diff around p))))
+    music))
+
+(define-public (music-invert around to music)
+  "Applies pitch-invert to all pitches in @var{music}."
+     (music-map (lambda (x) (pitch-invert around to x)) music))