[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Automated custom clef settings for custom staves
From: |
Paul Morris |
Subject: |
Re: Automated custom clef settings for custom staves |
Date: |
Sun, 10 Nov 2013 13:44:08 -0500 |
Below is my attempt to use a custom engraver to set custom clef settings but
only when the clefs appear in a particular custom staff context.
It doesn't quite work since the setting changes take effect too late. The
first note after the new clef is placed on the staff before the change to
"middleCPosition" has happened, and the change in "clefPosition" causes a
second clef to be drawn for each clef (after that first note), at the newly set
position.
Ideally the way to handle this *very* *very* marginal issue, would be to have
the default settings for middleCPosition and clefPosition for each kind of
clef, loaded at the staff level for each staff (as staff context properties?)
where the user could override them for any given staff and clef.
And... I think the phrase for that is "patches welcome" ?
I just wanted to share my attempt at this in case anyone else tries to go down
the same road.
-Paul
%% BEGIN SNIPPET %%
\version "2.17.95"
% Note: customization values are just for demo purposes
% and don't make sense for actual use
\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
}
\layout {
\context {
\Score
\consists
#(make-engraver
(acknowledgers
((clef-interface engraver grob source-engraver)
(let* ((ctx (ly:translator-context source-engraver))
(ctx-name (ly:context-name ctx))
(glyph (ly:grob-property grob 'glyph))
(glyph-name (ly:grob-property grob 'glyph-name)))
;; (display glyph-name)(newline)
;; (display glyph)(newline)
;; (display ctx-name)(newline)
(if (equal? ctx-name 'MyCustomStaff)
(cond
;; G / Treble clef
((equal? glyph "clefs.G")
(ly:context-set-property! ctx 'clefPosition 2)
(ly:context-set-property! ctx 'middleCPosition 10))
;; F / Bass clef
((equal? glyph "clefs.F")
(ly:context-set-property! ctx 'clefPosition -2)
(ly:context-set-property! ctx 'middleCPosition -10))
;; C / Alto etc clef
((equal? glyph "clefs.C")
(ly:context-set-property! ctx 'clefPosition 1)
(ly:context-set-property! ctx 'middleCPosition 6))))))))
}
}
music =
{
\clef treble
c' c' c' c'
\clef bass
c' c' c' c'
\clef alto
c' c' c' c'
\clef "treble^8"
c' c' c' c'
\clef tenor
c' c' c' c'
}
\new MyCustomStaff {
\music
}
\new Staff {
\music
}
- Automated custom clef settings for custom staves, Paul Morris, 2013/11/10
- Re: Automated custom clef settings for custom staves,
Paul Morris <=
- 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