[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fonction pour Ambitus
From: |
Jean Abou Samra |
Subject: |
Re: Fonction pour Ambitus |
Date: |
Mon, 29 Aug 2022 20:02:15 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 |
Le 28/08/2022 à 12:45, Ya Gloops a écrit :
Et dernière petite chose!
Si il n'y à qu'une note ou seulement un unisson, n'afficher qu'une note au lieu
de deux...
J'étais déjà surpris de l'ambitus à deux notes, je suis encore plus surpris
de l'ambitus unisson, mais pourquoi pas après tout…
Voilà une version qui le fait. J'ai aussi corrigé des problèmes avec les
altérations.
Cordialement,
Jean
\version "2.23.12"
\layout {
#(use-modules (ice-9 match)
(srfi srfi-1))
\context {
\Staff
\override Ambitus.before-line-breaking =
#(lambda (grob)
(let* ((elts (ly:grob-array->list (ly:grob-object grob
'elements)))
(heads (filter (lambda (g)
(grob::has-interface g
'note-head-interface))
elts)))
(match heads
(()
#f)
((head1 head2)
(let* ((p1 (ly:grob-property head1 'staff-position))
(p2 (ly:grob-property head2 'staff-position))
(diff (abs (- p1 p2))))
(case diff
((0)
(ly:grob-suicide! head2)
(for-each
(lambda (g)
(when (and (grob::has-interface g
'accidental-interface)
(eq? head2 (ly:grob-parent g Y)))
(ly:grob-suicide! g)
(let ((placement (find (lambda (h)
(grob::has-interface h 'accidental-placement-interface))
elts)))
(when placement
(let* ((accidental-grobs (ly:grob-object
placement 'accidental-grobs))
(filtered (map (lambda (entry)
(cons (car entry)
(delete g
(cdr entry))))
accidental-grobs)))
(ly:grob-set-object! placement
'accidental-grobs filtered)))))
(when (eq? 'AmbitusLine (grob::name g))
(ly:grob-suicide! g)))
elts))
((1)
(let* ((head-up (if (< p1 p2)
head2
head1))
(ext (ly:grob-extent head-up head-up X))
(len (interval-length ext)))
(ly:grob-translate-axis! head-up len X)))))))))
}
}
\layout {
\context {
\Staff
\consists Ambitus_engraver
}
}
{ s }
{ c' }
{ cis' }
{ c' d' }
{ cis' dis' }
{ c' c'' }
{ cis' cis'' }