lilypond-user
[Top][All Lists]
Advanced

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

Re: multiple transpose - was :Emacs integration


From: David Kastrup
Subject: Re: multiple transpose - was :Emacs integration
Date: Sun, 01 Sep 2013 14:50:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Thomas Morley <address@hidden> writes:

>>> And then you use either
>>> \scalesAndTriads { c f bes ees aes des ges g d a e b fis }
>>> or
>>> \scalesAndTriads << c f bes ees aes des ges g d a e b fis >>
>>>
>>> I'd not use \relative $music here: that looks like asking for trouble.
>
> Not sure what you suspect.
> May I ask for some details?

Silently applying \relative means that
a) a reference pitch will be picked out without asking the user
b) if the user intended absolute pitch, he'll get a surprise

> I now come up with:
>
> \version "2.17.25"
>
> multipleTranspose =
> #(define-music-function (parser location m music)(ly:music? ly:music?)
>   (let* ((elts (ly:music-property m 'elements))
>          (pitches (map (lambda (x) (ly:music-property x 'pitch)) elts))
>          (transposed-music-list
>            (map (lambda (pitch) #{ \transpose c $pitch $music #}) pitches)))
>
>   #{
>           $(cond ((music-is-of-type? m 'sequential-music)
>                   (make-sequential-music transposed-music-list))
>                  ((music-is-of-type? m 'simultaneous-music)
>                   (make-simultaneous-music
>                     (map
>                       (lambda (el) #{ \new Staff $el #})
>                       transposed-music-list)))
>                  ;; Not sure whether there's need for,
>                  ;; though, better be a paranoiac.
>                  (else
>                    (ly:error
>                      "m should be sequential or simultaneous-music. Typo?")))
>   #}))
>
> %% Examples
>
> \new Staff
> \multipleTranspose { c cis } \relative c'' { g a }
>
> \new StaffGroup
> \multipleTranspose << c cis >> \relative c'' { g a }

Well, as with \relative, I'd say that \new Staff deserves getting
_explicit_ specification by the user if that's his intent.  Now let's do
this somewhat recklessly:

\version "2.17.23"

multipleTranspose =
#(define-music-function (parser location m music)(ly:music? ly:music?)
   (music-clone m
    'elements
    (map (lambda (pitch)
          (ly:music-property #{ \transpose c $pitch $music #} 'element))
         (event-chord-pitches m))))

%% Examples

\new Staff
\multipleTranspose { c cis } \relative c'' { g a }

\new StaffGroup
\multipleTranspose << c cis >> \relative c'' \new Staff { g a }

\new Staff
\multipleTranspose <c cis> g''!

-- 
David Kastrup

reply via email to

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