Re: \tocItem within \score block, using header properties

2022-12-06 Thread Jean Abou Samra



Le 06/12/2022 à 19:05, Jean Abou Samra a écrit :

Le 06/12/2022 à 18:10, Joel C. Salomon a écrit :

The requirement that `\tocItem` is either outside the `\score` block
or within a music variable is making it awkward for me to keep it near
where the score `\header` block defines the piece title.  And I have
entirely failed to figure out a way to re-use the piece title.

Minimal example below, showing different ways I've tried.

Is there a cleaner way to accomplish this?





Try

\version "2.23.82"

upperI = \relative c' {
  c4 d e f
}
lowerI = \relative c {\clef bass f e d c }

scoreI =
\score {
  \header {
    piece = "Piece Title"
  }
  <<
    \new Devnull { \tocItem \markup "Piece Title" }
    \new PianoStaff <<
  \new Staff = "upper" \upperI
  \new Staff = "lower" \lowerI
    >>
  >>
}

\book {
  \markuplist \table-of-contents
  \scoreI
}



A \tocItem needs a bottom context to be interpreted,
like a Voice, Dynamics, TabVoice or such. In this case,
you don't want anything to be printed from it, so you
can use this lesser known context type Devnull. Some
people do it with a Dynamics as well. Devnull works
with everything you might want to take out of the
individual parts: \time, \tempo, \mark, etc.

For not repeating the title between \header and \tocItem,
you could try this approach:


\version "2.23.82"

withPiece =
#(define-scheme-function (mkup score) (markup? ly:score?)
   (let* ((music (ly:score-music score))
  (n (display-scheme-music music))



Sorry, the line above was for debugging, you can remove it.



(new-music #{ { \new Devnull \tocItem #mkup #music } #})
  (new-score (ly:make-score new-music))
  (header (let ((h (ly:score-header score)))
    (if (null? h)
    (make-module)
    h
 (for-each (lambda (odef)
 (ly:score-add-output-def! new-score odef))
   (ly:score-output-defs score))
 (module-define! header 'piece mkup)
 (ly:score-set-header! new-score header)
 new-score))

upperI = \relative c' {
  c4 d e f
}
lowerI = \relative c {\clef bass f e d c }

scoreI =
\withPiece \markup "Piece Title" \score {
  \new PianoStaff <<
    \new Staff = "upper" \upperI
    \new Staff = "lower" \lowerI
  >>
}

\book {
  \markuplist \table-of-contents
  \scoreI
}


Best,
Jean






OpenPGP_signature
Description: OpenPGP digital signature


Re: \tocItem within \score block, using header properties

2022-12-06 Thread Jean Abou Samra

Le 06/12/2022 à 18:10, Joel C. Salomon a écrit :

The requirement that `\tocItem` is either outside the `\score` block
or within a music variable is making it awkward for me to keep it near
where the score `\header` block defines the piece title.  And I have
entirely failed to figure out a way to re-use the piece title.

Minimal example below, showing different ways I've tried.

Is there a cleaner way to accomplish this?





Try

\version "2.23.82"

upperI = \relative c' {
  c4 d e f
}
lowerI = \relative c {\clef bass f e d c }

scoreI =
\score {
  \header {
    piece = "Piece Title"
  }
  <<
    \new Devnull { \tocItem \markup "Piece Title" }
    \new PianoStaff <<
  \new Staff = "upper" \upperI
  \new Staff = "lower" \lowerI
    >>
  >>
}

\book {
  \markuplist \table-of-contents
  \scoreI
}



A \tocItem needs a bottom context to be interpreted,
like a Voice, Dynamics, TabVoice or such. In this case,
you don't want anything to be printed from it, so you
can use this lesser known context type Devnull. Some
people do it with a Dynamics as well. Devnull works
with everything you might want to take out of the
individual parts: \time, \tempo, \mark, etc.

For not repeating the title between \header and \tocItem,
you could try this approach:


\version "2.23.82"

withPiece =
#(define-scheme-function (mkup score) (markup? ly:score?)
   (let* ((music (ly:score-music score))
  (n (display-scheme-music music))
  (new-music #{ { \new Devnull \tocItem #mkup #music } #})
  (new-score (ly:make-score new-music))
  (header (let ((h (ly:score-header score)))
    (if (null? h)
    (make-module)
    h
 (for-each (lambda (odef)
 (ly:score-add-output-def! new-score odef))
   (ly:score-output-defs score))
 (module-define! header 'piece mkup)
 (ly:score-set-header! new-score header)
 new-score))

upperI = \relative c' {
  c4 d e f
}
lowerI = \relative c {\clef bass f e d c }

scoreI =
\withPiece \markup "Piece Title" \score {
  \new PianoStaff <<
    \new Staff = "upper" \upperI
    \new Staff = "lower" \lowerI
  >>
}

\book {
  \markuplist \table-of-contents
  \scoreI
}


Best,
Jean




OpenPGP_signature
Description: OpenPGP digital signature


Parallel music and \skip while working on a part

2022-12-06 Thread Joel C. Salomon
This may be obvious to some, but I've found this construction helpful
while working on parallel pieces of music, and I thought I'd share:

\version "2.23.80"

upper = \relative c' {
  c4 d e f |
}

lower = << \skip \upper \relative c {
  f e
  % still being worked on
}
>>

\score {
  \new PianoStaff <<
\new Staff = "upper" \upper
\new Staff = "lower" \lower
  >>
}

And when the second part is complete, the `<< \skip \upper` and `>>`
can be removed.

—Joel



Re: "loco" after ottava

2022-12-06 Thread Joel C. Salomon
On Fri, Dec 2, 2022 at 2:14 PM Jean Abou Samra  wrote:
>
> Le 02/12/2022 à 02:27, Joel C. Salomon a écrit :
> > Piece of music I have in front of me puts the text "loco." above the
> > first note after an ottava.  See also the attached example, from
> > .
> >
> > The code below does not work, which makes me suspect I do not in fact
> > understand the spanner interface. (I tried to adapt the example from
> > crescendo spanners.)  The less-elegant solution of "just use
> > `\textMark` on the next note" works fine, but it feels like I'm
> > missing something obvious.
>
> bound-details is in fact not a property attached to spanner-interface
> (https://lilypond.org/doc/v2.23/Documentation/internals/spanner_002dinterface)
> but to the more specific line-spanner-interface
> (https://lilypond.org/doc/v2.23/Documentation/internals/line_002dspanner_002dinterface),
> which OttavaBracket currently does not implement. Therefore, it's
> expected that this doesn't work.

Thank you.

> The primary purpose of text marks is to be aligned to bar lines
> and to be performance indications for all staves (Text_mark_engraver
> lives in Score by default and the marks are typeset above all
> staves). Is a text mark really what you want here? I would just
> use a text script:

Looks like I'm going to have go through my code and better understand
when to use which sort of text.  I suspect some of my troubles with
"why is this interfering with that?" will also be helped by that
review.

--Joel



\tocItem within \score block, using header properties

2022-12-06 Thread Joel C. Salomon
The requirement that `\tocItem` is either outside the `\score` block
or within a music variable is making it awkward for me to keep it near
where the score `\header` block defines the piece title.  And I have
entirely failed to figure out a way to re-use the piece title.

Minimal example below, showing different ways I've tried.

Is there a cleaner way to accomplish this?

—Joel

\version "2.23.80"

upperI = \relative c' {
  \tocItem \markup "Piece Title" % works, but is an awkward place
  c4 d e f }
lowerI = \relative c {\clef bass f e d c }

scoreI = \score {
  \header {
piece = "Piece Title"
  }
  \new PianoStaff <<
  %  \tocItem \markup \fromproperty #'header:piece % doesn't work
  %  \tocItem \markup "Piece Title" % works, but creates extra staff
\new Staff = "upper" \upperI
\new Staff = "lower" \lowerI
  >>
}

\book {
  \markuplist \table-of-contents
  %  \tocItem \markup "Piece Title" % breaks locality
  \scoreI
}