@menu
* Octave checks::
* Transpose::
+* Inversion::
* Modal transformations::
@end menu
To use relative mode within transposed music, an additional
@code{\relative} must be placed inside @code{\transpose}.
+@node Inversion
+@unnumberedsubsubsec Inversion
+
+@cindex inversion
+
+A music expression can be inverted with @code{\inversion}.
+
+@example
+\inversion @var{frompitch} @var{topitch} @var{musicexpr}
+@end example
+
+@noindent
+This means that @code{@var{musicexpr}} is inverted
+interval-by-interval, and transposition is chosen so that
+@code{@var{frompitch}} is mapped to @code{@var{topitch}}.
+
@node Modal transformations
@unnumberedsubsubsec Modal transformations
\modalTranspose c' f' \cOctatonicScale \motif
\retrograde \motif
\modalInversion aes' b' \cOctatonicScale \motif
+ \inversion aes' b' \motif
}
{
s1-"Octatonic motif" |
s1-"motif transposed from c to f" |
s1-"motif in retrograde" |
s1-"motif inverted around aes to b" |
+ s1-"motif inverted exactly"
}
>>
}
(change-pitches music transposer)
music))
+inversion =
+#(define-music-function
+ (parser location around to music) (ly:music? ly:music? ly:music?)
+ (_i "Invert @var{music} about @var{around} and
+transpose from @var{around} to @var{to}.")
+ (music-invert around to music))
+
musicMap =
#(define-music-function (parser location proc mus) (procedure? ly:music?)
(_i "Apply @var{proc} to @var{mus} and all of the music it contains.")
(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-pitch to-pitch 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)))
+