Triple sharp and triple flat are used in a few pieces (e.g Alkan's Op 39 No 10, 30 ans, Roslavet's sonata)
But lilypond doesn't seem to have those accidentals, so can I create them manually? (e.g concatenating existing glyphs)
Music: Practice & Theory Stack Exchange is a question and answer site for musicians, students, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityIf you need this in one or two places doing it like Ramillies suggested will work just fine. If you need it more frequently you may want to get some sort of proper support:
By doing something like
#(ly:parser-set-note-names
(append pitchnames
(map (lambda (i n)
(cons (string->symbol (format #f "~aisisis" n))
(ly:make-pitch -1 i 3/2)))
(iota 7) '(c d e f g a b))
(map (lambda (i n)
(cons (string->symbol (format #f "~aeseses" n))
(ly:make-pitch -1 i -3/2)))
(iota 7) '(c d e f g a b))))
we can get support for alterations 3/2 (triple sharp) and -3/2 (triple flat). In this case we are using note names c-d-e-f-g-a-b with suffixes isisis and eseses. This will allows to properly enter such a note by doing cisisis
.
Now, of course this does not print. Lilypond uses a pairlist of glyph names for this, so it assumes that every accidental is a single feta glyph. In this case this is not true, so we’ll need to change the Accidental stencil:
\layout {
\context {
\Score
alterationGlyphs =
#(append '((3/2 . "custom")
(-3/2 . "custom"))
standard-alteration-glyph-name-alist)
\override Accidental.stencil =
#(lambda (grob)
(let* ((glyph (ly:grob-property grob 'glyph-name))
(alt (ly:grob-property grob 'alteration))
(dir (> alt 0))
(alt (abs alt))
(alt (* 2 alt))
(doubles (quotient alt 2))
(singles (remainder alt 2))
(doublesharp (grob-interpret-markup grob (markup #:musicglyph "accidentals.doublesharp")))
(doublesharps (make-list doubles doublesharp))
(sharp (grob-interpret-markup grob (markup #:musicglyph "accidentals.sharp")))
(flat (grob-interpret-markup grob (markup #:musicglyph "accidentals.flat"))))
(if (or (equal? glyph "custom") (> alt 2))
(if dir
(if (> singles 0)
(ly:stencil-combine-at-edge sharp X RIGHT (stack-stencils X RIGHT 0.1 doublesharps) 0.1)
(stack-stencils X RIGHT 0.1 doublesharps))
(stack-stencils X RIGHT -0.22 (make-list alt flat)))
(ly:accidental-interface::print grob))))
}
}
This will use the regular stencil unless the absolute alteration is more than 1 or the alteration glyph is set to "custom", in which case it uses repeated flats or repeated double sharps with an optional leading sharp.
Then we can simply do
\fixed c' {
c cis cisis cisisis |
c ces ceses ceseses |
cisisis cisis cis c |
ceseses ceses ces c
}
Now, if we add more and more such suffixes we’ll see that this is not an efficient representation. Instead of defining dedicated notenames we could also simply do a small music function that sharpens or flattens the music:
alt =
#(define-music-function (n m) (number? ly:music?)
#{ \transpose #(ly:make-pitch 0 0) #(ly:make-pitch 0 0 (/ n 2)) #m #})
bas =
#(define-music-function (n m) (number? ly:music?)
(alt (- n) m))
This way we can do
\fixed c' {
\alt3c \alt4c \bas5c \alt1c
}
(Note there are some warnings as the engraver does not find any configures glyphs for these alterations, which can be safely ignored!).
Now, what advantages does this have over Ramillies solution? This introduces proper support for such accidentals, which means you can transpose them:
\transpose cis c { \key ais\major ais'8 bis' cisis'' dis'' cisisis'' disis'' eis''4 }
proper MIDI support, the logic could be extended to provide support for cancelling, key signatures, whatever.
I'm not sure if it can be achieved in a "clean" manner (i. e. by Lilypond knowing it's a triple-accidental'ed note). However, you can always play dirty.
In Lilypond, you can make anything look like anything. Pretty much any object (that is rendered in some way) has a property stencil
, which tells Lilypond how the object should be rendered, and it can be overridden by whatever you want. If you override it with #ly:text-interface::print
, you can then specify any markup in a property called text
.
So you can write a normal sharp or double sharp note and hack the accidental that appears in this way. For instance, if you want to make an A-triple-sharp, you could do this:
\once\override Accidental.stencil = #ly:text-interface::print
\once\override Accidental.text = \markup\concat{\sharp \doublesharp}
ais2 |
This puts down an A sharp, but the sharp is actually hacked to look like \markup\concat{\sharp \doublesharp}
, so you get this:
I guess you will want to tweak it a bit for better readability, but that's just a question of using familiar markup commands (and if they're not familiar, there's always the complete list in docs) like \hspace
or \raise
.
The only disadvantage of this method is that Lilypond will think there's a sharp in front of that note (and it is a sharp, we just hacked it to look differently). So if the next note in the same bar needs to be a real A sharp, you will need to write it as ais!
in order to force the sharp to appear. The MIDI output will also be wrong. But it gets the job done (and it's the only thing I can think of at the moment).