\version "2.24.3"
\language "deutsch"
#(set-global-staff-size 16)
\header {
title = ""
}
\paper{
paper-width = 12\cm
paper-height = 20\cm
indent = 0
}
global = {
\key b \major
}
#(define ((shift offsets) grob)
"Defines how NoteHeads should be moved according to the given list of offsets."
(let* (
;; NoteHeads
;; Get the NoteHeads of the NoteColumn
(note-heads (ly:grob-array->list (ly:grob-object grob 'note-heads)))
;; Get their durations
(nh-duration-log
(map
(lambda (note-head-grobs)
(ly:grob-property note-head-grobs 'duration-log))
note-heads))
;; Get their length in X-axis-direction
(stencils-x-lengths
(map
(lambda (x)
(let* ((grob-x-ext (ly:grob-extent x grob X)))
(if (interval-sane? grob-x-ext)
(interval-length grob-x-ext)
0)))
note-heads))
;; Stem
(stem (ly:grob-object grob 'stem))
(stem-thick (ly:grob-property stem 'thickness 1.3))
(stem-x-width (if (ly:grob? stem)
(let ((stem-x-ext (ly:grob-extent stem grob X)))
(if (interval-sane? stem-x-ext)
(interval-length stem-x-ext)
(/ stem-thick 10)))
;; Fall back
;; TODO is it ever used?
(/ stem-thick 10)))
(stem-dir (ly:grob-property stem 'direction))
;; Calculate a value to compensate the stem-extension
(stem-x-corr
(map
(lambda (q)
;; TODO better coding if (<= log 0)
(cond ((and (= q 0) (= stem-dir 1))
(* -1 (+ 2 (* -4 stem-x-width))))
((and (< q 0) (= stem-dir 1))
(* -1 (+ 2 (* -1 stem-x-width))))
((< q 0)
(* 2 stem-x-width))
(else (/ stem-x-width 2))))
nh-duration-log)))
;; Final Calculation for moving the NoteHeads
(for-each
(lambda (nh nh-x-length off x-corr)
(if (= off 0)
#f
(ly:grob-translate-axis! nh (* off (- nh-x-length x-corr)) X)))
note-heads stencils-x-lengths offsets stem-x-corr)))
displaceHeads =
#(define-music-function (offsets) (list?)
"
Moves the NoteHeads, using (shift offsets)
"
#{
\once \override NoteColumn.before-line-breaking = #(shift offsets)
#})
melody = \relative {
\global
\omit Score.TimeSignature
\omit Score.BarLine
\omit Stem
\autoBeamOff
f' g < f g > \displaceHeads #'(0 1.75) < a g > a < f f >
}
words = \lyricmode {
Ky -- ri -- e e -- lei -- son.
}
\score {
<<
\new Staff {
\melody
}
\addlyrics { \words }
>>
}\once \override LyricText.X-offset = #1.5 e%%%%% Defs to be saved as "modernGregorian.ily" %%%%%%%%%
%%%% Defining new stem/ligatures:
% long stem
lst = #(define-music-function (mus)
(ly:music?)
#{
\stemDown
\undo\omit Stem
\once\override Stem.length = #7
\once\override Stem.X-extent = #'(.1 . 0)
\once\override NoteHead.stem-attachment = #'(-1.5 . -.1)
$mus
\omit Stem
#})
%long curved ligature
#(define (long-curved-ligature grob)
(if (ly:stencil? (ly:stem::print grob))
(let* ((stencil (ly:stem::print grob))
(X-ext (ly:stencil-extent stencil X))
(Y-ext (ly:stencil-extent stencil Y))
(width (interval-length X-ext))
(len (interval-length Y-ext)))
(ly:stencil-translate
(grob-interpret-markup grob
(markup
(#:path width
(list (list (quote moveto) -0.7 -0.65)
(list (quote curveto) -1.2 -0.4 -1.1 -0.2 -0.9 0.5)
(list (quote curveto) -0.9 0.5 -0.4 2 -0.8 2.2)))))
(cons 0 (interval-start Y-ext))))
#f))
lli = #(define-music-function (mus)
(ly:music?)
#{
\stemUp
\undo\omit Stem
\override Stem.stencil = #long-curved-ligature
$mus
\omit Stem
#})
%medium curved ligature
#(define (medium-curved-ligature grob)
(if (ly:stencil? (ly:stem::print grob))
(let* ((stencil (ly:stem::print grob))
(X-ext (ly:stencil-extent stencil X))
(Y-ext (ly:stencil-extent stencil Y))
(width (interval-length X-ext))
(len (interval-length Y-ext)))
(ly:stencil-translate
(grob-interpret-markup grob
(markup
(#:path width
(list (list (quote moveto) -0.7 -0.65)
(list (quote curveto) -1.2 -0.4 -1.1 -0.2 -0.9 0.5)
(list (quote curveto) -0.9 0.5 -0.4 1.9 -1.4 1.8)))))
(cons 0 (interval-start Y-ext))))
#f))
mli = #(define-music-function (mus)
(ly:music?)
#{
\stemUp
\undo\omit Stem
\override Stem.stencil = #medium-curved-ligature
$mus
\omit Stem
#})
%short curved ligature
#(define (short-curved-ligature grob)
(if (ly:stencil? (ly:stem::print grob))
(let* ((stencil (ly:stem::print grob))
(X-ext (ly:stencil-extent stencil X))
(Y-ext (ly:stencil-extent stencil Y))
(width (interval-length X-ext))
(len (interval-length Y-ext)))
(ly:stencil-translate
(grob-interpret-markup grob
(markup
(#:path width
(list (list (quote moveto) -0.7 -0.65)
(list (quote curveto) -1.2 -0.4 -1.1 -0.2 -1 0.4)
(list (quote curveto) -1 0.4 -0.8 1.5 -1.4 1.3)))))
(cons 0 (interval-start Y-ext))))
#f))
sli = #(define-music-function (mus)
(ly:music?)
#{
\stemUp
\undo\omit Stem
\override Stem.stencil = #short-curved-ligature
$mus
\omit Stem
#})
%tiny curved ligature
#(define (tiny-curved-ligature grob)
(if (ly:stencil? (ly:stem::print grob))
(let* ((stencil (ly:stem::print grob))
(X-ext (ly:stencil-extent stencil X))
(Y-ext (ly:stencil-extent stencil Y))
(width (interval-length X-ext))
(len (interval-length Y-ext)))
(ly:stencil-translate
(grob-interpret-markup grob
(markup
(#:path width
(list (list (quote moveto) -0.7 -0.65)
(list (quote curveto) -1.2 -0.4 -1.1 -0.1 -1 0.2)
(list (quote curveto) -1 0.2 -0.8 0.7 -1.4 0.6)))))
(cons 0 (interval-start Y-ext))))
#f))
tli = #(define-music-function (mus)
(ly:music?)
#{
\stemUp
\undo\omit Stem
\override Stem.stencil = #tiny-curved-ligature
$mus
\omit Stem
#})
%% Ornament function
orn =
-\tweak self-alignment-X #LEFT
-\tweak Y-offset #0.5
-\tweak X-offset #1
-\tweak outside-staff-priority ##f
-\markup
\raise #-.3
\scale #'(1 . .85)
\rotate #90
\musicglyph "ties.lyric.short"
%% Left aligning lyric :
lal = \once\override LyricText.self-alignment-X = #LEFT
%% horizontal inside staff spacer
space =
#(define-music-function
(anzahl)
(number?)
#{
\grace { \repeat unfold #anzahl s }
#})
% Given some music that represents lyrics, add a prefix to the first
% lyric event.
% syntax is \versus { some lyrics }
% resp. \responsum { some lyrics }
#(define (add-prefix-to-lyrics prefix music)
(let ((found? #f))
(map-some-music
(lambda (m)
(if found? m
(and (music-is-of-type? m 'lyric-event)
(begin
(set! (ly:music-property m 'text)
(string-append prefix (ly:music-property m 'text)))
(set! found? #t)
m))))
music)))
% Add unicode 2123 (versicle) as prefix to lyrics.
versus =
#(define-music-function (music) (ly:music?)
(add-prefix-to-lyrics "℣. " music))
% Add unicode 211F (response) as prefix to lyrics.
responsum =
#(define-music-function (music) (ly:music?)
(add-prefix-to-lyrics "℟. " music))
%% Defining notelaces (neume, melisma) and dedicated context:
gregorianContext = {
\cadenzaOn
\omit Clef
\omit TimeSignature
\omit StaffSymbol
\omit Rest
\omit Flag
\omit Beam
\override SpacingSpanner.packed-spacing = ##t
\override NoteHead.stencil =
#(lambda (grob)
(let ((pos (ly:grob-property grob 'staff-position)))
(cond ((= pos -6)
(grob-interpret-markup grob
#{
\markup
\concat {
\with-dimensions #'(0 . 0) #'(0 . 0)
\translate-scaled #'(-.45 . 0)
\override #'(thickness . 2)
\draw-line #'(1.78 . 0)
\hspace #-.21
\musicglyph "noteheads.s2"
\hspace #-.25
}
#}))
((= pos -7)
(grob-interpret-markup grob
#{
\markup
\concat {
\with-dimensions #'(0 . 0) #'(0 . 0)
\override #'(thickness . 2)
\translate-scaled #'(-.45 . .5)
\draw-line #'(1.78 . 0)
\hspace #-.21
\musicglyph "noteheads.s2"
\hspace #-.25
}
#}))
((= pos -8)
(grob-interpret-markup grob
#{
\markup
\concat {
\with-dimensions #'(0 . 0) #'(0 . 0)
\override #'(thickness . 2)
\translate-scaled #'(-.45 . 1)
\draw-line #'(1.78 . 0)
\with-dimensions #'(0 . 0) #'(0 . 0)
\override #'(thickness . 2)
\translate-scaled #'(-.45 . 0)
\draw-line #'(1.78 . 0)
\hspace #-.21
\musicglyph "noteheads.s2"
\hspace #-.25
}
#}))
(else
(grob-interpret-markup grob
#{
\markup
\concat {
\hspace #-.21
\musicglyph "noteheads.s2"
\hspace #-.25
}
#})))))
\override Accidental.extra-offset = #'(-.2 . 0)
%%% TODO: find a fixed ledger line with no dimension; see
%%% https://lists.gnu.org/archive/html/lilypond-user/2015-02/msg00681.html
%\override LedgerLineSpanner.length-fraction = #'() %%% ???
%\override LedgerLineSpanner.minimum-length-fraction = #'() %%% ???
}
neume = #(define-music-function (mus)
(ly:music?)
#{
\once\override NoteHead.stencil = #(lambda (grob)
(grob-interpret-markup grob
#{
\markup\concat {
\hspace #-2
\score {
\transpose c c' { \omit Stem $mus }
\layout {
indent = 0
ragged-right = ##t
\context {
\Score
\gregorianContext
}
}
}
}
#}))
#})
melisma = #(define-music-function (mus)
(ly:music?)
#{
{
\once\override Lyrics.LyricText.self-alignment-X = #LEFT
\neume { $mus }
\omit Accidental
\omit Dots
#(make-music
'NoteEvent
'pitch
(ly:make-pitch -1 6 0)
'duration
(ly:make-duration 2 0 1))
}
#})
% Declare default layout
\layout {
\context {
\Score
\omit TimeSignature
}
}
%%%%%%%%%%%% end of "modernGregorian.ily" %%%%%%%%%\version "2.24.3"
\language "deutsch"
#(set-global-staff-size 16)
\include "modernGregorian.ily"
\header {
title = ""
}
\paper{
paper-width = 12\cm
paper-height = 20\cm
indent = 0
}
global = {
\key b \major
}
melody = \relative c'' {
\global
\omit Score.TimeSignature
\omit Score.BarLine
\omit Stem
\autoBeamOff
f, c < f g > < a g > a < f f >
}
words = \lyricmode {
Ky -- ri -- e e -- lei -- son.
}
\score {
<<
\new Staff {
\melody
}
\addlyrics { \words }
>>
}Zitat von: harm6 am Sonntag, 26. April 2026, 16:33Zitatder Code ist natürlich von Harm.Hm, da erinnere ich mich nicht dran. Hast du einen link?
Gruß,
Harm
\version "2.24.3"
#(set-global-staff-size 16)
\header {
title = ""
}
\paper{
paper-width = 12\cm
paper-height = 20\cm
indent = 0
}
global = {
\key bes \major
}
melody = \relative c'' {
\global
\omit Score.TimeSignature
\omit Score.BarLine
\omit Stem
\autoBeamOff
f, c f [g] a [g] a f [f]
}
words = \lyricmode {
Ky -- ri -- e e -- lei -- son.
}
\score {
<<
\new Staff { \melody }
\addlyrics { \words }
>>
\layout { \override LyricText #'font-name = #"Nunito Sans" }
\midi { }
}
Zitatder Code ist natürlich von Harm.Hm, da erinnere ich mich nicht dran. Hast du einen link?
Zitat von: ingmar am Samstag, 25. April 2026, 19:54Nur, was du an der Stelle
(let ((elt (ly:music-property mus 'element)))
(fold loop ...
..genau machst, ist mir nicht klar.
ZitatMit wenig Aufwand kannst du aus diesem Code die gewünschten Funktionen basteln.
\version "2.25.80"
musicextrema =
#(define-music-function (mus)(ly:music?)
(let*
(
(alle-pitches
(let loop ((mus mus) (pitches '()))
(let ((p (ly:music-property mus 'pitch)))
(if (ly:pitch? p)
(cons p pitches)
(let ((elt (ly:music-property mus 'element)))
(fold loop
(if (ly:music? elt)
(loop elt pitches)
pitches)
(ly:music-property mus 'elements)))))))
(alle-sortiert (sort alle-pitches ly:pitch<?))
(tief (car alle-sortiert))
(hoch (car (reverse alle-sortiert)))
)
; (display tief )(display hoch)
; (write-me "alle pitches----> " (list? alle-pitches))
(make-music
'SequentialMusic
'elements
(list
(make-music
'NoteEvent
'duration
(ly:make-duration 2)
'pitch
tief)
(make-music
'NoteEvent
'pitch
hoch
'duration
(ly:make-duration 2))))
))
mymus = \relative { c' c c, c,, }
{ \clef bass \musicextrema \mymus }