# Lilypond: Create natural signs and accidentals manually

Edit: At first, I was looking for a way to add natural signs manually. Turns out that, at least for the moment, I actually need to place accidentals manually. Generally, I might need both in the future.

There's another question on how to create custom key signatures in Lilypond for Turkish folk music.

I'm using the code from the selected answer posted there to create a combination of ♭ and ♯ with additional superscripts. This allows me to write f in Lilypond code for the 'microtone' note that's between f and f♯. But now I need to use both this note (which is not on the piano) and f♯ (black key on the piano).

I'd like to simply set a ♯ manually in front of some f's. Is there a way to do so? Or any alternative approach?

To clarify: Lilyponds treats the score as if it was a mixture of F major and G major, so it sets a ♮ in front of each b and f automatically, but nothing in front of bes or fis.

• It would help if you could post the important parts of your files so that people willing to answer could use them for experimentation. I guess you checked the "Common notation for non-Western music" in the lilypond manual? For Turkish music, it suggests to use \include "makam.ly" and then use note names such as c4 cc db fk gbm4 gfc gfb efk fk4 db cc c... – Ansa211 May 26 at 8:21
• The most basic code sample would be fis in a piece with key g \major: I need the ability to put a ♯ in front of the note. Most of my question is just an explanation why I need this, but it really boils down to "How can I manually add naturals and accidentals". – Pida May 26 at 11:16
• The suggestion to use makam.ly is for Turkish classical/ottoman music, which probably means music from the 1910s and earlier. I'm interested in folk and pop music from the 1930ies until today, which is usually transcribed differently. – Pida May 26 at 11:19
• You can always add a ♯ manually by writing fis! with exclamation mark. Similarly, f! will print a ♮ and bes! will always print a ♭, even if the key of the score already provides for these accidentals. – Jasper Habicht May 27 at 20:09

If I understand you correctly, you want to add an accidental in front of a note that, due to the key of the score, inherently already is a sharp or flat note. This can be done quite easily by adding an exclamation mark behind the note name, which will force Lilypond to print the relevant accidental regardless of the underlying key. Adding an exclamation mark to a regular note (not sharp or flat) will print a natural sign.

The following code based on the answer you cited … :

\score{
{
\set Staff.keySignature = #((6 . ,FLAT) (3 . ,SHARP))
\override Staff.KeySignature.stencil = #ly:text-interface::print
\override Staff.KeySignature.text =
\markup {
\concat {
\musicglyph #"accidentals.flat"
\lower #0.4 \super \bold \fontsize #-3 2
}
\concat {
\raise #2 \musicglyph #"accidentals.sharp"
\raise #1.6 \super \bold \fontsize #-3 3
}
}
\time 9/8
\relative c' {
s8 fis bes s4. fis!8 bes! s8 \bar "|."
}
}
\layout{}
}
`

… yields the following output:

• Thanks, that's just what I need! – Pida May 28 at 21:17