[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Automated custom clef settings for custom staves (revisited)
From: |
Paul Morris |
Subject: |
Automated custom clef settings for custom staves (revisited) |
Date: |
Tue, 29 Apr 2014 11:37:20 -0700 (PDT) |
Hi all,
I figured out how to do what I was working on back in November (with custom
clef settings):
http://lists.gnu.org/archive/html/lilypond-user/2013-11/msg00295.html
I wrote a music function that takes music with standard clef settings and
returns the music with customized clef settings. This allows you to use the
same music on both a standard staff (with standard clef settings) and on a
custom staff that requires custom clef settings. You just have to run the
music on the custom staff through the music function.
One could use custom clef definitions and/or tags for this but that doesn't
separate content and presentation like this does.
You can use \displayMusic { \clef treble } to see the values of various clef
settings in the music: clefGlyph, clefPosition, middleCClefPosition,
clefTransposition.
I'm posting it for the archives in case it's useful to anyone else.
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."
(let ((current-glyph ""))
(music-map
(lambda (m)
(cond
((equal? 'clefGlyph (ly:music-property m 'symbol))
(set! current-glyph (ly:music-property m 'value)))
((equal? 'clefPosition (ly:music-property m 'symbol))
(set! (ly:music-property m 'value)
(case (ly:music-property m 'value)
((-2) -5) ;; treble
((2) 5) ;; bass
((0) 0) ;; alto
(else (ly:music-property m 'value)))))
((equal? 'clefTransposition (ly:music-property m 'symbol))
(set! (ly:music-property m 'value)
(case (ly:music-property m 'value)
((7) 12) ;; ^8
((-7) -12) ;; _8
((14) 24) ;; ^15
((-14) 24) ;; _15
(else (ly:music-property m 'value)))))
((equal? 'middleCClefPosition (ly:music-property m 'symbol))
(cond
((equal? current-glyph "clefs.G")
(set! (ly:music-property m 'value)
(case (ly:music-property m 'value)
((-6) -12) ;; treble ;; -4 + -2
((-13) -24) ;; treble^8
((-20) -36) ;; treble^15
((1) 0) ;; treble_8
((8) 12) ;; treble_15
(else (ly:music-property m 'value)))))
((equal? current-glyph "clefs.F")
(set! (ly:music-property m 'value)
(case (ly:music-property m 'value)
((6) 12) ;; bass ;; 4 + 2
((13) 24) ;; bass_8
((20) 36) ;; bass_15
((-1) 0) ;; bass^8
((-8) -12) ;; bass^15
(else (ly:music-property m 'value)))))
((equal? current-glyph "clefs.C")
(set! (ly:music-property m 'value)
(case (ly:music-property m 'value)
((0) 0) ;; alto
((-7) -12) ;; alto^8
((7) 12) ;; alto_8
((-14) -24) ;; alto^15
((14) 24) ;; alto_15
(else (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-tp161934.html
Sent from the User mailing list archive at Nabble.com.
- Automated custom clef settings for custom staves (revisited),
Paul Morris <=