lilypond-user
[Top][All Lists]
Advanced

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

Re: multi-instrument parts


From: Jay Anderson
Subject: Re: multi-instrument parts
Date: Wed, 16 Jan 2013 19:00:01 -0700

On Tue, Jan 15, 2013 at 10:43 PM, Kieren MacMillan
<address@hidden> wrote:
>> There's this: http://lsr.dsi.unimi.it/LSR/Item?id=697 which is useful
>> when the transposition changes mid-piece (like for clarinets, horns,
>> and trumpets). Also you don't have to think about the 'from' pitch.
>> You only need the 'to' pitch.
>
> That doesn't seem to handle key signatures very well — is there a workaround?

It was a simple change to make it take into account the key
signatures. I updated it for the latest version as well (functions
should take in pitches directly). I'm used to horn music devoid of key
signatures :).

\version "2.17.10"

#(define (adjust-note mus key currkey)
 (cond ((or
          (eq? (ly:music-property mus 'name) 'NoteEvent)
          (eq? (ly:music-property mus 'name) 'KeyChangeEvent))
         (ly:music-transpose mus (car currkey)))
       ((and
          (eq? (ly:music-property mus 'name) 'PropertySet)
          (eq? (ly:music-property mus 'symbol) 'instrumentTransposition))
         (set-car! currkey (ly:pitch-negate (ly:music-property mus 'value)))
         (ly:music-set-property! mus 'value (ly:make-pitch 0 0 0))
         mus)
       (else mus)))

normalizeTransposition =
#(define-music-function (parser location key music) (ly:pitch? ly:music?)
 (ly:music-transpose
   (let ((currkey (list (ly:make-pitch 0 0 0))))
     (music-map (lambda (x) (adjust-note x key currkey)) music))
   (ly:pitch-negate key)))

music = \relative c' {
 \time 4/4
 \transposition f
 \key c \major
 c e g c |
 \transposition ees
 \key c \major
 c, e g c |
 \transposition g
 \key c \major
 c, e g c |
}

\score {
 <<
   \new Staff {
     \music
   }
   \new Staff {
     \normalizeTransposition c' \music
   }
 >>
 \layout {}
 \midi {}
}



reply via email to

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