Re: What is the meaning of a mordent on top of a sharp sign?

2022-06-27 Thread William Rehwinkel
No problem Ken. Sorry about that, I made the following example: (note 
that this would not play in midi playback)


\version "2.22.2"

shMordentUp = \markup { \center-column {\musicglyph "scripts.mordent" 
\musicglyph "accidentals.sharp" }}
shMordentDo = \markup { \center-column {\musicglyph "accidentals.sharp" 
\musicglyph "scripts.mordent" }}


\score {
    \relative c'' {
    c4^\shMordentUp
    c4_\shMordentDo
    }
}

Also note this example from 
https://lilypond.org/doc/v2.22/Documentation/notation/expressive-marks-attached-to-notes


\relative c''' {
  \once \override TextScript.script-priority = #-100
  a2^\prall^\markup { \sharp }

  \once \override Script.script-priority = #-100
  a2^\prall^\markup { \sharp }
}

Thank you,

-William

On 6/28/22 00:23, Kenneth Wolcott wrote:

Hi William;

   Thank you, now I have a meaning.

   What remains (that I did not specify) is how to engrave this?

Thanks,
Ken

On Mon, Jun 27, 2022 at 8:51 PM William Rehwinkel
 wrote:

That symbol means that the lower note is sharped. So it would be g-f#-g
instead of g-fnatural-g. See
https://music.stackexchange.com/questions/86043/would-an-accidental-in-a-mordant-still-be-effective-for-the-whole-measure


On 6/27/22 23:13, Kenneth Wolcott wrote:

Hi;

I'm trying to engrave a Piano arrangement of JS Bach, Six Little
Preludes, Nr 1, where the left hand notes have a strange thing I've
never seen before, a mordent on top of a sharp sign.

I've never seen these symbols together in this manner.

I have a screenshot attached.

Thanks,
Ken Wolcott

--
William Rehwinkel

will...@williamrehwinkel.net
https://williamrehwinkel.net



--
William Rehwinkel

will...@williamrehwinkel.net
https://williamrehwinkel.net




Re: What is the meaning of a mordent on top of a sharp sign?

2022-06-27 Thread Kenneth Wolcott
Hi William;

  Thank you, now I have a meaning.

  What remains (that I did not specify) is how to engrave this?

Thanks,
Ken

On Mon, Jun 27, 2022 at 8:51 PM William Rehwinkel
 wrote:
>
> That symbol means that the lower note is sharped. So it would be g-f#-g
> instead of g-fnatural-g. See
> https://music.stackexchange.com/questions/86043/would-an-accidental-in-a-mordant-still-be-effective-for-the-whole-measure
>
>
> On 6/27/22 23:13, Kenneth Wolcott wrote:
> > Hi;
> >
> >I'm trying to engrave a Piano arrangement of JS Bach, Six Little
> > Preludes, Nr 1, where the left hand notes have a strange thing I've
> > never seen before, a mordent on top of a sharp sign.
> >
> >I've never seen these symbols together in this manner.
> >
> >I have a screenshot attached.
> >
> > Thanks,
> > Ken Wolcott
>
> --
> William Rehwinkel
>
> will...@williamrehwinkel.net
> https://williamrehwinkel.net
>
>



Re: What is the meaning of a mordent on top of a sharp sign?

2022-06-27 Thread Kenneth Wolcott
Hi William;

  Looks like I need to read more slowly :-)  I see now that my
question was indeed precisely covered in the documentation.

Thank *you*. :-)
Ken

On Mon, Jun 27, 2022 at 9:29 PM William Rehwinkel
 wrote:
>
> No problem Ken. Sorry about that, I made the following example: (note
> that this would not play in midi playback)
>
> \version "2.22.2"
>
> shMordentUp = \markup { \center-column {\musicglyph "scripts.mordent"
> \musicglyph "accidentals.sharp" }}
> shMordentDo = \markup { \center-column {\musicglyph "accidentals.sharp"
> \musicglyph "scripts.mordent" }}
>
> \score {
>  \relative c'' {
>  c4^\shMordentUp
>  c4_\shMordentDo
>  }
> }
>
> Also note this example from
> https://lilypond.org/doc/v2.22/Documentation/notation/expressive-marks-attached-to-notes
>
> \relative c''' {
>\once \override TextScript.script-priority = #-100
>a2^\prall^\markup { \sharp }
>
>\once \override Script.script-priority = #-100
>a2^\prall^\markup { \sharp }
> }
>
> Thank you,
>
> -William
>
> On 6/28/22 00:23, Kenneth Wolcott wrote:
> > Hi William;
> >
> >Thank you, now I have a meaning.
> >
> >What remains (that I did not specify) is how to engrave this?
> >
> > Thanks,
> > Ken
> >
> > On Mon, Jun 27, 2022 at 8:51 PM William Rehwinkel
> >  wrote:
> >> That symbol means that the lower note is sharped. So it would be g-f#-g
> >> instead of g-fnatural-g. See
> >> https://music.stackexchange.com/questions/86043/would-an-accidental-in-a-mordant-still-be-effective-for-the-whole-measure
> >>
> >>
> >> On 6/27/22 23:13, Kenneth Wolcott wrote:
> >>> Hi;
> >>>
> >>> I'm trying to engrave a Piano arrangement of JS Bach, Six Little
> >>> Preludes, Nr 1, where the left hand notes have a strange thing I've
> >>> never seen before, a mordent on top of a sharp sign.
> >>>
> >>> I've never seen these symbols together in this manner.
> >>>
> >>> I have a screenshot attached.
> >>>
> >>> Thanks,
> >>> Ken Wolcott
> >> --
> >> William Rehwinkel
> >>
> >> will...@williamrehwinkel.net
> >> https://williamrehwinkel.net
> >>
> >>
> --
> William Rehwinkel
>
> will...@williamrehwinkel.net
> https://williamrehwinkel.net
>



Re: What is the meaning of a mordent on top of a sharp sign?

2022-06-27 Thread Kenneth Wolcott
Hi Andrew;

  The screenshot is from 8notes.com:

https://www.8notes.com/school/pdf/piano/bach_six_1.pdf (attached)

Thanks,
Ken


On Mon, Jun 27, 2022 at 8:58 PM Andrew Bernard
 wrote:
>
> Are you referring to BWV 933-938  6 Kleine Praludien? If so, I see no
> such passage in any of the preludes.
>
> What source are you engraving from?
>
> I am a harpsichordist so I can fairly confidently say this is not a rare
> notation and all it would mean is that the mordent is to the F sharp not
> F natural.
>
> Prelude 6 is full of these. The first edition - only published in 1802 -
> is full of these, but with the sharp on top of the mordent, which is the
> same.
>
>  From Wikipedia:
>
> "In music, a mordent is an ornament indicating that the note is to be
> played with a single rapid alternation with the note above or below.
> Like trills, they can be chromatically modified by a small flat, sharp
> or natural accidental."
>
>
> Andrew
>
>
> Kenneth Wolcott wrote on 28/06/2022 1:13 PM:
> > Hi;
> >
> >I'm trying to engrave a Piano arrangement of JS Bach, Six Little
> > Preludes, Nr 1, where the left hand notes have a strange thing I've
> > never seen before, a mordent on top of a sharp sign.
> >
>
>


Bach_Six_Little_Preludes_Nr1_arranged_for_Piano.pdf
Description: Adobe PDF document


Re: What is the meaning of a mordent on top of a sharp sign?

2022-06-27 Thread Andrew Bernard
Are you referring to BWV 933-938  6 Kleine Praludien? If so, I see no 
such passage in any of the preludes.


What source are you engraving from?

I am a harpsichordist so I can fairly confidently say this is not a rare 
notation and all it would mean is that the mordent is to the F sharp not 
F natural.


Prelude 6 is full of these. The first edition - only published in 1802 - 
is full of these, but with the sharp on top of the mordent, which is the 
same.


From Wikipedia:

"In music, a mordent is an ornament indicating that the note is to be 
played with a single rapid alternation with the note above or below. 
Like trills, they can be chromatically modified by a small flat, sharp 
or natural accidental."



Andrew


Kenneth Wolcott wrote on 28/06/2022 1:13 PM:

Hi;

   I'm trying to engrave a Piano arrangement of JS Bach, Six Little
Preludes, Nr 1, where the left hand notes have a strange thing I've
never seen before, a mordent on top of a sharp sign.






Re: What is the meaning of a mordent on top of a sharp sign?

2022-06-27 Thread William Rehwinkel
That symbol means that the lower note is sharped. So it would be g-f#-g 
instead of g-fnatural-g. See 
https://music.stackexchange.com/questions/86043/would-an-accidental-in-a-mordant-still-be-effective-for-the-whole-measure



On 6/27/22 23:13, Kenneth Wolcott wrote:

Hi;

   I'm trying to engrave a Piano arrangement of JS Bach, Six Little
Preludes, Nr 1, where the left hand notes have a strange thing I've
never seen before, a mordent on top of a sharp sign.

   I've never seen these symbols together in this manner.

   I have a screenshot attached.

Thanks,
Ken Wolcott


--
William Rehwinkel

will...@williamrehwinkel.net
https://williamrehwinkel.net




What is the meaning of a mordent on top of a sharp sign?

2022-06-27 Thread Kenneth Wolcott
Hi;

  I'm trying to engrave a Piano arrangement of JS Bach, Six Little
Preludes, Nr 1, where the left hand notes have a strange thing I've
never seen before, a mordent on top of a sharp sign.

  I've never seen these symbols together in this manner.

  I have a screenshot attached.

Thanks,
Ken Wolcott


Re: Access header-modules from inside markup-command

2022-06-27 Thread Thomas Morley
Am Mo., 27. Juni 2022 um 13:23 Uhr schrieb Jean Abou Samra :
>
>
>
> Le 27/06/2022 à 12:12, Thomas Morley a écrit :
> > Hi,
> >
> > https://lsr.di.unimi.it/LSR/Item?id=467 provides a markup-command to
> > access header-entries for use in arbitrary markup.
> > Alas it's limited to $defaultheader.
> > Although there is a comment to add/access other headers like from
> > \score, \bookpar explicit \book, I found no way to do so.
> > I tried to look up '$current-book/'$current-bookpart in parser (and
> > apply ly:book-header on the result), but to no avail, the  book(part)
> > is not found.
> >
> > How to do so?
> >
> > Below some code to play with (I reformated, renamed the original
> > snippet, adding some condition etc):
> >
> > \version "2.22.1"
> >
> > %% LSR 467
> > #(define-markup-command (with-header layout props markup) (markup?)
> >"Interpret the given markup with the header fields added to the props.
> > This way, one can re-use the same functions (using fromproperty
> > #'header:field) in the header block and as top-level markup."
> > ;; TODO: If we are inside a score, add the score's local header block, too!
> > ;; Currently, I only use the global header block, stored in $defaultheader
> >(let ((scopes (list $defaultheader)))
> >
> > (pretty-print
> >(list
> >  (cons '$current-bookpart (ly:parser-lookup '$current-bookpart))
> >  (cons '$current-book (ly:parser-lookup '$current-book))
> >)
> > )
> >  (if (every module? scopes)
> >  (let* ((alists (map ly:module->alist scopes))
> > (prefixed-alist
> >  (map
> >(lambda (alist)
> >   (map
> > (lambda (entry)
> >   (cons
> > (symbol-append 'header: (car entry))
> > (cdr entry)))
> > alist))
> >alists))
> > (props
> >   (append
> > prefixed-alist
> > props
> > (layout-extract-page-properties layout
> >(interpret-markup layout props markup))
> >  (begin
> >(ly:warning "No header-module found, returning point-stencil")
> >point-stencil
> >
> > %{
> > %% (1) \header and \markup at toplevel
> > %% works
> > \header { my-entry = "Whatever" }
> > \markup \with-header \with-color #red \fromproperty #'header:my-entry
> > %}
> >
> > %{
> > %% (2) \header and \markup in explizit book
> > %% How to make it work?
> > \book {
> >\header { my-entry = "Whatever" }
> >\markup \with-header \with-color #red \fromproperty #'header:my-entry
> > }
> > %}
> >
> > % {
> > %% (3) \header and \markup in \bookpart
> > %% %% How to make it work?
> > \bookpart {
> >\header { my-entry = "Whatever" }
> >\markup \with-header \with-color #red \fromproperty #'header:my-entry
> > }
> > %}
> >
> > %{
> > %% (4) \header and \markup in toplevel \score
> > %% %% How to make it work?
> > \score {
> >{ b1-\markup \with-header \with-color #red \fromproperty 
> > #'header:my-entry }
> >\header { my-entry = "Whatever" }
> > }
> > %}
>
>
> I don't have the time to investigate much right now, but I
> think it would be possible by changing the toplevel-score-handler
> and such to set a property in the \layout to the \header, and later
> use that property from the layout argument of the markup command.
>
> This is likely to be a bit fragile, though.

I'll probably try tomorrow...

> What is the use case?
> There may be better ways to achieve what is wanted.

I try to code sort of a tablature for Akkordzither.

Instead of longish descriptions best look at the image at the bottom of
https://gitlab.com/Thomas_Morley/zither-ly/-/tree/development

Obviously I need sort of a TabStaff running top to bottom as opposed
to the usual left to right.

If I use a portrait-paper-size, I can use the default header and need
to rotate the TabStaff. Not knowing how to do it different, I did so
putting the TabStaff into \markup.
This is the master-branch of above linked repo.
Alas, I can't ensure consistent line-width of the TabStaff, because
LilyPond does not accepts settings for line-width exceeding
paper-dimensions. Furthermore, LilyPond not only warns, but rejects my
attempts to set such a line-width.
LilyPond accepts the max width of the page, though because of said
rotation I need up to page-height. This is a show-stopper!
Though, keeping default headers keeps multipe bookparts with different
headers possible.

For landscape pages I can't use the default header (found no way to rotate it).
Thus I put all in one markup, faking the \header with above
\with-header and adding a TabStaff in usual direction there.
All works more nicely and no problems with line-width.
Disadvantages:
x- and y-coordinates are always switched, driving me crazy, lol.
One need to rotate the landscape back to portrait with a 

Re: shiftDurations and tempo

2022-06-27 Thread David Kastrup
Jean Abou Samra  writes:

> When you say "tackle the resulting parser conflicts", that means
> "add precedences to solve them by making interpretation choices",
> not "solve them in a way that always does what the user might intend",
> right? As I understand it, there is a shift/reduce conflict on
>
> \tempo    [here]   # ...
>
> where the single lookahead token # is not enough
> to distinguish between \tempo   = 
> and \tempo  #  . The only
> way to "solve" while not breaking existing use of the second
> possibility would be to reduce on
>
> \tempo  [here] #
>
> and thus fail on
>
> \tempo  # = 
>
> as that would be interpreted as
>
> \tempo 
> # =  % don't know what to do with this
>
> Does that sound right? I'm interested in understanding the parser
> better, but it's a bit foggy for me at the moment.

It's a bit foggy to the wizards.  It's quite opaque for most.

Here is Bison's take on the conflicts:

lily/parser.yy: warning: shift/reduce conflict on token SCM_TOKEN 
[-Wcounterexamples]
  First example: "#{" $@1 "\\tempo" text • SCM_TOKEN '=' tempo_range
  Shift derivation
start_symbol
↳ 3: "#{" $@1 embedded_lilypond
  ↳ 51: identifier_init_nonumber
↳ 81: music_assign
  ↳ 190: simple_music
 ↳ 201: event_chord
↳ 408: tempo_event
   ↳ 175: "\\tempo" text 
embedded_scm_bare '=' tempo_range
 ↳ 22: 
• SCM_TOKEN
  Second example: "#{" $@1 "\\tempo" text • SCM_TOKEN music_list "end of input"
  Reduce derivation
$accept
↳ 0: start_symbol   
 "end of input"
 ↳ 3: "#{" $@1 embedded_lilypond
   ↳ 55: music_embedded 
music_embeddedmusic_list
 ↳ 184: music   
↳ 186: music_embedded_backup
↳ 180: music_assign 
   ↳ 189: embedded_scm
   ↳ 190: simple_music  
  ↳ 40: embedded_scm_bare
  ↳ 201: event_chord
↳ 22: SCM_TOKEN
 ↳ 408: tempo_event
↳ 174: 
"\\tempo" text •
lily/parser.yy: warning: shift/reduce conflict on token SCM_IDENTIFIER 
[-Wcounterexamples]
  First example: "#{" $@1 "\\tempo" text • SCM_IDENTIFIER '=' tempo_range
  Shift derivation
start_symbol
↳ 3: "#{" $@1 embedded_lilypond
  ↳ 51: identifier_init_nonumber
↳ 81: music_assign
  ↳ 190: simple_music
 ↳ 201: event_chord
↳ 408: tempo_event
   ↳ 175: "\\tempo" text 
embedded_scm_bare  '=' tempo_range
 ↳ 23: 
• SCM_IDENTIFIER
  Second example: "#{" $@1 "\\tempo" text • SCM_IDENTIFIER music_list "end of 
input"
  Reduce derivation
$accept
↳ 0: start_symbol   
"end of input"
 ↳ 3: "#{" $@1 embedded_lilypond
   ↳ 55: music_embedded 
music_embedded   music_list
 ↳ 184: music   
↳ 186: music_embedded_backup
↳ 180: music_assign 
   ↳ 189: embedded_scm
   ↳ 190: simple_music  
  ↳ 40: embedded_scm_bare
  ↳ 201: event_chord
↳ 23: SCM_IDENTIFIER
 ↳ 408: tempo_event
↳ 174: 
"\\tempo" text •




Which actually does not look all that different from your analysis.

-- 
David Kastrup



Re: Generating a spiccato

2022-06-27 Thread Simon Albrecht

Hi Jacques,

On 27/06/2022 22:13, Jacques Menu wrote:

Does anyone know of some way to generate spiccato articulations in the scores 
produced by Lily?



what would you expect that to look like?

{ a'4-! }

maybe?

Best, Simon




Re: shiftDurations and tempo

2022-06-27 Thread Simon Albrecht

Hi David,

On 27/06/2022 21:07, David Kastrup wrote:

Before looking for a possible following `=`
LilyPond has to have made a decision what type the token/expression
coming before that has.  It cannot look at the type of a #... expression
before deciding to look for `=` but it can (and will) look at the type
of a $... expression.

Now syntax errors are comparatively unhelpful, so one could try to
tentatively accept an #... = ... expression anyway and then barf if the
expression type does not support it.  The result would likely not be
worse for the user.



thanks for your consideration. I don’t think I’m qualified to speak on 
that… a decision might depend on how strongly a user is expected to know 
about the # vs. $ issue.


Best, Simon




Re: shiftDurations and tempo

2022-06-27 Thread Simon Albrecht

Hi Jean,

On 27/06/2022 20:37, Jean Abou Samra wrote:



Le 27/06/2022 à 20:10, Simon Albrecht a écrit :

Hello everyone,

I’m trying to encode a piece such that I can switch whether or not 
durations will be shifted (note values halved/doubled). Unfortunately 
\tempo isn’t affected by \shiftDurations (that would be a sensible 
feature request, right?),


Go open an issue.



I did: 



so I tried this:
%%%
\version "2.23.9"

durationShiftOne = #-1
{
  \tempo #(ly:make-duration

[…]


Can I make that work some other way?



\version "2.23.9"

durationShiftOne = #-1
{
  \tempo $(ly:make-duration (+ 3 durationShiftOne)) = 152
  \shiftDurations \durationShiftOne #0 { 8 }
}


You just need to use $ instead of #.



I keep forgetting to try that. I’ll try understanding the difference 
better as well. Thanks for the help!


Best, Simon




Re: shiftDurations and tempo

2022-06-27 Thread Jean Abou Samra




Le 28/06/2022 à 00:15, David Kastrup a écrit :

David Kastrup  writes:


Jean Abou Samra  writes:


Le 27/06/2022 à 20:10, Simon Albrecht a écrit :

Hello everyone,

I’m trying to encode a piece such that I can switch whether or not
durations will be shifted (note values
halved/doubled). Unfortunately \tempo isn’t affected by
\shiftDurations (that would be a sensible feature request, right?),

Go open an issue.



so I tried this:
%%%
\version "2.23.9"

durationShiftOne = #-1
{
   \tempo #(ly:make-duration (+ 3 durationShiftOne)) = 152
   \shiftDurations \durationShiftOne #0 { 8 }
}


but unfortunately Lily won’t accept that Scheme expression instead
of the normal duration.

Can I make that work some other way?

Should the parser be able to take that Scheme expression there?


\version "2.23.9"

durationShiftOne = #-1
{
   \tempo $(ly:make-duration (+ 3 durationShiftOne)) = 152
   \shiftDurations \durationShiftOne #0 { 8 }
}


You just need to use $ instead of #. See these pages about the difference:

https://lilypond.org/doc/v2.23/Documentation/extending/lilypond-scheme-syntax.html
https://extending-lilypond.readthedocs.io/en/latest/lily-and-scheme.html#hash-vs-dollar

The problem is that \tempo has multiple syntaxes (\tempo ,
\tempo  =  and \tempo   = ),
which makes it impossible to accept # here because early evaluation
is needed to disambiguate, I think. I'm no expert of the parser
though.

It's sort of like that.  Before looking for a possible following `=`
LilyPond has to have made a decision what type the token/expression
coming before that has.  It cannot look at the type of a #... expression
before deciding to look for `=` but it can (and will) look at the type
of a $... expression.

Now syntax errors are comparatively unhelpful, so one could try to
tentatively accept an #... = ... expression anyway and then barf if the
expression type does not support it.  The result would likely not be
worse for the user.

To wit:
It's debatable whether this partial ability to specify the duration as
#... but not in the long form including text is worth the confusion.
Anyone who wants to tackle the resulting parser conflicts is welcome to
try: Bison appears to do a pretty good job these days proposing
productions that may trigger the problem when giving the right options.




When you say "tackle the resulting parser conflicts", that means
"add precedences to solve them by making interpretation choices",
not "solve them in a way that always does what the user might intend",
right? As I understand it, there is a shift/reduce conflict on

\tempo    [here]   # ...

where the single lookahead token # is not enough
to distinguish between \tempo   = 
and \tempo  #  . The only
way to "solve" while not breaking existing use of the second
possibility would be to reduce on

\tempo  [here] #

and thus fail on

\tempo  # = 

as that would be interpreted as

\tempo 
# =  % don't know what to do with this

Does that sound right? I'm interested in understanding the parser
better, but it's a bit foggy for me at the moment.

Thanks,
Jean




Re: shiftDurations and tempo

2022-06-27 Thread David Kastrup
David Kastrup  writes:

> Jean Abou Samra  writes:
>
>> Le 27/06/2022 à 20:10, Simon Albrecht a écrit :
>>> Hello everyone,
>>>
>>> I’m trying to encode a piece such that I can switch whether or not
>>> durations will be shifted (note values
>>> halved/doubled). Unfortunately \tempo isn’t affected by
>>> \shiftDurations (that would be a sensible feature request, right?),
>>
>> Go open an issue.
>>
>>
>>> so I tried this:
>>> %%%
>>> \version "2.23.9"
>>>
>>> durationShiftOne = #-1
>>> {
>>>   \tempo #(ly:make-duration (+ 3 durationShiftOne)) = 152
>>>   \shiftDurations \durationShiftOne #0 { 8 }
>>> }
>>> 
>>>
>>> but unfortunately Lily won’t accept that Scheme expression instead
>>> of the normal duration.
>>>
>>> Can I make that work some other way?
>>>
>>> Should the parser be able to take that Scheme expression there?
>>
>>
>> \version "2.23.9"
>>
>> durationShiftOne = #-1
>> {
>>   \tempo $(ly:make-duration (+ 3 durationShiftOne)) = 152
>>   \shiftDurations \durationShiftOne #0 { 8 }
>> }
>>
>>
>> You just need to use $ instead of #. See these pages about the difference:
>>
>> https://lilypond.org/doc/v2.23/Documentation/extending/lilypond-scheme-syntax.html
>> https://extending-lilypond.readthedocs.io/en/latest/lily-and-scheme.html#hash-vs-dollar
>>
>> The problem is that \tempo has multiple syntaxes (\tempo ,
>> \tempo  =  and \tempo   = ),
>> which makes it impossible to accept # here because early evaluation
>> is needed to disambiguate, I think. I'm no expert of the parser
>> though.
>
> It's sort of like that.  Before looking for a possible following `=`
> LilyPond has to have made a decision what type the token/expression
> coming before that has.  It cannot look at the type of a #... expression
> before deciding to look for `=` but it can (and will) look at the type
> of a $... expression.
>
> Now syntax errors are comparatively unhelpful, so one could try to
> tentatively accept an #... = ... expression anyway and then barf if the
> expression type does not support it.  The result would likely not be
> worse for the user.

To wit:

>From 56869db10837eac331e89d074efa5952116ce3d6 Mon Sep 17 00:00:00 2001
From: David Kastrup 
Date: Tue, 28 Jun 2022 00:06:17 +0200
Subject: [PATCH] Allow \tempo # = ... for tempo specifications

What doesn't work is specifying \tempo "text" # = ...
because its implementation would lead to parser conflicts.
---
 lily/parser.yy | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/lily/parser.yy b/lily/parser.yy
index 9207e479c8..7fff2fd019 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -1403,6 +1403,16 @@ tempo_event:
 	TEMPO steno_duration '=' tempo_range	{
 		$$ = MAKE_SYNTAX (tempo, @$, SCM_EOL, $2, $4);
 	}
+	| TEMPO embedded_scm_bare '=' tempo_range {
+		if (unsmob ($2))
+		{
+			$$ = MAKE_SYNTAX (tempo, @$, SCM_EOL, $2, $4);
+		} else {
+			parser->parser_error (@2, _("duration expected"));
+			$$ = MAKE_SYNTAX (tempo, @$,
+	  SCM_EOL, Duration (2, 0).smobbed_copy (), $4);
+		}
+	}
 	| TEMPO text steno_duration '=' tempo_range	{
 		$$ = MAKE_SYNTAX (tempo, @$, $2, $3, $5);
 	}
-- 
2.34.1


It's debatable whether this partial ability to specify the duration as
#... but not in the long form including text is worth the confusion.
Anyone who wants to tackle the resulting parser conflicts is welcome to
try: Bison appears to do a pretty good job these days proposing
productions that may trigger the problem when giving the right options.

-- 
David Kastrup


Re: Generating a spiccato

2022-06-27 Thread Hans Aikema

> On 27 Jun 2022, at 22:28, Jacques Menu  wrote:
> 
> Hello folks,
> 
> Does anyone know of some way to generate spiccato articulations in the scores 
> produced by Lily?
> 
> Thanks for your help!
> 
> JM

Google leads me to 
https://www.researchgate.net/figure/Bow-Strokes-Spiccato-From-Milanovs-First-Violin-Lessons-1981-Volume-II-tema-VII_fig27_256198538
 which makes me think you could use the staccato for notating the spiccato?




Generating a spiccato

2022-06-27 Thread Jacques Menu
Hello folks,

Does anyone know of some way to generate spiccato articulations in the scores 
produced by Lily?

Thanks for your help!

JM




Re: shiftDurations and tempo

2022-06-27 Thread David Kastrup
Jean Abou Samra  writes:

> Le 27/06/2022 à 20:10, Simon Albrecht a écrit :
>> Hello everyone,
>>
>> I’m trying to encode a piece such that I can switch whether or not
>> durations will be shifted (note values
>> halved/doubled). Unfortunately \tempo isn’t affected by
>> \shiftDurations (that would be a sensible feature request, right?),
>
> Go open an issue.
>
>
>> so I tried this:
>> %%%
>> \version "2.23.9"
>>
>> durationShiftOne = #-1
>> {
>>   \tempo #(ly:make-duration (+ 3 durationShiftOne)) = 152
>>   \shiftDurations \durationShiftOne #0 { 8 }
>> }
>> 
>>
>> but unfortunately Lily won’t accept that Scheme expression instead
>> of the normal duration.
>>
>> Can I make that work some other way?
>>
>> Should the parser be able to take that Scheme expression there?
>
>
> \version "2.23.9"
>
> durationShiftOne = #-1
> {
>   \tempo $(ly:make-duration (+ 3 durationShiftOne)) = 152
>   \shiftDurations \durationShiftOne #0 { 8 }
> }
>
>
> You just need to use $ instead of #. See these pages about the difference:
>
> https://lilypond.org/doc/v2.23/Documentation/extending/lilypond-scheme-syntax.html
> https://extending-lilypond.readthedocs.io/en/latest/lily-and-scheme.html#hash-vs-dollar
>
> The problem is that \tempo has multiple syntaxes (\tempo ,
> \tempo  =  and \tempo   = ),
> which makes it impossible to accept # here because early evaluation
> is needed to disambiguate, I think. I'm no expert of the parser
> though.

It's sort of like that.  Before looking for a possible following `=`
LilyPond has to have made a decision what type the token/expression
coming before that has.  It cannot look at the type of a #... expression
before deciding to look for `=` but it can (and will) look at the type
of a $... expression.

Now syntax errors are comparatively unhelpful, so one could try to
tentatively accept an #... = ... expression anyway and then barf if the
expression type does not support it.  The result would likely not be
worse for the user.

-- 
David Kastrup



Re: shiftDurations and tempo

2022-06-27 Thread Jean Abou Samra




Le 27/06/2022 à 20:10, Simon Albrecht a écrit :

Hello everyone,

I’m trying to encode a piece such that I can switch whether or not 
durations will be shifted (note values halved/doubled). Unfortunately 
\tempo isn’t affected by \shiftDurations (that would be a sensible 
feature request, right?),


Go open an issue.



so I tried this:
%%%
\version "2.23.9"

durationShiftOne = #-1
{
  \tempo #(ly:make-duration (+ 3 durationShiftOne)) = 152
  \shiftDurations \durationShiftOne #0 { 8 }
}


but unfortunately Lily won’t accept that Scheme expression instead of 
the normal duration.


Can I make that work some other way?

Should the parser be able to take that Scheme expression there?



\version "2.23.9"

durationShiftOne = #-1
{
  \tempo $(ly:make-duration (+ 3 durationShiftOne)) = 152
  \shiftDurations \durationShiftOne #0 { 8 }
}


You just need to use $ instead of #. See these pages about the difference:

https://lilypond.org/doc/v2.23/Documentation/extending/lilypond-scheme-syntax.html
https://extending-lilypond.readthedocs.io/en/latest/lily-and-scheme.html#hash-vs-dollar

The problem is that \tempo has multiple syntaxes (\tempo ,
\tempo  =  and \tempo   = ),
which makes it impossible to accept # here because early evaluation
is needed to disambiguate, I think. I'm no expert of the parser
though.

Best,
Jean




shiftDurations and tempo

2022-06-27 Thread Simon Albrecht

Hello everyone,

I’m trying to encode a piece such that I can switch whether or not 
durations will be shifted (note values halved/doubled). Unfortunately 
\tempo isn’t affected by \shiftDurations (that would be a sensible 
feature request, right?), so I tried this:


%%%
\version "2.23.9"

durationShiftOne = #-1
{
  \tempo #(ly:make-duration (+ 3 durationShiftOne)) = 152
  \shiftDurations \durationShiftOne #0 { 8 }
}


but unfortunately Lily won’t accept that Scheme expression instead of 
the normal duration.


Can I make that work some other way?

Should the parser be able to take that Scheme expression there?

Best, Simon




Re: simplify the program code

2022-06-27 Thread Лысов Дмитрий
Oh, no. This is what is needed. I just haven't come across the proposed algorithm of the program. I need to try it out.27.06.2022, 14:35, "Jean Abou Samra" :Le 27/06/2022 à 12:22, Лысов Дмитрий a écrit : It is interesting. There is something to think about.Since you say this, I suppose you are not completely satisfied with this solution. What could be better about it?Jean



Re: Problem with a snippet "shorthand for triplets [0.21429]"

2022-06-27 Thread David Kastrup
Aaron Hill  writes:

> On 2022-06-27 6:18 am, Jean Abou Samra wrote:
>> The LSR runs LilyPond 2.22 and you have 2.18. You need to upgrade
>> LilyPond. Frescobaldi makes it easy to use several versions in
>> parallel.
>
> As far as I can see, the LSR only notes the current version in
> Contributing [1].
>
> [1]: https://lsr.di.unimi.it/LSR/html/contributing.html
>
> Would it be possible to have this information displayed prominently on
> the search page itself?  Unless users are following the mailing list
> threads, they would not be aware of the recent upgrade to 2.22.

Does anybody remember the rationale why the snippets don't contain
\version statements?

-- 
David Kastrup



Re: Problem with a snippet "shorthand for triplets [0.21429]"

2022-06-27 Thread Aaron Hill

On 2022-06-27 6:18 am, Jean Abou Samra wrote:

The LSR runs LilyPond 2.22 and you have 2.18. You need to upgrade
LilyPond. Frescobaldi makes it easy to use several versions in
parallel.


As far as I can see, the LSR only notes the current version in 
Contributing [1].


[1]: https://lsr.di.unimi.it/LSR/html/contributing.html

Would it be possible to have this information displayed prominently on 
the search page itself?  Unless users are following the mailing list 
threads, they would not be aware of the recent upgrade to 2.22.



-- Aaron Hill



Re: Problem with a snippet "shorthand for triplets [0.21429]"

2022-06-27 Thread Jean Abou Samra




Le 27/06/2022 à 13:26, mark damerell a écrit :

It came from:
%% http://lsr.di.unimi.it/LSR/Item?id=328

Here is part of it:

% First version, with a single argument, i.e. the
% syntax is \triplet{ c d e }
triplet = #(define-music-function (music) (ly:music?)
  #{ \tuplet 3/2 $music #})

\score{
  \relative c'{
    c4 \triplet {c d e}
  }
}

This produces:

GNU LilyPond 2.18.2
Processing `/home/rmd/Music/holycity/trips.ly '
Parsing.../usr/share/lilypond/2.18.2/scm/ly-syntax-constructors.scm:56:23: 
In expression (apply (ly:music-function-extract fun) parser ...):
/usr/share/lilypond/2.18.2/scm/ly-syntax-constructors.scm:56:23: Wrong 
number of arguments to #


Compilation exited abnormally with code 1 at Mon Jun 27 12:18:38

Please any advice? thank you.



The LSR runs LilyPond 2.22 and you have 2.18. You need to upgrade 
LilyPond. Frescobaldi makes it easy to use several versions in parallel.


Alternatively, replace "music" with the legacy syntax "parser location 
music".


Jean




Problem with a snippet "shorthand for triplets [0.21429]"

2022-06-27 Thread mark damerell
It came from:
%% http://lsr.di.unimi.it/LSR/Item?id=328

Here is part of it:

% First version, with a single argument, i.e. the
% syntax is \triplet{ c d e }
triplet = #(define-music-function (music) (ly:music?)
  #{ \tuplet 3/2 $music #})

\score{
  \relative c'{
c4 \triplet {c d e}
  }
}

This produces:

GNU LilyPond 2.18.2
Processing `/home/rmd/Music/holycity/trips.ly'
Parsing.../usr/share/lilypond/2.18.2/scm/ly-syntax-constructors.scm:56:23:
In expression (apply (ly:music-function-extract fun) parser ...):
/usr/share/lilypond/2.18.2/scm/ly-syntax-constructors.scm:56:23: Wrong
number of arguments to #

Compilation exited abnormally with code 1 at Mon Jun 27 12:18:38

Please any advice? thank you.


Re: simplify the program code

2022-06-27 Thread Jean Abou Samra




Le 27/06/2022 à 12:22, Лысов Дмитрий a écrit :

It is interesting. There is something to think about.


Since you say this, I suppose you are not completely satisfied with this 
solution. What could be better about it?


Jean





Re: Access header-modules from inside markup-command

2022-06-27 Thread Jean Abou Samra




Le 27/06/2022 à 12:12, Thomas Morley a écrit :

Hi,

https://lsr.di.unimi.it/LSR/Item?id=467 provides a markup-command to
access header-entries for use in arbitrary markup.
Alas it's limited to $defaultheader.
Although there is a comment to add/access other headers like from
\score, \bookpar explicit \book, I found no way to do so.
I tried to look up '$current-book/'$current-bookpart in parser (and
apply ly:book-header on the result), but to no avail, the  book(part)
is not found.

How to do so?

Below some code to play with (I reformated, renamed the original
snippet, adding some condition etc):

\version "2.22.1"

%% LSR 467
#(define-markup-command (with-header layout props markup) (markup?)
   "Interpret the given markup with the header fields added to the props.
This way, one can re-use the same functions (using fromproperty
#'header:field) in the header block and as top-level markup."
;; TODO: If we are inside a score, add the score's local header block, too!
;; Currently, I only use the global header block, stored in $defaultheader
   (let ((scopes (list $defaultheader)))

(pretty-print
   (list
 (cons '$current-bookpart (ly:parser-lookup '$current-bookpart))
 (cons '$current-book (ly:parser-lookup '$current-book))
   )
)
 (if (every module? scopes)
 (let* ((alists (map ly:module->alist scopes))
(prefixed-alist
 (map
   (lambda (alist)
  (map
(lambda (entry)
  (cons
(symbol-append 'header: (car entry))
(cdr entry)))
alist))
   alists))
(props
  (append
prefixed-alist
props
(layout-extract-page-properties layout
   (interpret-markup layout props markup))
 (begin
   (ly:warning "No header-module found, returning point-stencil")
   point-stencil

%{
%% (1) \header and \markup at toplevel
%% works
\header { my-entry = "Whatever" }
\markup \with-header \with-color #red \fromproperty #'header:my-entry
%}

%{
%% (2) \header and \markup in explizit book
%% How to make it work?
\book {
   \header { my-entry = "Whatever" }
   \markup \with-header \with-color #red \fromproperty #'header:my-entry
}
%}

% {
%% (3) \header and \markup in \bookpart
%% %% How to make it work?
\bookpart {
   \header { my-entry = "Whatever" }
   \markup \with-header \with-color #red \fromproperty #'header:my-entry
}
%}

%{
%% (4) \header and \markup in toplevel \score
%% %% How to make it work?
\score {
   { b1-\markup \with-header \with-color #red \fromproperty #'header:my-entry }
   \header { my-entry = "Whatever" }
}
%}



I don't have the time to investigate much right now, but I
think it would be possible by changing the toplevel-score-handler
and such to set a property in the \layout to the \header, and later
use that property from the layout argument of the markup command.

This is likely to be a bit fragile, though. What is the use case?
There may be better ways to achieve what is wanted.

Jean



Re: simplify the program code

2022-06-27 Thread Лысов Дмитрий
It is interesting. There is something to think about.27.06.2022, 09:48, "Jean Abou Samra" :Le 26/06/2022 à 20:25, Лысов Дмитрий a écrit : Thanks. That's not bad. Probably, the insertion of the \markup block  in \score should not be done. Then you will get one midi file. Still,  it is more convenient to listen to individual midi files.1. It is usually more convenient if you move global \layoutand \midi settings to a separate block on the top-level ratherthan duplicating them.2. To move the markups inside the score, you can use headers:\score {   \header { piece = \markup ...   }   ...}3. Define a substitution function to do the rest. (This is easierwith the previous bullet point since it only has to return one singlevalue.)\version "2.23.9"\header {   title = "Сборник мелодических формул знаменного распева" %\markup { \override #'(line-width . 60) \wordwrap-string  { "Конда́къ ..., гла́съ є҃:"  } }   %subtitle = ""   %subsubtitle =  ""   composer= "Штейнберг Б."   poet = "Москва 2017"   %copyright = ""}\paper {   #(set-paper-size "a4")   %page-count = # 1   tagline=##f   %ragged-last = ##t   ragged-right = ##t   myStaffSize = #21   #(define fonts (make-pango-font-tree   "Times New Roman"   "Times New Roman"   "Times New Roman"   (/ myStaffSize 21)))}\layout {   indent = 0.0   \context { \Lyrics \override LyricText #'font-size = #4 \override LyricText #'font-name = #"Times New Roman" \override LyricSpace.minimum-distance = #0.8   }}#(define counter-alist '())#(define-markup-command (counter layout props name) (string?)    "Increases and prints out the value of the given counter named @var{name}.    If the counter does not yet exist, it is initialized with 1."    (let* ((oldval (assoc-ref counter-alist name))   (newval (if (number? oldval) (+ oldval 1) 1)))  (set! counter-alist (assoc-set! counter-alist name newval))  (interpret-markup layout props    (markup (number->string newval)#(define-markup-command (setcounter layout props name value) (string? number?)    "Set the given counter named @var{name} to the given @var{value} and prints    out the value. The counter does not yet have to exist."    (set! counter-alist (assoc-set! counter-alist name (- value 1)))    (interpret-markup layout props (make-counter-markup name)))\markup { \setcounter #"mycounter" #-1 }\markup { \fill-line \huge { "Глас 1" }}\markup { \fill-line \huge { "Начальные" }}\markup { Номер midi файла: \counter #"mycounter" }\layout {   \context { \Score \override SpacingSpanner.spacing-increment = 0.5   }   \context { \KievanVoice \stemDown fontSize = 1.0   }}\midi {   \context { \Score tempoWholesPerMinute = #(ly:make-moment 110 2)   }   \context { \Staff \remove Staff_performer   }   \context { \Voice \remove Staff_performer   }}makeScore =#(define-scheme-function (mark notes) (markup? ly:music?)    #{  \score {    \header {  piece = \markup { Номер midi файла: \counter #"mycounter" }    }    \new KievanVoice = "melody" \relative c' {  \cadenzaOn  \mark #mark  #notes  \bar "|"    }    \layout { }    \midi { }  }    #})\makeScore Удра { e4 c d f e d c d e d e1 }\makeScore Рымза { e4 c d e f e d c2 d e1 }\makeScore Рутва { e2 e4 c d f e d c d e d e1 }\makeScore Перегиб { e2 e4 c d f e d c2 d e1 }\makeScore "Вознос последний" { d2 d4 f e d c b a1 g }See these pages in the documentation:https://lilypond.org/doc/v2.23/Documentation/notation/creating-titles-headers-and-footers#default-layout-of-bookpart-and-score-titleshttps://lilypond.org/doc/v2.23/Documentation/extending/scheme-functions.html(You need define-scheme-function rather than the more usualdefine-music-function because this function returns a whole\score block, not some music that could be used within a largerpiece of music.)Best,Jean

Access header-modules from inside markup-command

2022-06-27 Thread Thomas Morley
Hi,

https://lsr.di.unimi.it/LSR/Item?id=467 provides a markup-command to
access header-entries for use in arbitrary markup.
Alas it's limited to $defaultheader.
Although there is a comment to add/access other headers like from
\score, \bookpar explicit \book, I found no way to do so.
I tried to look up '$current-book/'$current-bookpart in parser (and
apply ly:book-header on the result), but to no avail, the  book(part)
is not found.

How to do so?

Below some code to play with (I reformated, renamed the original
snippet, adding some condition etc):

\version "2.22.1"

%% LSR 467
#(define-markup-command (with-header layout props markup) (markup?)
  "Interpret the given markup with the header fields added to the props.
This way, one can re-use the same functions (using fromproperty
#'header:field) in the header block and as top-level markup."
;; TODO: If we are inside a score, add the score's local header block, too!
;; Currently, I only use the global header block, stored in $defaultheader
  (let ((scopes (list $defaultheader)))

(pretty-print
  (list
(cons '$current-bookpart (ly:parser-lookup '$current-bookpart))
(cons '$current-book (ly:parser-lookup '$current-book))
  )
)
(if (every module? scopes)
(let* ((alists (map ly:module->alist scopes))
   (prefixed-alist
(map
  (lambda (alist)
 (map
   (lambda (entry)
 (cons
   (symbol-append 'header: (car entry))
   (cdr entry)))
   alist))
  alists))
   (props
 (append
   prefixed-alist
   props
   (layout-extract-page-properties layout
  (interpret-markup layout props markup))
(begin
  (ly:warning "No header-module found, returning point-stencil")
  point-stencil

%{
%% (1) \header and \markup at toplevel
%% works
\header { my-entry = "Whatever" }
\markup \with-header \with-color #red \fromproperty #'header:my-entry
%}

%{
%% (2) \header and \markup in explizit book
%% How to make it work?
\book {
  \header { my-entry = "Whatever" }
  \markup \with-header \with-color #red \fromproperty #'header:my-entry
}
%}

% {
%% (3) \header and \markup in \bookpart
%% %% How to make it work?
\bookpart {
  \header { my-entry = "Whatever" }
  \markup \with-header \with-color #red \fromproperty #'header:my-entry
}
%}

%{
%% (4) \header and \markup in toplevel \score
%% %% How to make it work?
\score {
  { b1-\markup \with-header \with-color #red \fromproperty #'header:my-entry }
  \header { my-entry = "Whatever" }
}
%}


Thanks,
  Harm



Re: simplify the program code

2022-06-27 Thread Jean Abou Samra

Le 26/06/2022 à 20:25, Лысов Дмитрий a écrit :
Thanks. That's not bad. Probably, the insertion of the \markup block 
in \score should not be done. Then you will get one midi file. Still, 
it is more convenient to listen to individual midi files.



1. It is usually more convenient if you move global \layout
and \midi settings to a separate block on the top-level rather
than duplicating them.

2. To move the markups inside the score, you can use headers:

\score {
  \header {
    piece = \markup ...
  }
  ...
}

3. Define a substitution function to do the rest. (This is easier
with the previous bullet point since it only has to return one single
value.)




\version "2.23.9"

\header {
  title = "Сборник мелодических формул знаменного распева" %\markup { 
\override #'(line-width . 60) \wordwrap-string  { "Конда́къ ..., гла́съ 
є҃:"  } }

  %subtitle = ""
  %subsubtitle =  ""
  composer= "Штейнберг Б."
  poet = "Москва 2017"
  %copyright = ""
}

\paper {
  #(set-paper-size "a4")
  %page-count = # 1
  tagline=##f
  %ragged-last = ##t
  ragged-right = ##t
  myStaffSize = #21
  #(define fonts (make-pango-font-tree
  "Times New Roman"
  "Times New Roman"
  "Times New Roman"
  (/ myStaffSize 21)))
}

\layout {
  indent = 0.0
  \context {
    \Lyrics
    \override LyricText #'font-size = #4
    \override LyricText #'font-name = #"Times New Roman"
    \override LyricSpace.minimum-distance = #0.8
  }
}

#(define counter-alist '())

#(define-markup-command (counter layout props name) (string?)
   "Increases and prints out the value of the given counter named 
@var{name}.

   If the counter does not yet exist, it is initialized with 1."
   (let* ((oldval (assoc-ref counter-alist name))
  (newval (if (number? oldval) (+ oldval 1) 1)))
 (set! counter-alist (assoc-set! counter-alist name newval))
 (interpret-markup layout props
   (markup (number->string newval)

#(define-markup-command (setcounter layout props name value) (string? 
number?)
   "Set the given counter named @var{name} to the given @var{value} and 
prints

   out the value. The counter does not yet have to exist."
   (set! counter-alist (assoc-set! counter-alist name (- value 1)))
   (interpret-markup layout props (make-counter-markup name)))

\markup { \setcounter #"mycounter" #-1 }
\markup { \fill-line \huge { "Глас 1" }}
\markup { \fill-line \huge { "Начальные" }}
\markup { Номер midi файла: \counter #"mycounter" }

\layout {
  \context {
    \Score
    \override SpacingSpanner.spacing-increment = 0.5
  }
  \context {
    \KievanVoice
    \stemDown
    fontSize = 1.0
  }
}

\midi {
  \context {
    \Score
    tempoWholesPerMinute = #(ly:make-moment 110 2)
  }
  \context {
    \Staff
    \remove Staff_performer
  }
  \context {
    \Voice
    \remove Staff_performer
  }
}

makeScore =
#(define-scheme-function (mark notes) (markup? ly:music?)
   #{
 \score {
   \header {
 piece = \markup { Номер midi файла: \counter #"mycounter" }
   }
   \new KievanVoice = "melody" \relative c' {
 \cadenzaOn
 \mark #mark
 #notes
 \bar "|"
   }
   \layout { }
   \midi { }
 }
   #})

\makeScore Удра { e4 c d f e d c d e d e1 }
\makeScore Рымза { e4 c d e f e d c2 d e1 }
\makeScore Рутва { e2 e4 c d f e d c d e d e1 }
\makeScore Перегиб { e2 e4 c d f e d c2 d e1 }
\makeScore "Вознос последний" { d2 d4 f e d c b a1 g }




See these pages in the documentation:

https://lilypond.org/doc/v2.23/Documentation/notation/creating-titles-headers-and-footers#default-layout-of-bookpart-and-score-titles
https://lilypond.org/doc/v2.23/Documentation/extending/scheme-functions.html

(You need define-scheme-function rather than the more usual
define-music-function because this function returns a whole
\score block, not some music that could be used within a larger
piece of music.)

Best,
Jean