Hallo miteinander
ich wollte, dank
diesen Post, eine Funktion definieren, mit der ich Hemiolen zeigen kann.
Die Syntax wäre:
\hemiola #1 {c d}{e f}{g a}Jetzt: Mit viel Copy-Paste und viel Schweiss habe ich etwas gebastelt das funktioniert (hat):
(kompiliert nicht)
\version "2.18.2"
\layout {
\context {
\Voice
\consists "Horizontal_bracket_engraver"
}
}
#(define (add-grouping dir note-event)
"Add an NoteGroupingEvent to the articulations of `note-event',
which is supposed to be a NoteEvent expression."
(set! (ly:music-property note-event 'articulations)
(cons (make-music 'NoteGroupingEvent
'span-direction dir)
(ly:music-property note-event 'articulations)))
note-event)
#(define (helper ls1 ls2)
"Add a NoteGroupingEvent with the direction -1 to the first
and one with the direction 1 to the last NoteEvent of
a SequentialMusic expression"
(if (eq? 1 (length ls1))
; wenn ls1 nur noch aus einem element besteht
; Schluss mit der Selbstaufrufung, das Ende von der Klammer
; an die letzte Note hängen und das ganze umdrehen
(reverse (cons (add-grouping 1 (car ls1)) ls2))
(if (null? ls2)
; ls2 ist noch leer, das heißt (car ls1) ist das
; erste Element in der Liste. Start der klammer an die
; Note hängen und weiter
(helper
(cdr ls1)
(cons (add-grouping -1 (car ls1)) ls2))
; (car ls1) ist weder das letzte noch das erste
; Element in der Liste. Nichts verändern und ein
; Element weiter gehen
(helper
(cdr ls1)
(cons (car ls1) ls2)))))
bracketize = #(define-music-function (parser location music) (ly:music?)
(make-music
'SequentialMusic
'elements
(helper (ly:music-property music 'elements) '())))
#(define (add-bracket direction m)
(case (ly:music-property m 'name)
((NoteEvent) (set! (ly:music-property m 'articulations)
(cons (make-music 'TextScriptEvent
'direction
direction
'text
(markup
#:line
(#:path 0.1
(list (list (quote moveto) -1 0)
(list (quote lineto) -0.5 1)
(list (quote lineto) 1.5 1)
(list (quote lineto) 2 0)))))
(ly:music-property m 'articulations)))
m)
((EventChord)(set! (ly:music-property m 'elements)
(cons (make-music 'TextScriptEvent
'direction
direction
'text
(markup
#:line
(#:path 0.1
(list (list (quote moveto) -1 0)
(list (quote lineto) -0.5 1)
(list (quote lineto) 1.5 1)
(list (quote lineto) 2 0)))))
(ly:music-property m 'articulations)))
m)
(else #f)))
hemiola =
#(define-music-function (parser location direction m1 m2 m3) (number? ly:music? ly:music? ly:music?)
#{
\override HorizontalBracket.direction = $direction
#(if (eq? 1 (length (ly:music-property m1 'elements)))
(map-some-music add-bracket direction m1)
#{ \bracketize $m1 #}
)
#(if (eq? 1 (length (ly:music-property m2 'elements)))
(map-some-music add-bracket direction m2)
#{ \bracketize $m2 #}
)
#(if (eq? 1 (length (ly:music-property m3 'elements)))
(map-some-music add-bracket direction m3)
#{ \bracketize $m3 #}
)
\revert HorizontalBracket.direction
#}
)
{
\new Staff {
\hemiola #1 {c} {d c} {c d}
}
}
Der Code ist vielleicht Horror, hat aber funktioniert bis ich in der Prozedur
add-bracket die Direktion der Klammern beeinflussen wollte. Und so kompiliert den Code nicht mehr, ich verstehe aber nicht wieso.
Mit
#(define (add-bracket m)
[...]
#(if (eq? 1 (length (ly:music-property m1 'elements)))
(map-some-music add-bracket m1)
[...]
geht hingegen.
Nur eine Bemerkung: ich musste auch diese
add-bracket schreiben, weil die Klammer funktionieren nur mit mehrere Noten.
Ich hoffe, man versteht, was ich meine.
Ich danke euch für die Hilfe, und wünsche euch einen schönen Abend
Liebe Grüsse
Eugenio