I am trying to write a simple, minimalist script in LilyPond to create the koron symbol (used in Persian music).
I came up with the following solution, with satisfactory results, but my code is not well-organized:
koron = {
\once\override Accidental.stencil = #ly:text-interface::print
\once\override Accidental.text = \markup {
\overlay {
\override #'(thickness . 1.5) {
\draw-line #'(-.7 . .4)
\draw-line #'(-.7 . -.4)
\translate #'(-.7 . -1.4)
\draw-line #'(0 . 1.8)
}
}
}
}
\markup {Mode of Dastgah}
\score {
{
\omit Staff.TimeSignature
\cadenzaOn
\key c \major % not interested in automation of accidentals!
\override Staff.KeySignature.stencil = #ly:text-interface::print
\override Staff.KeySignature.text = \markup {
\musicglyph #"accidentals.flat" % standard symbol added to key signature like this
\overlay {
\raise #1.5 {
\override #'(thickness . 1.5) {
\draw-line #'(-.7 . .4)
\draw-line #'(-.7 . -.4)
\translate #'(-.7 . -1.4)
\draw-line #'(0 . 1.8)
}
}
} % koron symbol added to key signature like this
}
\relative c' {
b!1 c \koron % replaces accidental of next note by koron
deh e f g
a^\markup {
\overlay {
\override #'(thickness . 1.5) {
\translate #'(1.5 . .7) {
\draw-line #'(-.7 . .4)
\draw-line #'(-.7 . -.4)
\translate #'(-.7 . -1.4)
\draw-line #'(0 . 1.8)
}
}
} (var)
} % koron in a text
b
\bar "|."
}
}
}
My naive difficulty is with defining new commands. I wish LilyPond would accept a LaTeX tool like \newcommand
, but apparently it does not. The variable "koron" in my code seems to be working fine, but when I try to define, for example,
koronsymboldraw = {
\draw-line #'(-.7 . .4)
\draw-line #'(-.7 . -.4)
\translate #'(-.7 . -1.4)
\draw-line #'(0 . 1.8)
}
to make things more modular, LilyPond gives me errors:
error: unknown escaped string: `\draw-line'
...
With the manual of LilyPond not being sufficiently helpful really, I hope I can get some thoughts here on how we can define efficient commands and functions in LilyPond, particularly for this code.