Re: afterGrace, glissando, and hidenotes

2024-04-12 Thread Valentin Petzel
Am Donnerstag, 11. April 2024, 19:11:45 CEST schrieb Walt North:
> Hello, I would appreciate some help with this music function.
> 
> The end goal is have a define function produce a glissando after a note
> going either up or down to
> 
> undetermined second note.  For example a guitar slide down off the note.
> 
> I can get the behavior I want with a line of code directly in the score
> but not by using a function.
> 

Hello Walt,

The reason is that \glissando does not in fact behave the way you think is 
does. \glissando is a special kind of event we call afterevent — which is 
basically a function \glissando note which is applied in postfix notation note-
\glissando. This means that such an event needs to be handled specially by the 
parser. As not every code is exactly correct in this sense the parse will try 
to find such post events that are not attached to anything, and try to find a 
previous note it can be attached to.

This means that other than c-\glissando you can also do {c}\glissando or 
whatever.

But if you have a function like \afterGrace and then do #startNote \glissando 
... the parser will see this as two different entities and therefore call 
\afterGrace with the arguments #startNote and \glissando — thus the grace part 
will not actually be inserted as grace, but as regular notes, which causes the 
bar check failure, and the glissando will be started without any notehead.

To fix this you could simply do

\afterGrace 1 { #startNote \glissando } ...

Cheers,
Valentin

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


Re: afterGrace, glissando, and hidenotes

2024-04-12 Thread Michael Werner
Hi Walt,

On 4/11/24 13:11, Walt North wrote:
> Hello, I would appreciate some help with this music function.
>
> The end goal is have a define function produce a glissando after a
> note going either up or down to undetermined second note.  For
> example a guitar slide down off the note.

If I'm understanding correctly what you're after there's an existing
function for this. Have a look at:
https://lilypond.org/doc/v2.24/Documentation/notation/expressive-marks-as-curves#index-fall-1
As an example:

\version "2.24.2"

musicOne = \relative c'' {
r4 c4\bendAfter #+1 r2
r4 c4\bendAfter #-1 r2
r4 c4\bendAfter #+2 r2
r4 c4\bendAfter #-2 r2
}

musicTwo = \relative c'' {
\override Score.SpacingSpanner.shortest-duration-space = #4.0
r4 c4\bendAfter #+1 r2
r4 c4\bendAfter #-1 r2
r4 c4\bendAfter #+2 r2
r4 c4\bendAfter #-2 r2
}

\score {
\musicOne
}

\score {
\musicTwo
}

This gives:

[image: image.png]

--
Michael


afterGrace, glissando, and hidenotes

2024-04-11 Thread Walt North

Hello, I would appreciate some help with this music function.

The end goal is have a define function produce a glissando after a note 
going either up or down to


undetermined second note.  For example a guitar slide down off the note.

I can get the behavior I want with a line of code directly in the score 
but not by using a function.


Below is sample code along with log output and a screenshot.



% The end goal of this is two have a function that will produce a slide out
% a given either up or down depending need.  The actual grace note is not
% needed except to give the slide an up or down direction.

\version "2.24.2"
slideOutOf =
#(define-music-function (startNote endNote)
   (ly:music? ly:music?)
   #{
 \afterGrace 1 #startNote \glissando
 { \hideNotes #endNote \unHideNotes }
   #})

%this works as I want.
notesOne = {
  \relative {
    r4
    \afterGrace 1 d''4 \glissando
    { \hideNotes c16 \unHideNotes }
    r2 |
  }
}

%This does not work. Two issues. Barcheck fail and no glissando
notesTwo = { r4 \slideOutOf d''4 c16 r2 |}

\score {
  {
    \notesOne
    \notesTwo
  }
}



Starting lilypond.exe 2.24.2 [test.ly]...

Processing `G:/My Drive/Sheet Music/Dobro/test.ly'

Parsing...

Interpreting music...

G:/My Drive/Sheet Music/Dobro/test.ly:25:41: warning: barcheck failed 
at: 1/16


notesTwo = { r4 \slideOutOf d''4 c16 r2

|}


Preprocessing graphical objects...

Finding the ideal number of pages...

Fitting music on 1 page...

Drawing systems...

Converting to `test.pdf'...

Success: compilation successfully completed

Completed successfully in 1.0".