lilypond-user
[Top][All Lists]
Advanced

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

Re: scheme function for transposition


From: Gilles THIBAULT
Subject: Re: scheme function for transposition
Date: Mon, 1 Jun 2009 22:34:21 +0200

Is the above code something flexible
enough that it could work with the first of those
being something other than c?
(e.g., \transpose f g \notes)
Just change
   (ly:make-pitch -1 0 0)     (<pitch c>)
by
    (ly:make-pitch -1 3 0)     (<pitch f>)
( 0 = c, 1 = d,  etc ...)

If you do want 2 parameters, proceed as for one (copy/past) changing only the names.

%%%%%%%%%%%%%%%%%
firstNotes = \relative c' { c4 d e f }

first = #(define-music-function (parser location root trans)(ly:music? ly:music?)
(let* (
   (trans-note (car (ly:music-property trans 'elements)))
   (trans-pitch (ly:music-property trans-note 'pitch))
   (root-note (car (ly:music-property root 'elements)))
   (root-pitch (ly:music-property root-note 'pitch))
   (delta-pitch (ly:pitch-diff trans-pitch root-pitch)))
(ly:music-transpose (ly:music-deep-copy firstNotes) delta-pitch)
))

\score {<<
\new Staff  \firstNotes
 \new Staff  \first c d
 \new Staff  \first d fis
 \new Staff  \first e a
 >>
}

%%%%%%%%%%%%%%%%%%
Gilles





reply via email to

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