[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Automated custom clef settings for custom staves
From: |
Paul Morris |
Subject: |
Automated custom clef settings for custom staves |
Date: |
Sun, 10 Nov 2013 13:15:02 -0500 |
Hi everyone,
Say you have a custom staff that needs custom settings for each of the
different clefs, namely "middleCPosition" to put the notes on the right lines
and spaces, and "clefPosition" to put the clef in the right vertical position.
You can put these settings into a variable and use that instead of the usual
syntax for setting a clef:
myBass = {
\clef bass
\set Staff.middleCPosition = #-2
\set Staff.clefPosition = #1
}
(Previous discussion:
http://lists.gnu.org/archive/html/lilypond-user/2013-02/msg00247.html )
But I figured out another way to do it that lets you use the standard input for
setting and changing clefs. See the snippet below. It stores the standard
"clef" function in a variable and then overwrites "clef" with a new music
function that passes the input/parameter through to the standard clef function
and also changes the other settings, depending on the clef.
It seems to work well. The only down side (so far) is that it affects all
clefs regardless of what kind of staff they're on. So if you try to put a
standard staff in the same file with your custom staff, the positions of notes
and clefs on the standard staff won't be correct.
So my question is whether there is some way to determine whether a given clef
is to be on a given custom staff or not, and only apply these setting changes
when that's the case. I've made an unsuccessful attempt at this using an
engraver, which I'll post in a follow-up email.
Thanks,
-Paul
%% BEGIN SNIPPET %%
\version "2.17.95"
% Note: customization values are just for demo purposes
% and don't make sense for actual use
standardClefFunction = #clef
clef =
#(define-music-function (parser location clef-type) (string-or-symbol?)
#{
\standardClefFunction #clef-type
#(cond
((or (equal? clef-type "treble") (equal? clef-type "G"))
#{
\set Staff.middleCPosition = #-4
\set Staff.clefPosition = #-4
#})
((or (equal? clef-type "bass") (equal? clef-type "F"))
#{
\set Staff.middleCPosition = #3
\set Staff.clefPosition = #4
#})
((or (equal? clef-type "alto") (equal? clef-type "C"))
#{
\set Staff.middleCPosition = #-1
\set Staff.clefPosition = #-1
#}))
#})
\layout {
\context {
\Staff
\name MyCustomStaff
\alias Staff
\override StaffSymbol.line-positions = #'(-4 -2 2 4)
% omitting other customizations to make tiny example
}
\context { \Score \accepts MyCustomStaff }
% omitting other contexts to make tiny example
}
music =
{
\clef treble
c'2 c'
\clef bass
c' c'
\clef alto
c' c'
\clef "treble^8"
c' c'
\clef tenor
c' c'
}
\new MyCustomStaff {
\music
}
\new Staff {
\music
}
- Automated custom clef settings for custom staves,
Paul Morris <=
- Re: Automated custom clef settings for custom staves, Paul Morris, 2013/11/10
- Re: Automated custom clef settings for custom staves, David Kastrup, 2013/11/10
- Re: Automated custom clef settings for custom staves, Paul Morris, 2013/11/10
- Re: Automated custom clef settings for custom staves, David Kastrup, 2013/11/10
- Re: Automated custom clef settings for custom staves, Paul Morris, 2013/11/10
- Re: Automated custom clef settings for custom staves, Paul Morris, 2013/11/11
- Re: Automated custom clef settings for custom staves, Urs Liska, 2013/11/11
- Re: Automated custom clef settings for custom staves, Paul Morris, 2013/11/11
- Re: Automated custom clef settings for custom staves, Paul Morris, 2013/11/11