Alternative small note in brackets?

2024-08-04 Thread Alasdair McAndrew
Hello,

I have a situation where the main note is below the stave, and an
alternative note is provided, an octave higher, which is in the stave.
This alternative note has a small note head which is in (square) brackets,
and its stem is in the same direction (up) as the main note.  The stem of
the alternative note is just to the left of the stem of the main note.

I can get a reasonable effect using CueVoice, except that the
alternative stem is to the right of the main stem, and I get a warning
about needing a "\voiceXx or \shiftXx setting".  But I can't get this
alternative note in brackets: experiments with \parenthesize have so far
not worked.

Here's what I have for these notes (this is in bass clef):

<< {b,} \new CueVoice {<\parenthesize b'4>} >>

So I have these questions:

1.  How can I most easily move the cue note to the left?
2.  How can I get square brackets around the cue note, and slightly larger
and more spaced out, so as to be easier to see?

Many thanks,
Alasdair

-- 
Alasdair McAndrew (he/him)
mob: 0432 854 858

https://numbersandshapes.net


Re: Alternative small note in brackets?

2024-08-04 Thread Knute Snortum
On Sun, Aug 4, 2024 at 7:33 AM Alasdair McAndrew  wrote:

> Hello,
>
> I have a situation where the main note is below the stave, and an
> alternative note is provided, an octave higher, which is in the stave.
> This alternative note has a small note head which is in (square) brackets,
> and its stem is in the same direction (up) as the main note.  The stem of
> the alternative note is just to the left of the stem of the main note.
>
> I can get a reasonable effect using CueVoice, except that the
> alternative stem is to the right of the main stem, and I get a warning
> about needing a "\voiceXx or \shiftXx setting".  But I can't get this
> alternative note in brackets: experiments with \parenthesize have so far
> not worked.
>
> Here's what I have for these notes (this is in bass clef):
>
> << {b,} \new CueVoice {<\parenthesize b'4>} >>
>
> So I have these questions:
>
> 1.  How can I most easily move the cue note to the left?
> 2.  How can I get square brackets around the cue note, and slightly larger
> and more spaced out, so as to be easier to see?
>

You might start with overriding the notehead font size:

\version "2.24.4"

% small note head
snh = \single \override NoteHead.font-size = -2 \etc

{
  4
}


--
Knute Snortum


Cross-Staff stems with note collisions

2024-08-04 Thread Valentin Petzel
Hello,

Cross-staff stems do currently work by simply connecting to any stem that is on 
the correct side and matches the positions. This often does not work out when 
we have shifted note columns due to collision. In such cases we’d need to do 
manual positioning. So I’ve written a small engraver that matches positions of 
stems. This way we can tell Lilypond: Place this note column in such a way 
that the stems can be connected.

Cheers,
Valentin#(define (match-stem-engraver context)
   (let ((stems '()) (roots '()))
 (make-engraver
  (acknowledgers
   ((stem-interface engraver grob source-engraver)
(let* ((det (ly:grob-property grob 'details))
   (stem-id (assoc-get 'stem-id det #f))
   (root (assoc-get 'is-root det #f)))
  (if stem-id
  (if root
  (set! roots (assoc-set! roots stem-id grob))
  (set! stems (assoc-set! stems stem-id
  (cons grob (assoc-get stem-id stems '())
  ((process-acknowledged engraver)
   (for-each
(lambda (pair)
  (let ((id (car pair))
(root (cdr pair)))
(for-each
 (lambda (stem)
   (ly:grob-set-parent! (ly:grob-parent stem X) X (ly:grob-parent root X))
   (ly:grob-set-property! (ly:grob-parent stem X) 'X-offset
  (- (ly:grob-property root 'X-offset)
 (ly:grob-property stem 'X-offset)))
   (ly:grob-set-property! (ly:grob-parent stem X) 'ignore-collision #t)
   )
 (assoc-get id stems '()
roots)
   (set! roots '())
   (set! stems '())

\layout {
  \context {
\PianoStaff
\consists "Span_stem_engraver"
  }
}

\new PianoStaff <<
  \new Staff <<
 \\ e'
  >>
  \new Staff {
\clef bass
<< \crossStaff g \\ c >>
  }
>>

\new PianoStaff \with {
  \consists #match-stem-engraver
} <<
  \new Staff <<
{
  \override Stem.details.stem-id = #'A \override Stem.details.is-root = ##t
  
}
\\
e'
  >>
  \new Staff {
\clef bass
<<
  {
\override Stem.details.stem-id = #'A
\crossStaff g
  }
  \\
  c
>>
  }
>>


signature.asc
Description: This is a digitally signed message part.


Re: Vertically align objects of same class?

2024-08-04 Thread Valentin Petzel
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: Alternative small note in brackets?

2024-08-04 Thread Valentin Petzel
How about this:

\new Staff <<
  {b,}
  \new CueVoice {
\shiftOff\stemUp
\override Parentheses.font-size = #2
\override Parentheses.stencils =
#(lambda (grob)
   (list (grob-interpret-markup grob (markup #:vcenter #:center-align 
#:bold "["))
 (grob-interpret-markup grob (markup #:vcenter #:center-align 
#:bold "]"
\parenthesize b'
  }
>>


Cheers,
Valentin

Am Sonntag, 4. August 2024, 16:31:48 MESZ schrieb Alasdair McAndrew:
> Hello,
> 
> I have a situation where the main note is below the stave, and an
> alternative note is provided, an octave higher, which is in the stave.
> This alternative note has a small note head which is in (square) brackets,
> and its stem is in the same direction (up) as the main note.  The stem of
> the alternative note is just to the left of the stem of the main note.
> 
> I can get a reasonable effect using CueVoice, except that the
> alternative stem is to the right of the main stem, and I get a warning
> about needing a "\voiceXx or \shiftXx setting".  But I can't get this
> alternative note in brackets: experiments with \parenthesize have so far
> not worked.
> 
> Here's what I have for these notes (this is in bass clef):
> 
> << {b,} \new CueVoice {<\parenthesize b'4>} >>
> 
> So I have these questions:
> 
> 1.  How can I most easily move the cue note to the left?
> 2.  How can I get square brackets around the cue note, and slightly larger
> and more spaced out, so as to be easier to see?
> 
> Many thanks,
> Alasdair



signature.asc
Description: This is a digitally signed message part.


Re: Alternative small note in brackets?

2024-08-04 Thread Alasdair McAndrew
Hi Valentin,

Many thanks indeed - that's a much more involved and complex solution than
I could ever have worked out for myself.  It looks like the sort of thing
that would be best incorporated in a function, called something like, say
"bracketise", which can then be easily called in the score as " \bracketise
b' ".  I'll go back through my scores to see if I can re-teach myself how
to write, and use, a function.

Thanks again!

Cheers,
Alasdair

On Mon, 5 Aug 2024 at 09:38, Valentin Petzel  wrote:

> How about this:
>
> \new Staff <<
>   {b,}
>   \new CueVoice {
> \shiftOff\stemUp
> \override Parentheses.font-size = #2
> \override Parentheses.stencils =
> #(lambda (grob)
>(list (grob-interpret-markup grob (markup #:vcenter #:center-align
> #:bold "["))
>  (grob-interpret-markup grob (markup #:vcenter #:center-align
> #:bold "]"
> \parenthesize b'
>   }
> >>
>
>
> Cheers,
> Valentin
>
> Am Sonntag, 4. August 2024, 16:31:48 MESZ schrieb Alasdair McAndrew:
> > Hello,
> >
> > I have a situation where the main note is below the stave, and an
> > alternative note is provided, an octave higher, which is in the stave.
> > This alternative note has a small note head which is in (square)
> brackets,
> > and its stem is in the same direction (up) as the main note.  The stem of
> > the alternative note is just to the left of the stem of the main note.
> >
> > I can get a reasonable effect using CueVoice, except that the
> > alternative stem is to the right of the main stem, and I get a warning
> > about needing a "\voiceXx or \shiftXx setting".  But I can't get this
> > alternative note in brackets: experiments with \parenthesize have so far
> > not worked.
> >
> > Here's what I have for these notes (this is in bass clef):
> >
> > << {b,} \new CueVoice {<\parenthesize b'4>} >>
> >
> > So I have these questions:
> >
> > 1.  How can I most easily move the cue note to the left?
> > 2.  How can I get square brackets around the cue note, and slightly
> larger
> > and more spaced out, so as to be easier to see?
> >
> > Many thanks,
> > Alasdair
>
>

-- 
Alasdair McAndrew (he/him)
mob: 0432 854 858

https://numbersandshapes.net