Re: Vertically align objects of same class?
Am Sonntag, 21. Juli 2024, 08:12:07 MESZ schrieb Fennel: > Valentino, > > Your function seems to not work for polyphonic passages as in the example > below. Is there a fix for the function, would using \voiceOne and \voiceTwo > explicitly for this polyphonic context make a difference? > Hello Fennel, the issue here is that Horizontal Brackets require NoteHeads, and in your case there are none (the Brackets would not be printed in any case). If you want to use them in this case, add the engraver to the Staff context instead. But then also your polyphonic structure is a mess (your group definition is outside of the << ... >>, so it comes only after the notes). Finally there is some issue with order, so I‘ve adjusted the engraver slightly: \version "2.24.3" #(define (outside-staff-collecting-engraver context) (let* ((span_up #f) (span_down #f) (elts '())) (make-engraver ((initialize engraver) (set! span_up (ly:engraver-make-grob engraver 'TextSpanner '())) (ly:grob-set-property! span_up 'transparent #t) (ly:grob-set-property! span_up 'direction UP) (set! span_down (ly:engraver-make-grob engraver 'TextSpanner '())) (ly:grob-set-property! span_down 'transparent #t) (ly:grob-set-property! span_down 'direction DOWN)) (acknowledgers ((outside-staff-interface engraver grob source-engraver) (set! elts (cons grob elts ((process-acknowledged engraver) (for-each (lambda (grob) (if (assoc-get 'align (ly:grob-property grob 'details)) (let* ((d (ly:grob-property grob 'direction)) (span (if (= d UP) span_up span_down))) (display grob) (display (ly:spanner-bound grob LEFT)) (ly:grob-set-parent! grob Y span) (if (null? (ly:spanner-bound span LEFT)) (ly:spanner-set-bound! span LEFT (if (ly:spanner? grob) (ly:spanner-bound grob LEFT) grob))) (ly:spanner-set-bound! span RIGHT (if (ly:spanner? grob) (ly:spanner-bound grob LEFT) grob)) (ly:grob-set-property! grob 'outside-staff-priority #f) (ly:grob-set-property! grob 'Y-offset 0 elts) (set! elts '()) \layout { \context { \Staff \consists #outside-staff-collecting-engraver \consists Horizontal_bracket_engraver \override HorizontalBracket.direction = #UP } \context { \Voice \remove Horizontal_bracket_engraver } } \relative c { \override Staff.HorizontalBracket.details.align = ##t << << { c\startTextSpan c c c\stopTextSpan | } \\ { g g g g | } \\ { a a a a } >> { s\startGroup s s s\stopGroup } >> } signature.asc Description: This is a digitally signed message part.
Re: Vertically align objects of same class?
On Fri, 26 Jul 2024 at 02:11, Fennel wrote: > > Setting staff-affinity = #DOWN should mean that the brackets appear above the staff instead of below, right? Hello, staff-affinity is used for spacing purposes. Use alignAboveContext, as explained in NR 5.1.7 Context layout order https://lilypond.org/doc/v2.24/Documentation/notation/context-layout-order Kind regards, Xavier
Re: Vertically align objects of same class?
Any ideas as to why the staff-affinity option is being ignored here? \layout { \context { \Dynamics \consists Horizontal_bracket_engraver \override HorizontalBracket.direction = #UP \consists Note_heads_engraver \consists Rhythmic_column_engraver \override NoteHead.stencil = #(ly:make-stencil '() '(0 . 0) '(0 . 0)) } } brackets = \new Dynamics { \override VerticalAxisGroup.staff-affinity = #DOWN c4 c\startGroup c c\stopGroup | c\startGroup c c\stopGroup c } Produced output: [image.png] Setting staff-affinity = #DOWN should mean that the brackets appear above the staff instead of below, right? -Fennel
Re: Vertically align objects of same class?
Valentino, Your function seems to not work for polyphonic passages as in the example below. Is there a fix for the function, would using \voiceOne and \voiceTwo explicitly for this polyphonic context make a difference? \version "2.24.3" #(define (outside-staff-collecting-engraver context) (let* ((span_up #f) (span_down #f)) (make-engraver ((initialize engraver) (set! span_up (ly:engraver-make-grob engraver 'TextSpanner '())) (ly:grob-set-property! span_up 'transparent #t) (ly:grob-set-property! span_up 'direction UP) (set! span_down (ly:engraver-make-grob engraver 'TextSpanner '())) (ly:grob-set-property! span_down 'transparent #t) (ly:grob-set-property! span_down 'direction DOWN)) (acknowledgers ((outside-staff-interface engraver grob source-engraver) (if (assoc-get 'align (ly:grob-property grob 'details)) (let* ((d (ly:grob-property grob 'direction)) (span (if (= d UP) span_up span_down))) (ly:grob-set-parent! grob Y span) (if (null? (ly:spanner-bound span LEFT)) (ly:spanner-set-bound! span LEFT (if (ly:spanner? grob) (ly:spanner-bound grob LEFT) grob))) (ly:spanner-set-bound! span RIGHT (if (ly:spanner? grob) (ly:spanner-bound grob LEFT) grob)) (ly:grob-set-property! grob 'outside-staff-priority #f) (ly:grob-set-property! grob 'Y-offset 0 \layout { \context { \Staff \consists #outside-staff-collecting-engraver } \context { \Voice \consists Horizontal_bracket_engraver \override HorizontalBracket.direction = #UP } } \relative c { \override HorizontalBracket.details.align = ##t << { << { c\startTextSpan c c c\stopTextSpan | } \\ { g g g g | } a a a a >> } >> { s\startGroup s s s\stopGroup | s s s s } } -Fennel
Re: Vertically align objects of same class?
> So what you’d > need to do is to replace the skips by notes: > > brackets = \new Dynamics { > \override VerticalAxisGroup.staff-affinity = #DOWN > c4 c\startGroup c c\stopGroup | c\startGroup c c\stopGroup c > } > > Then this will still not work, as the Dynamics context does not create any > NoteColumns by default. So you’ll need to add Rhythmic_column_engraver. But to > actually have something to encompass you’d need to have a stencils, so you’d > need to also add the Note_heads_engraver. > > Then you’d need to get rid of the note heads, but you still need a stencil, so > do something like > > \layout { > \context { > \Dynamics > \consists Horizontal_bracket_engraver > \override HorizontalBracket.direction = #UP > \consists Note_heads_engraver > \consists Rhythmic_column_engraver > > \override NoteHead.stencil = #(ly:make-stencil '() '(0 . 0) '(0 . 0)) > } > > } This snippet gives the following output: [image.png]It seems that the staff-affinity option is being ignored? -Fennel >
Re: Vertically align objects of same class?
Adapting my previous code to work with spanners: % #(define (outside-staff-collecting-engraver context) (let* ((span_up #f) (span_down #f)) (make-engraver ((initialize engraver) (set! span_up (ly:engraver-make-grob engraver 'TextSpanner '())) (ly:grob-set-property! span_up 'transparent #t) (ly:grob-set-property! span_up 'direction UP) (set! span_down (ly:engraver-make-grob engraver 'TextSpanner '())) (ly:grob-set-property! span_down 'transparent #t) (ly:grob-set-property! span_down 'direction DOWN)) (acknowledgers ((outside-staff-interface engraver grob source-engraver) (if (assoc-get 'align (ly:grob-property grob 'details)) (let* ((d (ly:grob-property grob 'direction)) (span (if (= d UP) span_up span_down))) (ly:grob-set-parent! grob Y span) (if (null? (ly:spanner-bound span LEFT)) (ly:spanner-set-bound! span LEFT (if (ly:spanner? grob) (ly:spanner-bound grob LEFT) grob))) (ly:spanner-set-bound! span RIGHT (if (ly:spanner? grob) (ly:spanner-bound grob LEFT) grob)) (ly:grob-set-property! grob 'outside-staff-priority #f) (ly:grob-set-property! grob 'Y-offset 0 \layout { \context { \Staff \consists #outside-staff-collecting-engraver } \context { \Voice \consists Horizontal_bracket_engraver \override HorizontalBracket.direction = #UP } } \new Voice \relative c'' { << { \repeat unfold 4 {c4} \repeat unfold 4 {c'4} } { s4 s\startGroup s s\stopGroup | s\startGroup s s\stopGroup s } >> } \new Voice \relative c'' { \override HorizontalBracket.details.align = ##t << { \repeat unfold 4 {c4} \repeat unfold 4 {c'4} } { s4 s\startGroup s s\stopGroup | s\startGroup s s\stopGroup s } >> } % Cheers, Valentin Am Montag, 15. Juli 2024, 06:34:18 MESZ schrieb Fennel: > Per-system vertical alignment of all horizontal brackets is the goal. This > can almost be achieved by adjusting the staff padding property (to a value > large enough that no other objects will interfere with the brackets), but > then we have the problem of the brackets being too far off of the staff for > almost every system. > > I’ll take a look at what you suggested, Valentin. Hopefully it works for > what I need! > > -Fennel > > signature.asc Description: This is a digitally signed message part.
Re: Vertically align objects of same class?
Per-system vertical alignment of all horizontal brackets is the goal. This can almost be achieved by adjusting the staff padding property (to a value large enough that no other objects will interfere with the brackets), but then we have the problem of the brackets being too far off of the staff for almost every system. I’ll take a look at what you suggested, Valentin. Hopefully it works for what I need! -Fennel
Re: Vertically align objects of same class?
Hello Fennel, That will not work out easily. The horizontal bracket, meaning it is printed to encompass certain NoteColumns. But you are not even creating notes, but simply skipping. Thus there are no NoteColumns to encompass. So what you’d need to do is to replace the skips by notes: brackets = \new Dynamics { \override VerticalAxisGroup.staff-affinity = #DOWN c4 c\startGroup c c\stopGroup | c\startGroup c c\stopGroup c } Then this will still not work, as the Dynamics context does not create any NoteColumns by default. So you’ll need to add Rhythmic_column_engraver. But to actually have something to encompass you’d need to have a stencils, so you’d need to also add the Note_heads_engraver. Then you’d need to get rid of the note heads, but you still need a stencil, so do something like \layout { \context { \Dynamics \consists Horizontal_bracket_engraver \override HorizontalBracket.direction = #UP \consists Note_heads_engraver \consists Rhythmic_column_engraver \override NoteHead.stencil = #(ly:make-stencil '() '(0 . 0) '(0 . 0)) } } But then I’m curious of what you actually want to get from adding analysis brackets to a Dynamics context? Cheers, Valentin Am Sonntag, 14. Juli 2024, 17:23:21 MESZ schrieb Fennel: > The dynamics context seems to work well enough for text markup objects. I’d > also like to throw a lot of analysis brackets into a Dynamics context above > the staff with similar output. Here’s what I would imagine working > > \version "2.24.3" > > \layout { > \context { > \Voice % Or \Dynamics ? There's no mention of a dynamics context on the > relevant doc page. \consists Horizontal_bracket_engraver > \override HorizontalBracket.direction = #UP > > } > } > > music = \context Staff \relative c'' { > \repeat unfold 8 {c4} > } > > brackets = \context Dynamics { > \override VerticalAxisGroup.staff-affinity = #DOWN > s4 s\startGroup s s\stopGroup | s\startGroup s s\stopGroup s > } > > \score { << \music \brackets >> } > > [image.png] > > This snippet fails to engrave the analysis brackets, as shown. Is it > possible to do so? > > -Fennel > > signature.asc Description: This is a digitally signed message part.
Re: Vertically align objects of same class?
The dynamics context seems to work well enough for text markup objects. I’d also like to throw a lot of analysis brackets into a Dynamics context above the staff with similar output. Here’s what I would imagine working \version "2.24.3" \layout { \context { \Voice % Or \Dynamics ? There's no mention of a dynamics context on the relevant doc page. \consists Horizontal_bracket_engraver \override HorizontalBracket.direction = #UP } } music = \context Staff \relative c'' { \repeat unfold 8 {c4} } brackets = \context Dynamics { \override VerticalAxisGroup.staff-affinity = #DOWN s4 s\startGroup s s\stopGroup | s\startGroup s s\stopGroup s } \score { << \music \brackets >> } [image.png] This snippet fails to engrave the analysis brackets, as shown. Is it possible to do so? -Fennel
Re: Vertically align objects of same class?
Hello Werner, hello Fennel, > As far as I can see, LilyPond doesn't provide a 'container line' as > you imagine. I'm quite sure that this can be programmed in Scheme, > but someone™ has to do that... But maybe a different, simpler > solution can be found; let's see what other guys come up with. In fact we can do this with quite little effort: % #(define (outside-staff-collecting-engraver context) (let* ((span_up #f) (span_down #f)) (make-engraver ((initialize engraver) (set! span_up (ly:engraver-make-grob engraver 'TextSpanner '())) (ly:grob-set-property! span_up 'transparent #t) (ly:grob-set-property! span_up 'direction UP) (set! span_down (ly:engraver-make-grob engraver 'TextSpanner '())) (ly:grob-set-property! span_down 'transparent #t) (ly:grob-set-property! span_down 'direction DOWN)) (acknowledgers ((outside-staff-interface engraver grob source-engraver) (display grob) (if (assoc-get 'align (ly:grob-property grob 'details)) (let* ((d (ly:grob-property grob 'direction)) (span (if (= d UP) span_up span_down))) (ly:grob-set-parent! grob Y span) (if (null? (ly:spanner-bound span LEFT)) (ly:spanner-set-bound! span LEFT grob)) (ly:spanner-set-bound! span RIGHT grob) (ly:grob-set-property! grob 'outside-staff-priority #f) (ly:grob-set-property! grob 'Y-offset 0 \layout { \context { \Staff \consists #outside-staff-collecting-engraver } } \relative c'' { \override TextScript.details.align = ##t c_"I"^"a" c'_"II"^^ c,,_"III"^+ c'_"IV"^"d"\break g_"A"^"e" g'_"B"^"f" g,,_"C"^"g" g'_"D"^"h" } \relative c'' { \override TextScript.details.align = ##t \override Script.details.align = ##t c_"I"^"a" c'_"II"^^ c,,_"III"^+ c'_"IV"^"d"\break g_"A"^"e" g'_"B"^"f" g,,_"C"^"g" g'_"D"^"h" } % This will create an invisible TextSpanner above and below the staff and set Y parent of oos grobs with details.align set to #t to the spanner corresponding with it’s direction. Cheers, Valentin signature.asc Description: This is a digitally signed message part.
Re: Vertically align objects of same class?
Hi Fennel, > I wonder if this is hackable if I just duplicate the current staff context as > a dynamic context and then remove all of the markup objects from the staff > context… I wouldn’t call that “hacking”… that’s simply using contexts to display different grobs. %%% SNIPPET BEGINS \version "2.25.11" \paper { system-system-spacing.padding = #6 } music = \relative c'' { c_"I" c'_"II" c,,_"III" c'_"IV"\break g_"A" g'_"B" c,,,_"C" g'_"D" } << \new Staff \with { \omit TextScript } \music \new Dynamics \with { \override TextScript.font-shape = #'upright \override TextScript.padding = #0 \override TextScript.staff-padding = #0 \override VerticalAxisGroup.staff-affinity = #UP \override VerticalAxisGroup.nonstaff-relatedstaff-spacing.padding = #0.5 \override VerticalAxisGroup.nonstaff-relatedstaff-spacing.minimum-distance = #0 } \music >> %%% SNIPPET ENDS Cheers, Kieren. __ My work day may look different than your work day. Please do not feel obligated to read or respond to this email outside of your normal working hours.
Re: Vertically align objects of same class?
> Knute, to your point I think that the Dynamics context, while > slightly better than lyricMode for this use case still has a similar > issue given that the project I'm working on is of considerable size > and would require a significant refactor. Feasible but I'd like to > avoid doing this if at all possible. > > Werner, it seems like I'd have to do trial and error to figure out > what the minimum viable staff-padding is for each line and then set > it each time. If I calibrate it once for the most extreme staff (the > second in the given example), then there will be quite a bit of > excess space between the first staff and the line of markup objects. As far as I can see, LilyPond doesn't provide a 'container line' as you imagine. I'm quite sure that this can be programmed in Scheme, but someone™ has to do that... But maybe a different, simpler solution can be found; let's see what other guys come up with. Werner
RE: Vertically align objects of same class?
Fennel, I am not converse in “hacking” so I suggest you attempt it. Mark From: Fennel Sent: Tuesday, June 25, 2024 10:31 AM To: carsonm...@ca.rr.com Cc: lilypond-user@gnu.org Subject: RE: Vertically align objects of same class? I wonder if this is hackable if I just duplicate the current staff context as a dynamic context and then remove all of the markup objects from the staff context… ~Fennel On Tuesday, June 25th, 2024 at 12:52 PM, carsonm...@ca.rr.com <mailto:carsonm...@ca.rr.com> mailto:carsonm...@ca.rr.com> > wrote: Fennel, Go to: https://lilypond.org/doc/v2.24/Documentation/notation/expressive-marks-attached-to-notes#dynamics And scroll down to “A dynamics context”. Mark From: lilypond-user-bounces+carsonmark=ca.rr@gnu.org <mailto:lilypond-user-bounces+carsonmark=ca.rr@gnu.org> mailto:lilypond-user-bounces+carsonmark=ca.rr@gnu.org> > On Behalf Of Fennel Sent: Tuesday, June 25, 2024 9:06 AM To: Lilypond-User Mailing List mailto:lilypond-user@gnu.org> > Subject: Vertically align objects of same class? I have a bunch of objects of the same type that I’d like to all be aligned to the same Y-level on a per staff basis. Here’s an example: \version "2.24.3" \relative c'' { c_"I" c'_"II" c,,_"III" c'_"IV"\break g_"A" g'_"B" g,,_"C" g'_"D" } I would like for all of the markup objects on each staff to align with the lowest default placement, so in this example in the first staff all text would vertically align with the “III” and in the second staff all test would vertically align with the “C”. I know that lyricMode would work well in this example, but I would also like to do the same thing with HorizontalBrackets and I’m mainly using this for string indications which do not appear on every note, making lyricmode somewhat of a pain to use in this scenario. -Fennel
RE: Vertically align objects of same class?
I wonder if this is hackable if I just duplicate the current staff context as a dynamic context and then remove all of the markup objects from the staff context… ~Fennel On Tuesday, June 25th, 2024 at 12:52 PM, carsonm...@ca.rr.com wrote: > Fennel, > > Go to: > https://lilypond.org/doc/v2.24/Documentation/notation/expressive-marks-attached-to-notes#dynamics > > And scroll down to “A dynamics context”. > > Mark > > From: lilypond-user-bounces+carsonmark=ca.rr@gnu.org > On Behalf Of Fennel > Sent: Tuesday, June 25, 2024 9:06 AM > To: Lilypond-User Mailing List > Subject: Vertically align objects of same class? > > I have a bunch of objects of the same type that I’d like to all be aligned to > the same Y-level on a per staff basis. > > Here’s an example: > > \version "2.24.3" > > \relative c'' { > > c_"I" c'_"II" c,,_"III" c'_"IV"\break > > g_"A" g'_"B" g,,_"C" g'_"D" > > } > > I would like for all of the markup objects on each staff to align with the > lowest default placement, so in this example in the first staff all text > would vertically align with the “III” and in the second staff all test would > vertically align with the “C”. I know that lyricMode would work well in this > example, but I would also like to do the same thing with HorizontalBrackets > and I’m mainly using this for string indications which do not appear on every > note, making lyricmode somewhat of a pain to use in this scenario. > > -Fennel > >
RE: Vertically align objects of same class?
Fennel, Go to: https://lilypond.org/doc/v2.24/Documentation/notation/expressive-marks-attached-to-notes#dynamics And scroll down to “A dynamics context”. Mark From: lilypond-user-bounces+carsonmark=ca.rr@gnu.org On Behalf Of Fennel Sent: Tuesday, June 25, 2024 9:06 AM To: Lilypond-User Mailing List Subject: Vertically align objects of same class? I have a bunch of objects of the same type that I’d like to all be aligned to the same Y-level on a per staff basis. Here’s an example: \version "2.24.3" \relative c'' { c_"I" c'_"II" c,,_"III" c'_"IV"\break g_"A" g'_"B" g,,_"C" g'_"D" } I would like for all of the markup objects on each staff to align with the lowest default placement, so in this example in the first staff all text would vertically align with the “III” and in the second staff all test would vertically align with the “C”. I know that lyricMode would work well in this example, but I would also like to do the same thing with HorizontalBrackets and I’m mainly using this for string indications which do not appear on every note, making lyricmode somewhat of a pain to use in this scenario. -Fennel
Re: Vertically align objects of same class?
Knute, to your point I think that the Dynamics context, while slightly better than lyricMode for this use case still has a similar issue given that the project I'm working on is of considerable size and would require a significant refactor. Feasible but I'd like to avoid doing this if at all possible. Werner, it seems like I'd have to do trial and error to figure out what the minimum viable staff-padding is for each line and then set it each time. If I calibrate it once for the most extreme staff (the second in the given example), then there will be quite a bit of excess space between the first staff and the line of markup objects. Any change to other objects on the staff after the initial per-staff calibration would also require another calibration of the staff-specific padding value. Is there a way to query the maximum extent of a staff/calculate what the value of the staff padding should be such that all of the objects are vertically aligned? ~Fennel
Re: Vertically align objects of same class?
> I have a bunch of objects of the same type that I’d like to all be > aligned to the same Y-level on a per staff basis. Increase the `staff-padding` property. Werner
Re: Vertically align objects of same class?
On Tue, Jun 25, 2024 at 9:07 AM Fennel wrote: > I have a bunch of objects of the same type that I’d like to all be aligned > to the same Y-level on a per staff basis > I would use a Dynamics context for this, but perhaps that's what you meant when you said you didn't want to use lyricsMode. %%% \version "2.24.3" music = \relative c'' { c4 c' c,, c'\break g g' g,, g' } text = { s4_"I" s_"II" s_"III" s_"IV" s_"A" s_"B" s_"C" s_"D" } << \new Staff \music \new Dynamics \text >> %%% -- Knute Snortum
Vertically align objects of same class?
I have a bunch of objects of the same type that I’d like to all be aligned to the same Y-level on a per staff basis. Here’s an example: \version "2.24.3" \relative c'' { c_"I" c'_"II" c,,_"III" c'_"IV"\break g_"A" g'_"B" g,,_"C" g'_"D" } I would like for all of the markup objects on each staff to align with the lowest default placement, so in this example in the first staff all text would vertically align with the “III” and in the second staff all test would vertically align with the “C”. I know that lyricMode would work well in this example, but I would also like to do the same thing with HorizontalBrackets and I’m mainly using this for string indications which do not appear on every note, making lyricmode somewhat of a pain to use in this scenario. -Fennel