Hi all,

You could write this function more briefly as below. I wonder if there
is any ambiguity about transposition by, for example, one semitone:
should it be \transpose c cis or \transpose c des ?

\version "2.24.0"

#(define pitches (vector #{c#} #{des#} #{d#} #{es#} #{e#} #{f#}
#{fis#} #{g#} #{as#} #{a#} #{bes#} #{b#} #{c'#}))

someFunction =
#(define-music-function
  (note transposeCoeficient)
  (ly:music? integer?)
  (make-relative (note) note
     #{ $note \transpose c #(vector-ref pitches transposeCoeficient)
$note #}))

\score {\relative c' { \someFunction c4 12 }}

Or, if one wants to reduce the number of #{ ... #} constructs:

\version "2.24.0"

pitches =
#(define-scheme-function (mus) (ly:music?)
   (apply circular-list (music-pitches mus)))

myPitches = \pitches { c des d es e f fis g as a bes b c' }

someFunction =
#(define-music-function
  (note transposeCoefficient)
  (ly:music? integer?)
  (make-relative (note) note
     #{ $note \transpose c $(list-ref myPitches transposeCoefficient)
$note #}))

\score {
  \relative c' { \someFunction c4 12 }
}

Lukas


Reply via email to