lilypond-user
[Top][All Lists]
Advanced

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

Re: Automated custom clef settings for custom staves (revisited)


From: Paul Morris
Subject: Re: Automated custom clef settings for custom staves (revisited)
Date: Wed, 30 Apr 2014 11:03:36 -0700 (PDT)

Paul Morris wrote
> I wrote a music function that takes music with standard clef settings and
> returns the music with customized clef settings.  

Here's an improved version that also handles cue clefs.  Designed for
treble, bass, and alto clefs, so it may not work with other clefs (with more
work they could be added).

Cheers,
-Paul


%%%%%%%%%%%%%%%%%%%%%%%%%%%

\version "2.18.2"

clefsMod =
#(define-music-function (parser location mus) (ly:music?)
   "Takes music with standard clef settings for standard staff, and
    returns the music with custom clef settings for custom staff.
    Only tested with treble, bass, and alto clefs."
   (let ((current-glyph ""))
     (music-map
      (lambda (m)
        (let ((sym (ly:music-property m 'symbol)))
          (cond

           ((or (eq? 'clefGlyph sym)
                (eq? 'cueClefGlyph sym))
            (set! current-glyph (ly:music-property m 'value)))

           ((or (eq? 'clefPosition sym)
                (eq? 'cueClefPosition sym))
            (ly:music-set-property! m 'value
              (* 5/2 (ly:music-property m 'value))))

           ((or (eq? 'middleCClefPosition sym)
                (eq? 'middleCCuePosition sym))
            (ly:music-set-property! m 'value
              (+ (round (* 12/7 (ly:music-property m 'value)))
                (cond
                 ((equal? current-glyph "clefs.G") -2)
                 ((equal? current-glyph "clefs.F") 2)
                 (else 0))))) ;; includes "clefs.C"

           ((or (eq? 'clefTransposition sym)
                (eq? 'cueClefTransposition sym))
            (ly:music-set-property! m 'value
              (round (* 12/7 (ly:music-property m 'value)))))))
        m)
      mus)))

someMusic = \relative f' {
  \clef treble
  c8 d e f g a b c
  \clef alto
  c,, d e f g a b c
  \clef bass
  c,, d e f g a b c
  \clef "treble_8"
  c d e f g a b c
}

% standard staff
\new Staff {
  \someMusic
}

% custom staff (chromatic scale based staff)
\new Staff \with {
  staffLineLayoutFunction = #ly:pitch-semitones
  \override StaffSymbol.line-positions = #'(-8 -4 4 8)
  \override Stem.no-stem-extend = ##t
}
\clefsMod {
  \someMusic
} 



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Automated-custom-clef-settings-for-custom-staves-revisited-tp161934p161960.html
Sent from the User mailing list archive at Nabble.com.



reply via email to

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