lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: transpose to a set of pitches


From: Thomas Morley
Subject: Re: transpose to a set of pitches
Date: Tue, 27 Feb 2018 22:24:22 +0100

2018-02-27 19:12 GMT+01:00 Sirius Barras <address@hidden>:
> I would like to transpose a motif (using \modalTranspose) to a _set_ of
> different pitches. At the moment this is what I do:
>
> scale = {c d e f g a b}
> motif = {c' e' g' c'}
> {
>   \modalTranspose c e \scale \motif
>   \modalTranspose c g \scale \motif
>   \modalTranspose c a \scale \motif
> }
>
> How can I do something similar to this:
>
> toPitchSet = {e g a}
> scale = {c d e f g a b}
> motif = {c' e' g' c'}
> {
>   \modalTranspose c \toPitchSet \scale \motif
> }
>
> Many thanks, S.


How about:

\version "2.19.65"

%% Based on a function by David K
multipleModalTransposes =
#(define-music-function (parser location m scale music)
  (ly:music? ly:music? ly:music?)
  ;; If `music' is simple `SequentialMusic', we need to go for 'elements instead
  ;; of 'element. In this case we also need to "unfold" the resulting
  ;; `possible-elts' one level
  (let* ((seq-mus? (music-is-of-type? music 'sequential-music))
         (possible-elts
           (map
             (lambda (pitch)
             (ly:music-property
               #{ \modalTranspose c $pitch $scale $music #}
                 (if seq-mus?
                    'elements
                    'element)))
                (event-chord-pitches m))))

    (music-clone m
      'elements
      (if seq-mus?
          (apply append '() possible-elts)
          possible-elts))))

toPitchSet = { e g a e b }
scale = { c d e f g a b }
motif =
  %\absolute { c' e' g' c' }
  %\relative { c' e g c, }
  %\relative c' { c e g c, }
  %\fixed c' { c e g c }
  %\context Voice { c'4 e' g' c' }
  { c'4 e' g' c' }

\multipleModalTransposes \toPitchSet \scale \motif


Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]