Re: need help building a Scheme function

2024-06-25 Thread Lukas-Fabian Moser

[Sorry! I wrote this two days ago on a train in one of the famous German
cell connection dead zones - and then forgot to actually send it later.]

Hi Kieren,


The last "m" in your innermost (if ...) is unnecessary: As with the difference between "for" and 
"map" in plain Scheme, the return value of the lambda function in for-some-music gets discarded ("for" 
functions are supposed to _do_ something, not _return_ something). So your branch stating "... else return m" can be 
omitted.

Excellent.


Well, modulo David's correction. :-)

It's true that the lambda function in for-some-music isn't supposed to
return the music it has produced. But since its return value determines
(as a boolean) whether to recurse, we should make sure to

- return ##f if our music argument m is not a note-event (but might
contain one)
- return a true value if we don't want to recurse any further. Since
note-events usually don't contain any other music, this might never
actually matter, but it is good to also read your code in the note-event
case and check which value gets returned in which case.

It might be worth noting that an (if condition then-clause) expression
without an else-clause returns and unspecified value if condition is #f.
https://www.gnu.org/software/guile/manual/html_node/Conditionals.html


Next, as you already hinted: If you use the same expression more than once 
(here (ly:music-property m 'pitch)), it is usually reasonably to store it in a 
variable, i.e. use (let ...).

Why wouldn’t I use let* here? I 
readhttps://extending-lilypond.gitlab.io/en/scheme/local-variables.html#let-syntax,
 and unless there’s some big-ticket efficiency problem under the hood, I don’t 
see why anyone would use let instead of let*.

I do not know if there are efficiency differences between let and let*
(but I doubt it). Personally, I use let if I don't need let*, since this
way, when I re-read my code, I immediately know that the let-assignments
do not depend on one another.



we rather want a list of pairs (old-pitch . new-pitch)

That’s the interface I was thinking of.


In order to construct such a list of pairs from two music inputs as above, (map 
...) provides a very elegant way.

In the case of a simple scale,

\adjustPitches scaleIn scaleOut

and then post-processing into lists, etc., makes some sense. But what about 
sending in pairs instead? e.g.

\adjustPitches ((ces c) (c b') (e g))

There would be the question of whether the user wants to process each pair 
consecutively (e.g., all ces become c, then all c [including the old ces] 
become b', etc.)… Maybe both options made available, with either a switch or 
optional parameter(s)?


The problem is that (ces c), or rather (ces . c), is Scheme syntax (and
requires ` and , when ces and c should not be taken as mere symbols),
but we don't have note name input in Scheme. So this would actually be
something like

(list (cons #{ ces #} #{ c #}) (cons #{ c #} #{ b #}))

or

`((,#{ ces #} . ,#{ c #}) (,#{ c #} . ,#{ b #}))

both of which make my brain hurt :-).

A way of inputting the pitches in LilyPond syntax might be much more
convenient. Possibilites that come to mind might be

{ ces c e } { c b' g }

{ ces c c b' e g }

{}

etc., all of which are comparatively easy to implement (the first one
probably being the easiest).

Lukas



Re: need help building a Scheme function

2024-06-23 Thread Kieren MacMillan
Hi Lukas!

Thanks for the patient and helpful tutorial(s).  :)

> The last "m" in your innermost (if ...) is unnecessary: As with the 
> difference between "for" and "map" in plain Scheme, the return value of the 
> lambda function in for-some-music gets discarded ("for" functions are 
> supposed to _do_ something, not _return_ something). So your branch stating 
> "... else return m" can be omitted.

Excellent.

> Next, as you already hinted: If you use the same expression more than once 
> (here (ly:music-property m 'pitch)), it is usually reasonably to store it in 
> a variable, i.e. use (let ...).

Why wouldn’t I use let* here? I read 
https://extending-lilypond.gitlab.io/en/scheme/local-variables.html#let-syntax, 
and unless there’s some big-ticket efficiency problem under the hood, I don’t 
see why anyone would use let instead of let*.

> Also some food for thought, if I may:
> - What if I want to replace each b by the c _above_ it?

Yes, you are thinking what I’m thinking, for the final version.  :)

> we rather want a list of pairs (old-pitch . new-pitch)

That’s the interface I was thinking of.

> In order to construct such a list of pairs from two music inputs as above, 
> (map ...) provides a very elegant way.

In the case of a simple scale,

   \adjustPitches scaleIn scaleOut

and then post-processing into lists, etc., makes some sense. But what about 
sending in pairs instead? e.g.

   \adjustPitches ((ces c) (c b') (e g))

There would be the question of whether the user wants to process each pair 
consecutively (e.g., all ces become c, then all c [including the old ces] 
become b', etc.)… Maybe both options made available, with either a switch or 
optional parameter(s)?

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: need help building a Scheme function

2024-06-23 Thread Lukas-Fabian Moser

The last "m" in your innermost (if ...) is unnecessary: As with the
difference between "for" and "map" in plain Scheme, the return value of
the lambda function in for-some-music gets discarded ("for" functions
are supposed to _do_ something, not _return_ something).

No, it doesn't.  It is a boolean that determines whether to recurse (#f)
or not (everything else).


Of course you're right, my bad. To be more precise:

- Plain Scheme (for ...) is indeed not supposed to return something but
rather do something.
- LilyPond's (for-some-music ...) is intended to i) do something, ii)
return a boolean indicating whether the recursion should continue (kind
of "is my work done in this branch of music?").

Of course that's what you explained, I just wanted to point out the
comparison with standard "for".

So @Kieren: In your example you should take care to control the return
value of your lambda (in particular, also in the else-branches of your
if's.)

Lukas


Re: need help building a Scheme function

2024-06-23 Thread Lukas-Fabian Moser

Hi David,


If you don't want to call upon undocumented internals of LilyPond (the
(@@ (lily) ...) bit), you can just use


[with-output-to-string]

Wow, thanks! I hadn't encountered this possibility yet.

Also thanks for pointing out the possibility of in-place modification.

Lukas


Re: need help building a Scheme function

2024-06-23 Thread Lukas-Fabian Moser

Hi Kieren,


for-some-music does not return music.  It works on music in-place.  So
the last thing in your music function must not be for-some-music but
rather the music that you have been working on.

So…

%%%  SNIPPET BEGINS
adjustPitch =
#(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?)
(for-some-music
 (lambda (m)
 (if (music-is-of-type? m 'note-event)
 (if (and (= (ly:pitch-notename (ly:music-property m 'pitch)) 
(ly:pitch-notename pitchIn))
   (= (ly:pitch-alteration (ly:music-property m 
'pitch)) (ly:pitch-alteration pitchIn)))
 (ly:music-set-property! m 'pitch
 (ly:make-pitch
  (ly:pitch-octave (ly:music-property m 
'pitch))
  (ly:pitch-notename pitchOut)
  (ly:pitch-alteration pitchOut)))
 m)
 #f))
 music)
 music)

testmusic = \fixed c' { c4 d es e f g c' es' eis }

{ \testmusic }

{ \adjustPitch ees e \testmusic }
%%%  SNIPPET ENDS

??


The last "m" in your innermost (if ...) is unnecessary: As with the
difference between "for" and "map" in plain Scheme, the return value of
the lambda function in for-some-music gets discarded ("for" functions
are supposed to _do_ something, not _return_ something). So your branch
stating "... else return m" can be omitted.

Next, as you already hinted: If you use the same expression more than
once (here (ly:music-property m 'pitch)), it is usually reasonably to
store it in a variable, i.e. use (let ...).

Also some food for thought, if I may:

- What if I want to replace each b by the c _above_ it?

- I've been thinking about a conventient user interface. If I understand
you correctly, you aim for something like a list of input-pitches and a
list of output-pitches, both preferably given as music, so we can do

\adjustPitch { c d e } { fis e d } \music

meaning: turn c into fis, d into e, and e into d. If I'm right, you'll
probably be able to make good use of (music-pitches ...). Also, for
search-and-replace tasks in Scheme, using an association list (alist) as
a dictionary is often convenient. This would mean we rather want a list
of pairs (old-pitch . new-pitch). In order to construct such a list of
pairs from two music inputs as above, (map ...) provides a very elegant way.

See also:

https://www.gnu.org/software/guile/manual/html_node/Association-Lists.html
https://www.gnu.org/software/guile/manual/html_node/List-Mapping.html

Lukas


Re: need help building a Scheme function

2024-06-22 Thread Kieren MacMillan
Hi David,

> for-some-music does not return music.  It works on music in-place.  So
> the last thing in your music function must not be for-some-music but
> rather the music that you have been working on.

So…

%%%  SNIPPET BEGINS
adjustPitch =
#(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?)
   (for-some-music
(lambda (m)
(if (music-is-of-type? m 'note-event)
(if (and (= (ly:pitch-notename (ly:music-property m 'pitch)) 
(ly:pitch-notename pitchIn))
  (= (ly:pitch-alteration (ly:music-property m 'pitch)) 
(ly:pitch-alteration pitchIn)))
(ly:music-set-property! m 'pitch
(ly:make-pitch
 (ly:pitch-octave (ly:music-property m 
'pitch))
 (ly:pitch-notename pitchOut)
 (ly:pitch-alteration pitchOut)))
m)
#f))
music)
music)

testmusic = \fixed c' { c4 d es e f g c' es' eis }

{ \testmusic }

{ \adjustPitch ees e \testmusic }
%%%  SNIPPET ENDS

??

Thanks,
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: need help building a Scheme function

2024-06-22 Thread David Kastrup
Kieren MacMillan  writes:

> I tried a few times, but got errors (about returning
> unspecified). Hints appreciated.

for-some-music does not return music.  It works on music in-place.  So
the last thing in your music function must not be for-some-music but
rather the music that you have been working on.

-- 
David Kastrup



Re: need help building a Scheme function

2024-06-22 Thread Kieren MacMillan
Hi David,

> This will also adjust eis and eses to e.  Note names are numbers and can
> be compared with = .  (make-music 'NoteEvent m) is silly and creates an
> unnecessary copy.  You can just use m instead.

Thanks — current version:

%%%  SNIPPET BEGINS
\version "2.25.11"

adjustPitch =
#(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?)
   (music-map
(lambda (m)
(if (music-is-of-type? m 'note-event)
(if (and (= (ly:pitch-notename (ly:music-property m 'pitch)) 
(ly:pitch-notename pitchIn))
  (= (ly:pitch-alteration (ly:music-property m 'pitch)) 
(ly:pitch-alteration pitchIn)))
(ly:music-set-property! m 'pitch
(ly:make-pitch
 (ly:pitch-octave (ly:music-property m 
'pitch))
 (ly:pitch-notename pitchOut)
 (ly:pitch-alteration pitchOut)))
m)
#f)
m)
music))

testmusic = \fixed c' { c4 d es e f g c' es' eis' }

{ \testmusic }

{ \adjustPitch ees e \testmusic }
%%%  SNIPPET ENDS

Q: Is there a more efficient way to test for note name and alteration 
independent of octave?

> If you do, you don't replace any music, so music-map is unnecessary.
> This can be better done with for-some-music .

I tried a few times, but got errors (about returning unspecified). Hints 
appreciated.

As for next step(s): I’m thinking some let-ing would make sense?

Thanks,
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: need help building a Scheme function

2024-06-22 Thread David Kastrup
Kieren MacMillan  writes:

> Hi again,
>
>> There is no necessity to return a new NoteEvent; you can just change
>> pitch on the existing one.
>> 
>> Music functions are allowed to modify their music arguments in place.
>
> This is what I have so far, which appears to do what I want:
>
> %%%  SNIPPET BEGINS
> \version "2.25.11"
>
> adjustPitch = 
> #(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? 
> ly:music?)
>(music-map
> (lambda (m)
> (if (music-is-of-type? m 'note-event)
> (if (equal? (ly:pitch-notename (ly:music-property m 'pitch)) 
> (ly:pitch-notename pitchIn))
> (ly:music-set-property! m 'pitch (ly:make-pitch 
> (ly:pitch-octave (ly:music-property m 'pitch)) (ly:pitch-notename pitchOut) 
> 0))
> (make-music 'NoteEvent m))
> (ly:message "Not of type"))
> m)
> music))
>
> \adjustPitch ees e \fixed c' { c4 d es f g c' es' }
> %%%  SNIPPET ENDS
>
> Comments before I move to the next step…?

This will also adjust eis and eses to e.  Note names are numbers and can
be compared with = .  (make-music 'NoteEvent m) is silly and creates an
unnecessary copy.  You can just use m instead.

If you do, you don't replace any music, so music-map is unnecessary.
This can be better done with for-some-music .

-- 
David Kastrup



Re: need help building a Scheme function

2024-06-22 Thread Kieren MacMillan
Hi again,

> There is no necessity to return a new NoteEvent; you can just change
> pitch on the existing one.
> 
> Music functions are allowed to modify their music arguments in place.

This is what I have so far, which appears to do what I want:

%%%  SNIPPET BEGINS
\version "2.25.11"

adjustPitch = 
#(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?)
   (music-map
(lambda (m)
(if (music-is-of-type? m 'note-event)
(if (equal? (ly:pitch-notename (ly:music-property m 'pitch)) 
(ly:pitch-notename pitchIn))
(ly:music-set-property! m 'pitch (ly:make-pitch 
(ly:pitch-octave (ly:music-property m 'pitch)) (ly:pitch-notename pitchOut) 0))
(make-music 'NoteEvent m))
(ly:message "Not of type"))
m)
music))

\adjustPitch ees e \fixed c' { c4 d es f g c' es' }
%%%  SNIPPET ENDS

Comments before I move to the next step…?

Thanks,
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: need help building a Scheme function

2024-06-22 Thread David Kastrup
Lukas-Fabian Moser  writes:

> Elaborating on David's explanation, it might be instructive to study the
> output of:
>
> \version "2.25.9"
>
> mappingFunction =
> #(define-music-function (music) (ly:music?)
>(music-map
> (lambda (m)
>   (ly:message "Considering music:\n~a\n-\n"
>   ((@@ (lily) music->lily-string) m))
>   m)
> music))
>
> \mappingFunction
> \new PianoStaff
> <<
>   \new Staff \relative { c'4 d e c }
>   \new Staff \relative { c' g c c }
>>>

If you don't want to call upon undocumented internals of LilyPond (the
(@@ (lily) ...) bit), you can just use

\version "2.25.9"

mappingFunction =
#(define-music-function (music) (ly:music?)
   (music-map
(lambda (m)
 (ly:message "Considering music:~a-\n"
  (with-output-to-string (lambda () (displayLilyMusic m
  m)
music))

\mappingFunction
\new PianoStaff
<<
  \new Staff \relative { c'4 d e c }
  \new Staff \relative { c' g c c }
>>


-- 
David Kastrup


Re: need help building a Scheme function

2024-06-22 Thread David Kastrup
Lukas-Fabian Moser  writes:

> But: Whether you use music-map or map-some-music, your helper function
> (your lambda) is expected to return the new music into which the given
> argument m should be transformed. So in any case, your lambda function
> should return music - in the trivial case, it could return m itself
> without change, but in the long run, you want to return a new
> note-event, i.e. (make-music 'NoteEvent ...).
>
> For this, it will come in handy that it's possible to do
>
> (make-music 'NoteEvent m)
>
> i.e. create a new NoteEvent that takes its 'pitch (which you're going to
> overwrite using an additional 'pitch ), 'articulation etc.
> properties from m. (This is explained somewhere in Jean's guide.)

There is no necessity to return a new NoteEvent; you can just change
pitch on the existing one.

Music functions are allowed to modify their music arguments in place.

-- 
David Kastrup



Re: need help building a Scheme function

2024-06-21 Thread Lukas-Fabian Moser

Hi Kieren,

Am 21.06.24 um 20:25 schrieb Kieren MacMillan:

Hi all,

Thank you for the rapid-iteration non-isochronous Scheme class!  :)

Before I do the next step, is this optimal at this point?

%%%  SNIPPET BEGINS
\version "2.25.11"

adjustPitch =
#(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?)
(music-map
 (lambda (m)
 (if (music-is-of-type? m 'note-event)
 (ly:message "Pitch is: ~a" (ly:music-property m 'pitch))
 #f)
 m)
 music))

\adjustPitch es es \fixed c' { c4 d e f g a b c' }
%%%  SNIPPET ENDS


While it's possible to use music-map, I'd still recommend
map-some-music: Instead of considering all the various music objects in
a tree (and then specialising to only considering note events),
map-some-music is tailor-made for applications where we want to reach a
specific type of music objects in our recursion and then, in each case,
declaring the job done, i.e. not recursing any further. (The actual
difference should be very small, since also music-map can't help but
stop recursing at note-events, since these don't contain other music
objects.)

But: Whether you use music-map or map-some-music, your helper function
(your lambda) is expected to return the new music into which the given
argument m should be transformed. So in any case, your lambda function
should return music - in the trivial case, it could return m itself
without change, but in the long run, you want to return a new
note-event, i.e. (make-music 'NoteEvent ...).

For this, it will come in handy that it's possible to do

(make-music 'NoteEvent m)

i.e. create a new NoteEvent that takes its 'pitch (which you're going to
overwrite using an additional 'pitch ), 'articulation etc.
properties from m. (This is explained somewhere in Jean's guide.)

Lukas




Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi Lukas,

> Elaborating on David's explanation, it might be instructive to study the 
> output of:
> [snip]
> In short: music-map really considers every music object in a music tree.

That was instructive — thanks!
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: need help building a Scheme function

2024-06-21 Thread Lukas-Fabian Moser

Hi Kieren,


I’m a little confused that the output of

%%%  SNIPPET BEGINS
\version "2.25.11"

adjustPitch =
#(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?)
(music-map
 (lambda (m)
   (ly:message "Pitch is: ~a" (ly:music-property m 'pitch)) m)
 music))

\adjustPitch es es \fixed c' { c4 d e f g a b c' }
%%%  SNIPPET ENDS

is

Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: ()
Pitch is: ()

What is causing the last two output lines?


Elaborating on David's explanation, it might be instructive to study the
output of:

\version "2.25.9"

mappingFunction =
#(define-music-function (music) (ly:music?)
   (music-map
    (lambda (m)
  (ly:message "Considering music:\n~a\n-\n"
  ((@@ (lily) music->lily-string) m))
  m)
    music))

\mappingFunction
\new PianoStaff
<<
  \new Staff \relative { c'4 d e c }
  \new Staff \relative { c' g c c }
>>

In short: music-map really considers every music object in a music tree.

Lukas


Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi David,

> To say something is "optimal", you have to state your objective.

I guess the immediate objective was to output [in the log] a list of pitches 
given the 'music' input.

> music-map is used for changing music, and you don't appear to do any
> useful changes to the music.  In fact, you replace note events with
> *undefined* which appears comparatively useless.
> 
> So what are you trying to achieve here?

The longer-term objective is to write

  \adjustMusic es e { c d es f g c' es' }

and get

  { c d e f g c' e' }

i.e., turn all E flats [at any octave] into E naturals.

Thanks,
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: need help building a Scheme function

2024-06-21 Thread David Kastrup
Kieren MacMillan  writes:

> Hi all,
>
> Thank you for the rapid-iteration non-isochronous Scheme class!  :)
>
> Before I do the next step, is this optimal at this point?
>
> %%%  SNIPPET BEGINS
> \version "2.25.11"
>
> adjustPitch = 
> #(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? 
> ly:music?)
>(music-map
> (lambda (m)
> (if (music-is-of-type? m 'note-event)
> (ly:message "Pitch is: ~a" (ly:music-property m 'pitch))
> #f)
> m)
> music))
>
> \adjustPitch es es \fixed c' { c4 d e f g a b c' }
> %%%  SNIPPET ENDS

To say something is "optimal", you have to state your objective.
music-map is used for changing music, and you don't appear to do any
useful changes to the music.  In fact, you replace note events with
*undefined* which appears comparatively useless.

So what are you trying to achieve here?

-- 
David Kastrup



Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi all,

Thank you for the rapid-iteration non-isochronous Scheme class!  :)

Before I do the next step, is this optimal at this point?

%%%  SNIPPET BEGINS
\version "2.25.11"

adjustPitch = 
#(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?)
   (music-map
(lambda (m)
(if (music-is-of-type? m 'note-event)
(ly:message "Pitch is: ~a" (ly:music-property m 'pitch))
#f)
m)
music))
   
\adjustPitch es es \fixed c' { c4 d e f g a b c' }
%%%  SNIPPET ENDS

Thanks,
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: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi David,

> If you want to only look at note events, you need to check for them
> yourself.  music-map is not discriminating.

Ah! Lovely Socratic lesson. :)

Thanks,
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: need help building a Scheme function

2024-06-21 Thread David Kastrup
Kieren MacMillan  writes:

> Hi again,
>
> I’m a little confused that the output of
>
> %%%  SNIPPET BEGINS
> \version "2.25.11"
>
> adjustPitch = 
> #(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? 
> ly:music?)
>(music-map
> (lambda (m)
>   (ly:message "Pitch is: ~a" (ly:music-property m 'pitch)) m)
> music))
>
> \adjustPitch es es \fixed c' { c4 d e f g a b c' }
> %%%  SNIPPET ENDS
>
> is
>
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: ()
> Pitch is: ()
>
> What is causing the last two output lines?

Well, what do you think should be the pitch of

{ c4 d e f g a b c' }

and of

\fixed c' { c4 d e f g a b c' }

?

If you want to only look at note events, you need to check for them
yourself.  music-map is not discriminating.

-- 
David Kastrup



Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi Timothy,

> Your lambda function for the mapping returns the value of ly:message, which 
> is #. You need to return some music. Changing the lambda 
> function to
> (lambda (m)
>   (ly:message "Pitch is: ~a" (ly:music-property m 'pitch)) m)
> maps the music to itself without any changes.

Oh! I see that now.

Thanks!
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: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi again,

I’m a little confused that the output of

%%%  SNIPPET BEGINS
\version "2.25.11"

adjustPitch = 
#(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?)
   (music-map
(lambda (m)
  (ly:message "Pitch is: ~a" (ly:music-property m 'pitch)) m)
music))

\adjustPitch es es \fixed c' { c4 d e f g a b c' }
%%%  SNIPPET ENDS

is

Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: #
Pitch is: ()
Pitch is: ()

What is causing the last two output lines?

Thanks,
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: need help building a Scheme function

2024-06-21 Thread Timothy Lanfear

On 21/06/2024 17:36, Kieren MacMillan wrote:

Hi Lukas!

All right… already back for more specific help.

I struggled with map-some-music, and failed. Scanned through Jean’s [amazing] 
“Extending” docs — yes, yes, I need to RTM on that one, page-by-page! — and 
found an example with music-map, so tried that instead. Also failed.

Your lambda function for the mapping returns the value of ly:message, 
which is #. You need to return some music. Changing the 
lambda function to


(lambda (m) (ly:message "Pitch is: ~a" (ly:music-property m 'pitch)) m)

maps the music to itself without any changes.

--
Timothy Lanfear, Bristol, UK.


Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi Lukas!

All right… already back for more specific help.

I struggled with map-some-music, and failed. Scanned through Jean’s [amazing] 
“Extending” docs — yes, yes, I need to RTM on that one, page-by-page! — and 
found an example with music-map, so tried that instead. Also failed.

%%%  SNIPPET BEGINS
\version "2.25.11"

adjustPitch = 
#(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?)
   (music-map
(lambda (m)
  (ly:message "Pitch is: ~a" (ly:music-property m 'pitch)))
music))

melody = {
  c'2 g'2 es'2. d'4 |
  c' es' d' c' |
  b d' g2
}

\adjustPitch es es \fixed c' { c d e f g a b c' }
%%%  SNIPPET ENDS

Helps/Hints appreciated.
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: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi L-F!

>> Is map-some-music the correct next move?
> Yes.

Thanks!

> I take it you're only asking for confirmation you're on the right track? :-)

Correct. I’ll try to ask more specific questions when I need more than 
confirmation.

> So I only suggest use the ly:pitch? predicate for pitchIn/pitchOut instead of 
> ly:music?.

Good point. I *think* I eventually want to allow a set (array?) of pitches 
in/out, but for now, I’ll start the input as small as the output.

Thanks!
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: need help building a Scheme function

2024-06-21 Thread Lukas-Fabian Moser

Hi Kieren,

Am 21.06.24 um 16:39 schrieb Kieren MacMillan:

%%%  SNIPPET BEGINS
\version "2.25.11"

adjustPitch =
#(define-music-function (pitchIn pitchOut music) (ly:music? ly:music? ly:music?)
(ly:message "Pitch is: ~a" (ly:pitch-notename (ly:music-property pitchIn 
'pitch)))
music)

melody = {
   c'2 g'2 es'2. d'4 |
   c' es' d' c' |
   b d' g2
}

\adjustPitch es es \fixed c' { c d e f g a b c' }
%%%  SNIPPET ENDS

This does exactly what it says on the can. Now I want to “map” the message 
[stand-in] function to the music provided, so it outputs the pitch for each 
note in the 'music' input.

Is map-some-music the correct next move?


Yes. I take it you're only asking for confirmation you're on the right
track? :-)

So I only suggest use the ly:pitch? predicate for pitchIn/pitchOut
instead of ly:music?.

Lukas


Re: Need help displaying note names in 2.22

2023-08-08 Thread Viktor Mastoridis
Dear all,

Thank you very much for the time taken to comment on my problem.

I tried all the suggestions one by one - the best solution was to upgrade
to Lilypond 2.24 (much easier than I thought) and to use Jean's code below:

\version "2.24.1"

\layout {
  \context {
\NoteNames
noteNameFunction =
  #(lambda args
 #{ \markup \with-string-transformer #(lambda (layout props str)
(string-upcase str))
#(apply note-name-markup args) #})
  }
}

music = \relative c { c, cis d es }

\score {
 <<
\new TabStaff \with {
  stringTunings = #bass-tuning
}
{ \music  }
\new NoteNames { \music }
  >>
  \layout { }
  \midi { }
}

---
Viktor Mastoridis





On Mon, 7 Aug 2023 at 19:04, Jean Abou Samra  wrote:

> Le lundi 07 août 2023 à 19:00 +0100, Viktor Mastoridis a écrit :
>
> How do I upgrade to Lilypond 2.24 on Mint 21 (Ubuntu LTS 22.4) without
> braking the system?
>
>
>
>
> Just follow the tutorial, it will not interfere with the system in any way.
>
>
> https://lilypond.org/doc/v2.24/Documentation/learning/graphical-setup-under-gnu_002flinux.html
>
>
> (You presumably already have Frescobaldi, so you don't need that part,
> only the part where it explains how to add a new LilyPond version to
> Frescobaldi.)
>


Re: Need help displaying note names in 2.22

2023-08-07 Thread Jean Abou Samra
Le lundi 07 août 2023 à 19:00 +0100, Viktor Mastoridis a écrit :
> How do I upgrade to Lilypond 2.24 on Mint 21 (Ubuntu LTS 22.4) without braking
> the system?



Just follow the tutorial, it will not interfere with the system in any way.

https://lilypond.org/doc/v2.24/Documentation/learning/graphical-setup-under-gnu_002flinux.html


(You presumably already have Frescobaldi, so you don't need that part, only the
part where it explains how to add a new LilyPond version to Frescobaldi.)


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


Re: Need help displaying note names in 2.22

2023-08-07 Thread Viktor Mastoridis
On Sunday, 6 August 2023, Jean Abou Samra  wrote:

> Oops, except that this is not going to work in 2.22, since
> \with-string-transformer is new in 2.24.
>
> However, 2.22 is not supported anymore, I would recommend upgrading to
> 2.24 anyway.
>

How do I upgrade to Lilypond 2.24 on Mint 21 (Ubuntu LTS 22.4) without
braking the system?

Viktor


-- 
Viktor Mastoridis


Re: Need help displaying note names in 2.22

2023-08-06 Thread Silvain Dupertuis

Le 06.08.23 à 16:59, David Kastrup a écrit :

Strange...
I tried a few things, but did not find a way to make it work.

I noticed  2 things :

1. In this association table :
chimenames =
#`(
     ("c" . "C")
     ("cis" . "C♯")
     ("d" . "D")
     ("es" . "E♭")
)
It only takes into account notes of names with one single character as
the default-name, but it does print the new-note if it has more
characters. I do not understand why...

Note names have changed to use ♯ and ♭ characters, so you need to look
up "c♯" instead of "cis".


I do not understand...

"c♯"
- is not recognized in the music description only "cis" works
- it is not recognized either in the table as (markup->string (ly:grob-property 
grob 'text))
in the associative table either,

--
Silvain Dupertuis
Route de Lausanne 335
1293 Bellevue (Switzerland)
tél. +41-(0)22-774.20.67
portable +41-(0)79-604.87.52
web: silvain-dupertuis.org 

Re: Need help displaying note names in 2.22

2023-08-06 Thread Jean Abou Samra
Oops, except that this is not going to work in 2.22, since \with-string-
transformer is new in 2.24.

However, 2.22 is not supported anymore, I would recommend upgrading to 2.24
anyway.


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


Re: Need help displaying note names in 2.22

2023-08-06 Thread Jean Abou Samra
Le dimanche 06 août 2023 à 18:36 +0200, Robin Bannister a écrit :

> David Kastrup wrote:
> 
> 
> > Note names have changed to use ♯ and ♭ characters, so you need to look
> > up "c♯" instead of "cis".
> 
> 
> I got no hits that way.


That's because the sharp sign is printed with \markup \accidental in the text 
property, i.e., (ly:grob-property grob 'text), but \accidental does not yet 
have a markup->string handler giving Unicode accidental characters.

Michael's solution works, but it will nullify the effect of certain 
NoteNames-specific properties like printOctaveNames.

I think the best solution here is

```
\version "2.24.1"

\layout {
  \context {
\NoteNames
noteNameFunction =
  #(lambda args
 #{ \markup \with-string-transformer #(lambda (layout props str) 
(string-upcase str))
#(apply note-name-markup args) #})
  }
}

music = \relative c { c, cis d es }

\score {
 <<
\new TabStaff \with {
  stringTunings = #bass-tuning
}  
{ \music  }
\new NoteNames { \music }
  >>
  \layout { }
  \midi { }
}
```

Best

Jean


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


Re: Need help displaying note names in 2.22

2023-08-06 Thread Robin Bannister

David Kastrup wrote:


Note names have changed to use ♯ and ♭ characters, so you need to look
up "c♯" instead of "cis".


I got no hits that way.

An alternative is to add
   printAccidentalNames = #'lily
to the NoteNames \with.



And if I change the "es" lookup key to the more canonical "ees" it finds 
the corresponding markup instead of returning the errored #f.




Cheers,
Robin



Re: Need help displaying note names in 2.22

2023-08-06 Thread Michael Werner
Hi Victor,

On Sat, Aug 5, 2023 at 7:12 PM Viktor Mastoridis <
viktor.mastori...@gmail.com> wrote:

> Hello,
>
> I have been using the syntax below for several years; the last code update
> I did was in December 2022, and it worked well since.
> Today I noticed that I can't get the sharp/flat note names properly.
> C# & Eb are not displayed.
> Can you please help?
> ---
>
>
> \version "2.22.1"
> chimenames =
> #`(
> ("c" . "C")
> ("cis" . "C♯")
>("d" . "D")
>   ("es" . "E♭")
>)
>
> ChimeNoteNames =
> #(lambda (grob)
> (let* ((default-name (markup->string (ly:grob-property grob 'text)))
>(new-name (assoc-get default-name chimenames)))
>   (ly:grob-set-property! grob 'text new-name)
> (ly:text-interface::print grob)))
>

Is the main idea here to just get the note names displayed in uppercase? If
so, I've been doing basically the same thing with this:

\version "2.25.6"

music = \relative c { c, cis d es }

\score
{
  <<
\new TabStaff
\with {
  stringTunings = #bass-tuning
}
{ \music  }

\new NoteNames {
  \set noteNameFunction = #(lambda (pitch ctx)
 (markup #:sans (note-name->markup pitch #f))
 )

  \music
}
  >>
  \layout { }  \midi { }
}

It might not be perfect but it gets the job done. For reference, the
note-name->markup function reference is:

*Function:* *note-name->markup** pitch lowercase?*

Return pitch markup for pitch, including accidentals printed as glyphs. If
lowercase? is set to false, the note names are capitalized.
-- 
Michael


Re: Need help displaying note names in 2.22

2023-08-06 Thread David Kastrup
Silvain Dupertuis  writes:

> Strange...
> I tried a few things, but did not find a way to make it work.
>
> I noticed  2 things :
>
> 1. In this association table :
> chimenames =
> #`(
>     ("c" . "C")
>     ("cis" . "C♯")
>     ("d" . "D")
>     ("es" . "E♭")
> )
> It only takes into account notes of names with one single character as
> the default-name, but it does print the new-note if it has more
> characters. I do not understand why...

Note names have changed to use ♯ and ♭ characters, so you need to look
up "c♯" instead of "cis".

> 2. In my version (2.24), I get a warning of a deprecated syntax for
> the expression
> {\override NoteName #'stencil = #ChimeNoteNames }
> saying it should be written with a dot notation
> {\override NoteName.#'stencil = #ChimeNoteNames }
> and the warning disappear with this notation

Ugh.  Please just write NoteName.stencil here.  This is 2.18+ syntax.

-- 
David Kastrup



Re: Need help displaying note names in 2.22

2023-08-06 Thread Silvain Dupertuis

Strange...
I tried a few things, but did not find a way to make it work.

I noticed  2 things :

1. In this association table :
chimenames =
#`(
    ("c" . "C")
    ("cis" . "C♯")
    ("d" . "D")
    ("es" . "E♭")
)
It only takes into account notes of names with one single character as the default-name, 
but it does print the new-note if it has more characters. I do not understand why...


2. In my version (2.24), I get a warning of a deprecated syntax for the 
expression
{\override NoteName #'stencil = #ChimeNoteNames }
saying it should be written with a dot notation
{\override NoteName.#'stencil = #ChimeNoteNames }
and the warning disappear with this notation


Le 06.08.23 à 01:11, Viktor Mastoridis a écrit :

Hello,

I have been using the syntax below for several years; the last code update I did was in 
December 2022, and it worked well since.

Today I noticed that I can't get the sharp/flat note names properly.
C# & Eb are not displayed.
Can you please help?
---


\version "2.22.1"
chimenames =
#`(
    ("c" . "C")
    ("cis" . "C♯")
   ("d" . "D")
      ("es" . "E♭")
   )

ChimeNoteNames =
#(lambda (grob)
    (let* ((default-name (markup->string (ly:grob-property grob 'text)))
           (new-name (assoc-get default-name chimenames)))
          (ly:grob-set-property! grob 'text new-name)
    (ly:text-interface::print grob)))

music = \relative c { c, cis d es }

\score
{
 <<
    \new TabStaff
    \with {
      stringTunings = #bass-tuning
    }
      { \music  }

    \new NoteNames \with {\override NoteName #'stencil = #ChimeNoteNames }
    { \music }
  >>
  \layout { }  \midi { }
}


---
Viktor Mastoridis





--
Silvain Dupertuis
Route de Lausanne 335
1293 Bellevue (Switzerland)
tél. +41-(0)22-774.20.67
portable +41-(0)79-604.87.52
web: silvain-dupertuis.org 

Re: Need help using math in markup command definition, and a feature request.

2023-05-09 Thread Jean Abou Samra
Le mardi 09 mai 2023 à 08:14 +, Werner LEMBERG a écrit :

> Yes, evaluated, sorry.

It is evaluated when baz is executed.

```
(define (foo bar)
  (define (baz)
(if bar "yes" "no"))
  (set! bar #t)
  (baz))

(foo #f) ⇒ "yes"
```




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


Re: Need help using math in markup command definition, and a feature request.

2023-05-09 Thread Werner LEMBERG
>> 
>> D'oh, this should be
>> 
>> ```
>> (define (foo bar)
>>   (define (baz)
>>     ...
>>     (if bar)    ; Is 'bar' visible here?  If yes, when is
>>   ...   ; 'bar' expanded?  At the time 'baz' is
>>     ; defined? At the time 'baz' is executed?
>> ```
> 
> I don't understand your question re macro expansion, what do you
> mean? Or did you want to say “evaluated” (rather than
> “[macro-]expanded”)?

Yes, evaluated, sorry.


Werner


Re: Need help using math in markup command definition, and a feature request.

2023-05-09 Thread dfro

On 5/9/23 03:22, Jean Abou Samra wrote:


Le lundi 08 mai 2023 à 22:55 -0400, dfro a écrit :


Jean,

I think \translate-scaled will work for me! This is a wonderful 
tool.  In the following example, \concat allows me to get the symbols 
closer together. The -.2 values for x in /translate-scaled on the 
third \markup example do nothing. Is there a way to turn off 
collision avoidance in \markup? I know about \once \override 
TextScript.extra-offset = #'(0 . 0) , but that does not scale.


|\concat| is not the tool you want here. Basically, 
|\translate-scaled| moves the markup on an imaginary grid, but 
|\concat| then ignores the placement of the translated markup on this 
grid by realigning its left edge to the right edge of the previous 
element, to bring the two elements as close to each other as possible. 
Try this instead:


|\version "2.24.1" chord = \markup \overlay { C \translate-scaled 
#'(1.8 . .4) \fontsize #-1 \flat \fontsize #-2 \column { 
\translate-scaled #'(3.1 . 1.2) 7 \translate-scaled #'(3.1 . 2.5) 4 } 
} { \textLengthOn c1^\markup \fontsize #5 \chord c1^\markup \fontsize 
#10 \chord c1^\markup \fontsize #5 \chord } |


Jean,

That is a beautiful solution! Thank you, for helping me to discover 
\overlay and how it can be used!


And, thank you for the clear explanation of why to use it in stead of 
\concat.



Peace,

David


Re: Need help using math in markup command definition, and a feature request.

2023-05-09 Thread dfro

On 5/9/23 03:22, Jean Abou Samra wrote:


Le lundi 08 mai 2023 à 22:55 -0400, dfro a écrit :


Jean,

I think \translate-scaled will work for me! This is a wonderful 
tool.  In the following example, \concat allows me to get the symbols 
closer together. The -.2 values for x in /translate-scaled on the 
third \markup example do nothing. Is there a way to turn off 
collision avoidance in \markup? I know about \once \override 
TextScript.extra-offset = #'(0 . 0) , but that does not scale.


|\concat| is not the tool you want here. Basically, 
|\translate-scaled| moves the markup on an imaginary grid, but 
|\concat| then ignores the placement of the translated markup on this 
grid by realigning its left edge to the right edge of the previous 
element, to bring the two elements as close to each other as possible. 
Try this instead:


|\version "2.24.1" chord = \markup \overlay { C \translate-scaled 
#'(1.8 . .4) \fontsize #-1 \flat \fontsize #-2 \column { 
\translate-scaled #'(3.1 . 1.2) 7 \translate-scaled #'(3.1 . 2.5) 4 } 
} { \textLengthOn c1^\markup \fontsize #5 \chord c1^\markup \fontsize 
#10 \chord c1^\markup \fontsize #5 \chord } |




Re: Need help using math in markup command definition, and a feature request.

2023-05-09 Thread Jean Abou Samra
Le lundi 08 mai 2023 à 22:55 -0400, dfro a écrit :

>  
> Jean,
>  
> I think \translate-scaled will work for me! This is a wonderful tool.  In the 
> following example, \concat allows me to get the symbols closer together. The 
> -.2 values for x in /translate-scaled on the third \markup example do 
> nothing. Is there a way to turn off collision avoidance in \markup? I know 
> about \once \override TextScript.extra-offset = #'(0 . 0) , but that does not 
> scale.

`\concat` is not the tool you want here. Basically, `\translate-scaled` moves 
the markup on an imaginary grid, but `\concat` then ignores the placement of 
the translated markup on this grid by realigning its left edge to the right 
edge of the previous element, to bring the two elements as close to each other 
as possible. Try this instead:

```
\version "2.24.1"

chord =
\markup \overlay {
  C
  \translate-scaled #'(1.8 . .4) \fontsize #-1 \flat
  \fontsize #-2 \column {
\translate-scaled #'(3.1 . 1.2) 7
\translate-scaled #'(3.1 . 2.5) 4
  }
}

{ 
  \textLengthOn
  c1^\markup \fontsize #5 \chord
  c1^\markup \fontsize #10 \chord
  c1^\markup \fontsize #5 \chord
}
```


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


Re: Need help using math in markup command definition, and a feature request.

2023-05-08 Thread Jean Abou Samra
Le mardi 09 mai 2023 à 04:26 +, Werner LEMBERG a écrit :
> 
> D'oh, this should be
> 
> ```
> (define (foo bar)
>   (define (baz)
>     ...
>     (if bar)    ; Is 'bar' visible here?  If yes, when is
>   ...   ; 'bar' expanded?  At the time 'baz' is
>     ; defined? At the time 'baz' is executed?
> ```



I don't understand your question re macro expansion, what do you mean? Or did 
you want to say “evaluated” (rather than “[macro-]expanded”)?


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


Re: Need help using math in markup command definition, and a feature request.

2023-05-08 Thread Werner LEMBERG

> BTW, I suggest to cover one more issue with local variables, namely
> whether arguments to a function are seen in sub-functions, which are
> IMHO a very good addition to `let` and `let*` to write clean and
> readable code – often much more readable than anonymous lambda
> expressions.
> 
> Example:

D'oh, this should be

```
(define (foo bar)
  (define (baz)
...
(if bar); Is 'bar' visible here?  If yes, when is
  ...   ; 'bar' expanded?  At the time 'baz' is
; defined? At the time 'baz' is executed?
```


Werner


Re: Need help using math in markup command definition, and a feature request.

2023-05-08 Thread Werner LEMBERG

> Second, you need to use `let` here, not `define`. See
> 
> https://extending-lilypond.gitlab.io/en/scheme/local-variables.html

BTW, I suggest to cover one more issue with local variables, namely
whether arguments to a function are seen in sub-functions, which are
IMHO a very good addition to `let` and `let*` to write clean and
readable code – often much more readable than anonymous lambda
expressions.

Example:

```
(define (foo bar)
  (define (baz)
...
(if bar); Is 'bar' visible?  If yes, when is 'bar'
  ...   ; expanded?  At the time 'foofoo' is defined?
; At the time 'foofoo' is executed?
```


Werner


Re: Need help using math in markup command definition, and a feature request.

2023-05-08 Thread dfro

On 5/8/23 21:06, Jean Abou Samra wrote:


Le lundi 08 mai 2023 à 20:55 -0400, dfro a écrit :


Fellow music engravers,

I have a feature request. Perhaps, this has been discussed already.

Sometimes, I would like the spacial formatting in a \markup command 
to respond to changes in fontsize, so that all of the \markup spacing 
will change proportional to the change in fontsize. I think having 
\markup formatting commands - like \fs-raise, \fs-lower, \fs-hspace, 
\fs-vspace, etc. - that respond to changes in \fontsize would be helpful.


First: have you seen the |\translate-scaled| markup command? It fits 
the bill in most cases.


Assuming you still want to write custom Scheme code:

I am trying to make a basic define-markup-command function for \raise 
that would do this for whole number fontsizes, but I do not know how 
to add math to markup command definitions. Here is my non-working 
code sketch, so far.


|``` \version "2.24.1"

%global font-size variable font-size = #0 %#1

|

|

Instead of using a global variable, it is better to read the font size 
inside the markup command. That makes the command usable in several 
places in the file with different font sizes. For an example, see the 
definition of |\translate-scaled| in the source code:


https://gitlab.com/lilypond/lilypond/-/blob/master/scm/define-markup-commands.scm#L5151

%fs-raise definition #(define-markup-command (fs-raise layout props 
rs text1) (number? markup?)     (interpret-markup layout props 
  (cond


   ((equal? font-size 0)     
; I want to create variable r = rs * 1, like this, which does not 
work, #(define r (* 1 rs))


First, you should not put a |#| character before the Scheme 
expression. In LilyPond, the |#| switches to Scheme mode, but here, 
you are already inside a Scheme expression (through the initial |#| in 
|#(define-markup-command ...|).


The |#| character is also used by the Scheme language itself; 
specifically; |#(...)| is a vector literal. That's not what you want here.


Second, you need to use |let| here, not |define|. See

https://extending-lilypond.gitlab.io/en/scheme/local-variables.html

|



Jean,

I think \translate-scaled will work for me! This is a wonderful tool.  
In the following example, \concat allows me to get the symbols closer 
together. The -.2 values for x in /translate-scaled on the third \markup 
example do nothing. Is there a way to turn off collision avoidance in 
\markup? I know about \once \override TextScript.extra-offset = #'(0 . 
0) , but that does not scale.




\version "2.24.1"

{
  \textLengthOn
  c1^\markup \fontsize #5 { \concat { C \translate-scaled #'(.2 . .4) 
\fontsize #-1 \flat \fontsize #-2 \column { \translate-scaled #'(.1 . 
1.2) 7 \translate-scaled #'(.1 . 2.5) 4 } } }
  c1^\markup \fontsize #10 { \concat { C \translate-scaled #'(.2 . .4) 
\fontsize #-1 \flat \fontsize #-2 \column { \translate-scaled #'(.1 . 
1.2) 7 \translate-scaled #'(.1 . 2.5) 4 } } }
  c1^\markup \fontsize #5 { C \translate-scaled #'(-.2 . .5) \fontsize 
#-2 \flat \translate-scaled #'(-.2 . .6) \fontsize #-2 7 }

}



Thank you, for the link to the Extending Lilypond website. I figured 
that I would have to learn about let or lambda. I also thought using # 
in the function was wrong, but it made a lot of errors go away when I 
was trying things.


Also, I agree that passing the fontsize to the function directly, rather 
than using a global variable, is more usable.



Peace,

David



Re: Need help using math in markup command definition, and a feature request.

2023-05-08 Thread Jean Abou Samra
Le lundi 08 mai 2023 à 20:55 -0400, dfro a écrit :

> Fellow music engravers,
> 
> I have a feature request. Perhaps, this has been discussed already.
>
> Sometimes, I would like the spacial formatting in a \markup command to 
> respond to changes in fontsize, so that all of the \markup spacing will 
> change proportional to the change in fontsize. I think having \markup 
> formatting commands - like \fs-raise, \fs-lower, \fs-hspace, \fs-vspace, 
> etc. - that respond to changes in \fontsize would be helpful.


First: have you seen the `\translate-scaled` markup command? It fits the bill 
in most cases.

Assuming you still want to write custom Scheme code:

> I am 
> trying to make a basic define-markup-command function for \raise that 
> would do this for whole number fontsizes, but I do not know how to add 
> math to markup command definitions. Here is my non-working code sketch, 
> so far.
> 
> 
> 
> ```
> \version "2.24.1"
> 
> %global font-size variable
> font-size =
> #0
> %#1

Instead of using a global variable, it is better to read the font size inside 
the markup command. That makes the command usable in several places in the file 
with different font sizes. For an example, see the definition of 
`\translate-scaled` in the source code:

https://gitlab.com/lilypond/lilypond/-/blob/master/scm/define-markup-commands.scm#L5151



> %fs-raise definition
> #(define-markup-command (fs-raise layout props rs text1) (number? markup?)
>     (interpret-markup layout props
>   (cond
> 
>    ((equal? font-size 0)
>     ; I want to create variable r = rs * 1, like 
> this, which does not work, #(define r (* 1 rs))


First, you should not put a `#` character before the Scheme expression. In 
LilyPond, the `#` switches to Scheme mode, but here, you are already inside a 
Scheme expression (through the initial `#` in `#(define-markup-command ...`).

The `#` character is also used by the Scheme language itself; specifically; 
`#(...)` is a vector literal. That's not what you want here.

Second, you need to use `let` here, not `define`. See

https://extending-lilypond.gitlab.io/en/scheme/local-variables.html



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


Re: Need help with usage of breve

2022-12-23 Thread Jean Abou Samra

Le 23/12/2022 à 16:50, Dave Seidel a écrit :

fis1\breve




This contains

- fis : a pitch,
- 1 : a duration, whole note,
- \breve : another duration, breve.

Therefore, the "fis" and "1" go together, as pitches and durations
always do, and the "\breve" is alone without a pitch, which tells
LilyPond to use the previous pitch, as if you had written

fis1 fis\breve

So you just need to remove this spurious "1".

Best,
Jean




OpenPGP_signature
Description: OpenPGP digital signature


Re: need help with 2.22 on mac

2022-12-12 Thread Flaming Hakama by Elaine
> As I mentioned, I did try 2.23, and I applied convert-ly to all my files.
>>
>
> The problem I ran into was:
>
> Preprocessing graphical objects...ERROR: In procedure
> %resolve-variable:
> Unbound variable: laissez-vibrer::print
>
> However, unlike most of the previous errors that could be fixed,
> because they tell you a file name and line number and the offending code,
> this error does not tell me a file name nor line number.
>
>
>
>
> It likely will if you add at the top of your .ly file, before any includes:
>
> #(ly:set-option 'compile-scheme-code)
>
> (Caveat for other people reading this list: this does not work on Windows
> currently.)
>
>
> Without that, I don't know how to address the issue.
> I don't really write scheme code, so it is unlikely to be something I
> wrote.
> I have cut & pasted some scheme code from LSR into some libraries I
> include,
> but I did convert-ly on those already.
>
>
> How to address the issue is what I tried to explain above.
>
> You need to find where your code uses "laissez-vibrer::print"
> (compile-scheme-code should help to pinpoint it), and replace that with
> "ly:tie::print".
>
> Also, has \laissezVibrer changed since 2.22?
> Does that even sound like something that would be related to the version
> upgrade?
>
>
> Yes. The syntax of \laissezVibrer has not changed but there was a minor
> change in its internals.
>
> Regards,
> Jean
>
>
> Le 12 déc. 2022 à 08:34, Flaming Hakama by Elaine <
> ela...@flaminghakama.com> a écrit :
> Thinking about this more, it is likely that I did install the previous
> 2.22 version from homebrew.
>
>
> Because it certainly was a lot slower than any previous version.
>
> I guess I'll try that again.
>
> Besides wanting/needing to work right now, IIUC, the next official release
> will as usual not support contemporary macs,
>
>
> It definitely will.
>
> and the homebrew version of 2.24 will also likely be as slow as homebrew
> 2.22--is there any reason to think the homebrew 2.24 version will be
> compiled differently?
>
>
> Yes. LilyPond 2.23 supports compiling Guile bytecode, 2.22 doesn’t.
>

Thanks for the help and explanation.
Great news that mac will finally be supported in the post-Guile 1.8 world.

I usually don't update versions unless there is a reason,
and getting rid of artificial slowness is certainly a good one
so I will likely follow all this advice once it hits the cask.


Thanks,

Elaine Alt
415 . 341 .4954   "*Confusion is
highly underrated*"
ela...@flaminghakama.com
Producer ~ Composer ~ Instrumentalist ~ Educator
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


Re: need help with 2.22 on mac

2022-12-11 Thread Jean Abou Samra

> Le 12 déc. 2022 à 08:34, Flaming Hakama by Elaine  
> a écrit :
> Thinking about this more, it is likely that I did install the previous 2.22 
> version from homebrew.
> 
> Because it certainly was a lot slower than any previous version.
> 
> I guess I'll try that again.  
> 
> Besides wanting/needing to work right now, IIUC, the next official release 
> will as usual not support contemporary macs,


It definitely will.


> and the homebrew version of 2.24 will also likely be as slow as homebrew 
> 2.22--is there any reason to think the homebrew 2.24 version will be compiled 
> differently? 


Yes. LilyPond 2.23 supports compiling Guile bytecode, 2.22 doesn’t.



Re: need help with 2.22 on mac

2022-12-11 Thread Jean Abou Samra
Le 12 déc. 2022 à 08:22, Flaming Hakama by Elaine  a écrit :On Sun, Dec 11, 2022 at 3:53 PM Jean Abou Samra  wrote:Le 12/12/2022 à 00:45, Flaming Hakama by Elaine a écrit :
> tl;dr:
>
> Does anyone have a download link of lilypond 2.22 that will work for 
> mac OS 12.6.1?
>
> I recently had to reinstall my mac OS.  It is now 12.6.1.
> Previously I had an earlier version of 12, most likley 12.1,
> based on the fact that the last time I had to do this was in January 2022.
> I had been running lilypond 2.22.2 successfully,
> and would like to run this version again.
>
> When running the version of lilypond 2.22
> that I get from the download page https://lilypond.org/macos-x.html
> I get the error "Bad CPU type in executable"
>
> I know that I previously did not build my own, nor use homebrew or 
> macports.
> But I don't recall where I downloaded it.
> Likely, from some hero who built it using macports then posted the binary.
>
> So, does anyone know where I can get a version of lilypond 2.22
> that might work for macos 12.6.1?
>
>
> (I did try the latest dev version, but even after fixing convert-ly 
> errors,
> it did not work for me.  Produced an error that I could not diagnose:
>
> Preprocessing graphical objects...ERROR: In procedure %resolve-variable:
> Unbound variable: laissez-vibrer::print)



The 2.24 stable release is going to happen next week, so I would 
recommend not chasing a working 2.22 version but just upgrading to 2.23.82.

Your error sounds like you have some Scheme code that uses 
laissez-vibrer::print, and it will probably work if you replace that 
with ly:tie::print, and if that doesn't work, show the code so we can help.

Best,
Jean
As I mentioned, I did try 2.23, and I applied convert-ly to all my files.The problem I ran into was:    Preprocessing graphical objects...ERROR: In procedure %resolve-variable:    Unbound variable: laissez-vibrer::printHowever, unlike most of the previous errors that could be fixed, because they tell you a file name and line number and the offending code, this error does not tell me a file name nor line number.It likely will if you add at the top of your .ly file, before any includes:#(ly:set-option 'compile-scheme-code)(Caveat for other people reading this list: this does not work on Windows currently.)Without that, I don't know how to address the issue.I don't really write scheme code, so it is unlikely to be something I wrote.I have cut & pasted some scheme code from LSR into some libraries I include, but I did convert-ly on those already.How to address the issue is what I tried to explain above.You need to find where your code uses "laissez-vibrer::print" (compile-scheme-code should help to pinpoint it), and replace that with "ly:tie::print".Also, has \laissezVibrer changed since 2.22?Does that even sound like something that would be related to the version upgrade?Yes. The syntax of \laissezVibrer has not changed but there was a minor change in its internals.Regards,Jean


Re: need help with 2.22 on mac

2022-12-11 Thread Flaming Hakama by Elaine
On Sun, Dec 11, 2022 at 10:28 PM Jean Abou Samra  wrote:

> Le 12/12/2022 à 03:51, Mark Probert a écrit :
> > The brew collection has lily pond at 2.22.2 (with Guile 2.2).
> >
> > If you already have brew installed then it is simply a matter of, from
> > the command line, running
> >
> >  $ brew install lilypond
> >
> > Hope this helps.
>
>
> I would recommend against this, because LilyPond 2.22 from
> Homebrew is known to be quite slow (due to using Guile 2
> without compiled bytecode).
>
> Best,
> Jean
>
>
Thinking about this more, it is likely that I did install the previous 2.22
version from homebrew.

Because it certainly was a lot slower than any previous version.

I guess I'll try that again.

Besides wanting/needing to work right now, IIUC, the next official release
will as usual not support contemporary macs, and the homebrew version of
2.24 will also likely be as slow as homebrew 2.22--is there any reason to
think the homebrew 2.24 version will be compiled differently?

So, eventually, I would still be interested if anyone has a 2.22, 2.23, or
2.24 version built using macports to share.


Thanks,

Elaine Alt
415 . 341 .4954   "*Confusion is
highly underrated*"
ela...@flaminghakama.com
Producer ~ Composer ~ Instrumentalist ~ Educator
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


Re: need help with 2.22 on mac

2022-12-11 Thread Flaming Hakama by Elaine
On Sun, Dec 11, 2022 at 3:53 PM Jean Abou Samra  wrote:

> Le 12/12/2022 à 00:45, Flaming Hakama by Elaine a écrit :
> > tl;dr:
> >
> > Does anyone have a download link of lilypond 2.22 that will work for
> > mac OS 12.6.1?
> >
> > I recently had to reinstall my mac OS.  It is now 12.6.1.
> > Previously I had an earlier version of 12, most likley 12.1,
> > based on the fact that the last time I had to do this was in January
> 2022.
> > I had been running lilypond 2.22.2 successfully,
> > and would like to run this version again.
> >
> > When running the version of lilypond 2.22
> > that I get from the download page https://lilypond.org/macos-x.html
> > I get the error "Bad CPU type in executable"
> >
> > I know that I previously did not build my own, nor use homebrew or
> > macports.
> > But I don't recall where I downloaded it.
> > Likely, from some hero who built it using macports then posted the
> binary.
> >
> > So, does anyone know where I can get a version of lilypond 2.22
> > that might work for macos 12.6.1?
> >
> >
> > (I did try the latest dev version, but even after fixing convert-ly
> > errors,
> > it did not work for me.  Produced an error that I could not diagnose:
> >
> > Preprocessing graphical objects...ERROR: In procedure %resolve-variable:
> > Unbound variable: laissez-vibrer::print)
>
>
>
> The 2.24 stable release is going to happen next week, so I would
> recommend not chasing a working 2.22 version but just upgrading to 2.23.82.
>
> Your error sounds like you have some Scheme code that uses
> laissez-vibrer::print, and it will probably work if you replace that
> with ly:tie::print, and if that doesn't work, show the code so we can help.
>
> Best,
> Jean
>
>
As I mentioned, I did try 2.23, and I applied convert-ly to all my files.

The problem I ran into was:

Preprocessing graphical objects...ERROR: In procedure %resolve-variable:
Unbound variable: laissez-vibrer::print

However, unlike most of the previous errors that could be fixed,
because they tell you a file name and line number and the offending code,
this error does not tell me a file name nor line number.

Without that, I don't know how to address the issue.
I don't really write scheme code, so it is unlikely to be something I wrote.
I have cut & pasted some scheme code from LSR into some libraries I
include,
but I did convert-ly on those already.

Also, has \laissezVibrer changed since 2.22?
Does that even sound like something that would be related to the version
upgrade?

I'm guessing it is because the build from the website is not usable on mac
os 12.
Which I suppose is expected, as the page says that it is only for mac os 10.


Thanks,

Elaine Alt
415 . 341 .4954   "*Confusion is
highly underrated*"
ela...@flaminghakama.com
Producer ~ Composer ~ Instrumentalist ~ Educator
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


Re: need help with 2.22 on mac

2022-12-11 Thread Jean Abou Samra

Le 12/12/2022 à 03:51, Mark Probert a écrit :

The brew collection has lily pond at 2.22.2 (with Guile 2.2).

If you already have brew installed then it is simply a matter of, from 
the command line, running


 $ brew install lilypond

Hope this helps.



I would recommend against this, because LilyPond 2.22 from
Homebrew is known to be quite slow (due to using Guile 2
without compiled bytecode).

Best,
Jean



OpenPGP_signature
Description: OpenPGP digital signature


Re: need help with 2.22 on mac

2022-12-11 Thread Mark Probert
 The brew collection has lily pond at 2.22.2 (with Guile 2.2).

If you already have brew installed then it is simply a matter of, from the
command line, running

 $ brew install lilypond

Hope this helps.

-mark.


On 12 Dec 2022 at 10:45:41, Flaming Hakama by Elaine <
ela...@flaminghakama.com> wrote:

> tl;dr:
>
> Does anyone have a download link of lilypond 2.22 that will work for mac
> OS 12.6.1?
>
>
> I recently had to reinstall my mac OS.  It is now 12.6.1.
> Previously I had an earlier version of 12, most likley 12.1,
> based on the fact that the last time I had to do this was in January 2022.
> I had been running lilypond 2.22.2 successfully,
> and would like to run this version again.
>
> When running the version of lilypond 2.22
> that I get from the download page https://lilypond.org/macos-x.html
> I get the error "Bad CPU type in executable"
>
> I know that I previously did not build my own, nor use homebrew or
> macports.
> But I don't recall where I downloaded it.
> Likely, from some hero who built it using macports then posted the binary.
>
> So, does anyone know where I can get a version of lilypond 2.22
> that might work for macos 12.6.1?
>
>
> (I did try the latest dev version, but even after fixing convert-ly
> errors,
> it did not work for me.  Produced an error that I could not diagnose:
>
> Preprocessing graphical objects...ERROR: In procedure %resolve-variable:
> Unbound variable: laissez-vibrer::print)
>
>
> Thanks,
>
> Elaine Alt
> 415 . 341 .4954   "Confusion is
> highly underrated"
> ela...@flaminghakama.com
> Producer ~ Composer ~ Instrumentalist ~ Educator
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
>


Re: need help with 2.22 on mac

2022-12-11 Thread Jean Abou Samra

Le 12/12/2022 à 00:45, Flaming Hakama by Elaine a écrit :

tl;dr:

Does anyone have a download link of lilypond 2.22 that will work for 
mac OS 12.6.1?


I recently had to reinstall my mac OS.  It is now 12.6.1.
Previously I had an earlier version of 12, most likley 12.1,
based on the fact that the last time I had to do this was in January 2022.
I had been running lilypond 2.22.2 successfully,
and would like to run this version again.

When running the version of lilypond 2.22
that I get from the download page https://lilypond.org/macos-x.html
I get the error "Bad CPU type in executable"

I know that I previously did not build my own, nor use homebrew or 
macports.

But I don't recall where I downloaded it.
Likely, from some hero who built it using macports then posted the binary.

So, does anyone know where I can get a version of lilypond 2.22
that might work for macos 12.6.1?


(I did try the latest dev version, but even after fixing convert-ly 
errors,

it did not work for me.  Produced an error that I could not diagnose:

Preprocessing graphical objects...ERROR: In procedure %resolve-variable:
Unbound variable: laissez-vibrer::print)




The 2.24 stable release is going to happen next week, so I would 
recommend not chasing a working 2.22 version but just upgrading to 2.23.82.


Your error sounds like you have some Scheme code that uses 
laissez-vibrer::print, and it will probably work if you replace that 
with ly:tie::print, and if that doesn't work, show the code so we can help.


Best,
Jean



OpenPGP_signature
Description: OpenPGP digital signature


Re: Need help with two tweaks

2022-10-01 Thread Valentin Petzel
Hello Sam,

for 1) you can do something like

\layout {
  \context {
\Staff
\remove Dot_column_engraver
  }
  \context {
\Voice
\consists Dot_column_engraver
  }
}

<<
  { 2. } \\
  { \once \override NoteColumn.force-hshift = #2.5 2. }
>>

This is not as dynamic as we’d want it to be though.

@2) Either set doubleSlurs to #t or use the \=[someID] notation, so using 
 you can start (and similarly end) multiple Slurs at the same 
time. This will most likely need to be manually placed though.

But arguably it might not be a good idea to create too many Slurs for chords, 
because it tends to get hard to read, and it might cause situations where you 
confuse such slurs for ties.

Cheers,
Valentin

Am Samstag, 1. Oktober 2022, 21:21:47 CEST schrieb Sam Carmalt:
> Hi -
> 
> I can't figure out how to tweak two bits of my score so it looks the way I
> want.
> 
> *Tweak 1*
> 
> current result
> [image: tweak-1-dots.jpg]
> 
> current code
> soprano line: bf4 | 2.| 2.
> alto line: 4 | \once \override NoteColumn.force-hshift = #2.0  g>2. | \once \override NoteColumn.force-hshift = #1.7 2.
> 
> problem:
> I want the dots for the soprano notes to print together with those notes,
> and before the start of the alto notes with their dots.
> 
> *Tweak 2*
> 
> current result:
> 
> [image: tweak-2-ties.jpg]
> 
> soprano line:  | bf2 af4 |
> alto line:  | f( ef) c |
> tenor line:  ||
> bass line: | g2 d4 |
> 
> problem: I want to add a slur between the two 1st tenor notes and another
> one between the two second tenor notes.
> 
> Thanks in advance,
> Sam



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


Re: Need help with two tweaks

2022-10-01 Thread Lukas-Fabian Moser

Hi Sam,


*Tweak 2*

current result:

tweak-2-ties.jpg

soprano line:  | bf2 af4 |
alto line:  | f( ef) c |
tenor line:  ||
bass line: | g2 d4 |

problem: I want to add a slur between the two 1st tenor notes and 
another one between the two second tenor notes.


Please always give a compilable example; it's much easier to help that way.

So I give just a pointer: You could do \set doubleSlurs = ##t - but I 
wonder if you wouldn't rather use one slur (tenor I) and one tie (tenor II)?


Lukas


Re: Need help with \force-hshift or \shiftO... (off, on, onn, onnn, etc.)

2022-03-28 Thread Kevin Cole
On Mon, Mar 28, 2022 at 4:42 AM Paul Hodges  wrote:
>
> I think you mean \mergeDifferentlyDotted
>
>> From: Mats Bengtsson 
>>
>> You don't happen to have a \mergeDifferentlyHeadedOn somewhere in your full 
>> score code, do you?

Ah. I had both: Due to my continued inability to hold the whole of it
in my head, I've been working from a Frankensteinian template that I
cobbled together which, up until now, has worked for the stuff I've
been transcribing. The template had both \mergeDifferentlyHeadedOn and
\mergeDifferentlyDottedOn. (I don't recall which scores in the book
wanted those.) Anyway, I removed both and all is looking good now.

Thanks.



Re: Need help with \force-hshift or \shiftO... (off, on, onn, onnn, etc.)

2022-03-28 Thread Paul Hodges
I think you mean \mergeDifferentlyDotted

Paul


 From:   Mats Bengtsson  
 To:   , Kevin Cole  
 Sent:   28/03/2022 7:50 
 Subject:   Re: Need help with \force-hshift or \shiftO... (off, on, onn, onnn, 
etc.) 

 

  
On 2022-03-28 03:54, Kevin Cole wrote:
  
   Ah. I think you're right. And, when I do what you suggested in the
minimal example, it works as described: Your example looks like the
image I sent. But when I inject it into the full score I get the
attached, which still merges the dotted eighth with the sixteenth at
the start of the measure.
  
You don't happen to have a \mergeDifferentlyHeadedOn somewhere in   your 
full score code, do you? 
   /Mats
 

Re: Need help with \force-hshift or \shiftO... (off, on, onn, onnn, etc.)

2022-03-28 Thread Mats Bengtsson

  
  


On 2022-03-28 03:54, Kevin Cole wrote:


  
Ah. I think you're right. And, when I do what you suggested in the
minimal example, it works as described: Your example looks like the
image I sent. But when I inject it into the full score I get the
attached, which still merges the dotted eighth with the sixteenth at
the start of the measure.


You don't happen to have a \mergeDifferentlyHeadedOn somewhere in
  your full score code, do you?
   /Mats

  




Re: Need help with \force-hshift or \shiftO... (off, on, onn, onnn, etc.)

2022-03-27 Thread Kevin Cole
On Sun, Mar 27, 2022 at 5:04 PM Carl Sorensen  wrote:
>
> On Sun, Mar 27, 2022 at 2:01 PM Kevin Cole  wrote:
>>
>> In my more-than-minimal example, the b16 from the first voice gets
>> merged with the b8. from the second voice. When I tried to create a
>> minimum (non-working) example, the two didn't merge. But, what I want
>> below is for the b8. from the first voice to merge with the b8. from
>> the second voice.
>>
>> In other words, it should look like b16 b8. g16 with the b8. in the
>> middle having stems going both directions.  Looking at examples that
>> were over my head, I attempted \override \once \force-hshift in
>> various places, but didn't accomplish anything.
>
>
> Kevin,
>
> If you want the heads to merge, they need to be at the same time step.
>
> I think you are misinterpreting the original music.  The original music has 
> two downstemmed notes (b natural sixteenth plus b natural eighth) at the same 
> time as one upstemmed note (b dotted eighth).
>
> To get the output in the image, just do this:
>
> \version "2.20.0"
> \language "english"
>
> \layout {
>   \autoBeamOff
> }
>
> global = {
>   \key ef \major
>   \time 4/4
> }
>
> melody = {
>   \relative {
> \global
> <<
>   { \voiceOne b'8. }
>   \new Voice
>   { \voiceTwo b16 b8 }
> >>
> \oneVoice
> a8 b8 c4 r8 d8
>   }
> }
>
> \score {
>   \new Staff { \melody }
> }


Ah. I think you're right. And, when I do what you suggested in the
minimal example, it works as described: Your example looks like the
image I sent. But when I inject it into the full score I get the
attached, which still merges the dotted eighth with the sixteenth at
the start of the measure.


RE: Need help with \force-hshift or \shiftO... (off, on, onn, onnn, etc.)

2022-03-27 Thread Mark Stephen Mrotek
Kevin,

Form what I see, the voices are interchanged.
What is in voiceOne should be voiceTwo and vice versa.
See:
https://lilypond.org/doc/v2.22/Documentation/learning/i_0027m-hearing-voices
 

Mark

-Original Message-
From: lilypond-user [mailto:lilypond-user-bounces+carsonmark=ca.rr@gnu.org] 
On Behalf Of Kevin Cole
Sent: Sunday, March 27, 2022 1:01 PM
To: lilypond-user mailinglist 
Subject: Need help with \force-hshift or \shiftO... (off, on, onn, onnn, etc.)

In my more-than-minimal example, the b16 from the first voice gets merged with 
the b8. from the second voice. When I tried to create a minimum (non-working) 
example, the two didn't merge. But, what I want below is for the b8. from the 
first voice to merge with the b8. from the second voice.

In other words, it should look like b16 b8. g16 with the b8. in the middle 
having stems going both directions.  Looking at examples that were over my 
head, I attempted \override \once \force-hshift in various places, but didn't 
accomplish anything.

%
\version "2.20.0"
\language "english"

\layout {
  \autoBeamOff
}

global = {
  \key ef \major
  \time 4/4
}

melody = {
  \relative {
\global
<<
  { \voiceOne b'16 b8. }
  \new Voice
  { \voiceTwo b8. g16 }
>>
\oneVoice
a8 b8 c4 r8 d8
  }
}

\score {
  \new Staff { \melody }
}
%

P.S. I think I'm interpreting the attached image correctly, but I could be 
wrong about that. In any case, that's what I'm trying to achieve in LilyPond.




Re: Need help with \force-hshift or \shiftO... (off, on, onn, onnn, etc.)

2022-03-27 Thread Carl Sorensen
On Sun, Mar 27, 2022 at 2:01 PM Kevin Cole  wrote:

> In my more-than-minimal example, the b16 from the first voice gets
> merged with the b8. from the second voice. When I tried to create a
> minimum (non-working) example, the two didn't merge. But, what I want
> below is for the b8. from the first voice to merge with the b8. from
> the second voice.
>
> In other words, it should look like b16 b8. g16 with the b8. in the
> middle having stems going both directions.  Looking at examples that
> were over my head, I attempted \override \once \force-hshift in
> various places, but didn't accomplish anything.
>

Kevin,

If you want the heads to merge, they need to be at the same time step.

I think you are misinterpreting the original music.  The original music has
two downstemmed notes (b natural sixteenth plus b natural eighth) at the
same time as one upstemmed note (b dotted eighth).

To get the output in the image, just do this:

\version "2.20.0"
\language "english"

\layout {
  \autoBeamOff
}

global = {
  \key ef \major
  \time 4/4
}

melody = {
  \relative {
\global
<<
  { \voiceOne b'8. }
  \new Voice
  { \voiceTwo b16 b8 }
>>
\oneVoice
a8 b8 c4 r8 d8
  }
}

\score {
  \new Staff { \melody }
}

HOpe this helps,

Carl


Re: Need help to familiarize with Lilypond's internals

2021-11-07 Thread Jean Abou Samra

Le 07/11/2021 à 21:52, CieMaKat a écrit :

Hello,

I'm a software engineer and I am working on my personal side project 
related to rendering sheet music. I didn't want to reinvent the wheel 
so I decided to check Lilypond source code (I find Lilypond the best 
music typesetter software I know) to understand basic concepts which 
could help me with my project. However, I have to say I'm struggling 
to understand how Lilypond works internally. Therefore I'm asking for 
help.


I browsed through the source code on Github, yet I'm unable to find 
out how, i.e. slur keypoints are calculated. The Essay on automated 
music engraving 
 
explains that actually three slurs are "generated" and one with the 
highest point rating is selected. I can't find either three-fold slur 
generation nor the rating algorithm.


Is there any valuable documentation for beginners? I am aware of the 
Contributor Guide 
, yet 
it gives little to none introduction to code itself.


Do these help?

https://lilypond.org/doc/v2.22/Documentation/extending/index.html
https://extending-lilypond.readthedocs.io/en/latest/

(I am the author of the latter, so you can write
me if you find anything confusing or wish an
improvement.)


Is there anyone who knows the Lilypond internals and would agree to 
have a call (Skype/Teams/Discord) to introduce me to the code? I think 
explaining how the slur is generated (from parsing the code until 
final control points are calculated) would be a great kickoff and 
would allow me to continue deep-diving in the Lilypond internals on my 
own.


I don't know about the slur determination yet, so
I may not be the best person for that. At any rate,
if you are specifically interested in that algorithm,
it's in lily/slur-scoring.cc.

I personally have not-so-high availability at
the moment, but we could arrange something if
you would be helped by more than the two links
above. Saying this, I really don't want to
prevent others from chiming it.

Best,
Jean




Re: Need help with Scheme code

2019-12-19 Thread Paolo Prete
Thanks Stefano. Currently I'm working for making generic the template. I'll
test your snippet soon after.
Best,
Paolo

On Fri, Dec 20, 2019 at 1:04 AM Stefano Troncaro 
wrote:

> Hi Paolo,
>
> AFAIK the problem here is that \tweak reads the next event of the input
> and you can't access those properties because the event has not been
> translated to a grob yet so lilypond has not yet calculated those values
> (others more suited than me may be able to explain it more elegantly or
> correct me if I have conceptual errors).
>
> For these types of situations I use both the "before-line-breaking" and
> the "after-line-breaking" properties, both can be set to a function that is
> passed the grob as a variable. So we can do the following to achieve what
> you want:
>
> \version "2.19.83"
>
> token = #(let* ((ctr 0)
> (ctr! (lambda ()
> (set! ctr (1+ ctr))
> ctr)))
>(define-music-function (mus) (ly:music?)
>  (let* ((id (format #f "foobar_~a" (ctr!)))
> (mexp #{ \tweak output-attributes.id #id #mus #} )
> (type (ly:music-property mus 'name))
> (mexp (case type
> ('BeamEvent
>   #{ \tweak Beam.after-line-breaking #(lambda (grob)
>(let* ((outprop (ly:grob-property grob
> 'output-attributes))
>   (beam-thickness (ly:grob-property grob
> 'beam-thickness))
>   (outprop (append outprop
> `((beam-thickness . ,beam-thickness)
>  (ly:grob-set-property! grob
> 'output-attributes outprop)))
>   #mexp #} )
> (else mexp
>mexp)))
>
> \relative { c'4 d8 -\token [ e ] f -\token [ g ] c,4 }
>
>
> I wrote the token function in a way that I think will be easy for you to
> expand, testing for different types of events and saving different
> properties to the output attributes property.
>
> Hope this helps,
> Stéfano
>
> El mié., 18 dic. 2019 a las 17:11, Paolo Prete ()
> escribió:
>
>> Hi Jaap,
>>
>> it doesn't fit with what I'm searching for (sorry: my question was not
>> enough clear) .
>> I need to obtain the property set/calculated by Lilypond, not the one set
>> by me.
>> Shortly: for a Beam, how can I:
>>
>> (set! myVar positions-of-the-beam-set-by-lilypond)
>>
>> or:
>>
>> (set! myVar Y-offset-of-the-beam-set-by-lilypond)
>>
>> ?
>>
>> I don't understand if these properties are user-only settable, or if they
>> are set by Lilypond too.
>> If they are not set by Lilypond, how can I obtain them and  put them into
>> myVar ?
>>
>> My aim is to pass these properties to the SVG script through the "
>> output-attributes" mechanism, instead of having to parse the SVG output
>> with JS (which is possible too, but I would like to avoid that)
>>
>> Thanks,
>> P
>>
>> On Wed, Dec 18, 2019 at 6:57 PM  wrote:
>>
>>> Without giving you any solution, I can give you a hint:
>>>
>>>
>>>
>>> Write the music in the traditional way, with and without your
>>> modification.
>>>
>>>
>>>
>>> In your lilypond file put:
>>>
>>> \displayMusic oldmusic
>>>
>>> \displayMusic newmusic
>>>
>>>
>>>
>>> And what you can see wht you have to write by observing the differences
>>>
>>>
>>>
>>> Jaap
>>>
>>>
>>>
>>> *From:* lilypond-user >> de-wolff@gnu.org> *On Behalf Of *Paolo Prete
>>> *Sent:* Wednesday, December 18, 2019 3:30 PM
>>> *To:* Aaron Hill 
>>> *Cc:* lilypond-user 
>>> *Subject:* Re: Need help with Scheme code
>>>
>>>
>>>
>>> Thanks again.
>>>
>>> Now, from what I see, I can extract if #mus is a Beam
>>> with  (ly:music-property mus 'name)  --> BeamEvent
>>>
>>> After that, how can I set, inside the same function you wrote, a
>>> variable with the  beam-thickness value of the corresponding Beam?
>>>
>>> something like (pseudo code):  (set! myVar
>>> current-value-of-beam-thickness )
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Wed, Dec 18, 2019 at 5:14 AM Aaron Hill 
>>> wrote:
>>>
>>> On 2019-12-17 6:01 pm, Paolo Prete wrote:
>>> > And thanks again to t

Re: Need help with Scheme code

2019-12-19 Thread Stefano Troncaro
Hi Paolo,

AFAIK the problem here is that \tweak reads the next event of the input and
you can't access those properties because the event has not been translated
to a grob yet so lilypond has not yet calculated those values (others more
suited than me may be able to explain it more elegantly or correct me if I
have conceptual errors).

For these types of situations I use both the "before-line-breaking" and the
"after-line-breaking" properties, both can be set to a function that is
passed the grob as a variable. So we can do the following to achieve what
you want:

\version "2.19.83"

token = #(let* ((ctr 0)
(ctr! (lambda ()
(set! ctr (1+ ctr))
ctr)))
   (define-music-function (mus) (ly:music?)
 (let* ((id (format #f "foobar_~a" (ctr!)))
(mexp #{ \tweak output-attributes.id #id #mus #} )
(type (ly:music-property mus 'name))
(mexp (case type
('BeamEvent
  #{ \tweak Beam.after-line-breaking #(lambda (grob)
   (let* ((outprop (ly:grob-property grob
'output-attributes))
  (beam-thickness (ly:grob-property grob
'beam-thickness))
  (outprop (append outprop
`((beam-thickness . ,beam-thickness)
 (ly:grob-set-property! grob 'output-attributes
outprop)))
  #mexp #} )
(else mexp
   mexp)))

\relative { c'4 d8 -\token [ e ] f -\token [ g ] c,4 }


I wrote the token function in a way that I think will be easy for you to
expand, testing for different types of events and saving different
properties to the output attributes property.

Hope this helps,
Stéfano

El mié., 18 dic. 2019 a las 17:11, Paolo Prete ()
escribió:

> Hi Jaap,
>
> it doesn't fit with what I'm searching for (sorry: my question was not
> enough clear) .
> I need to obtain the property set/calculated by Lilypond, not the one set
> by me.
> Shortly: for a Beam, how can I:
>
> (set! myVar positions-of-the-beam-set-by-lilypond)
>
> or:
>
> (set! myVar Y-offset-of-the-beam-set-by-lilypond)
>
> ?
>
> I don't understand if these properties are user-only settable, or if they
> are set by Lilypond too.
> If they are not set by Lilypond, how can I obtain them and  put them into
> myVar ?
>
> My aim is to pass these properties to the SVG script through the "
> output-attributes" mechanism, instead of having to parse the SVG output
> with JS (which is possible too, but I would like to avoid that)
>
> Thanks,
> P
>
> On Wed, Dec 18, 2019 at 6:57 PM  wrote:
>
>> Without giving you any solution, I can give you a hint:
>>
>>
>>
>> Write the music in the traditional way, with and without your
>> modification.
>>
>>
>>
>> In your lilypond file put:
>>
>> \displayMusic oldmusic
>>
>> \displayMusic newmusic
>>
>>
>>
>> And what you can see wht you have to write by observing the differences
>>
>>
>>
>> Jaap
>>
>>
>>
>> *From:* lilypond-user > de-wolff@gnu.org> *On Behalf Of *Paolo Prete
>> *Sent:* Wednesday, December 18, 2019 3:30 PM
>> *To:* Aaron Hill 
>> *Cc:* lilypond-user 
>> *Subject:* Re: Need help with Scheme code
>>
>>
>>
>> Thanks again.
>>
>> Now, from what I see, I can extract if #mus is a Beam
>> with  (ly:music-property mus 'name)  --> BeamEvent
>>
>> After that, how can I set, inside the same function you wrote, a variable
>> with the  beam-thickness value of the corresponding Beam?
>>
>> something like (pseudo code):  (set! myVar
>> current-value-of-beam-thickness )
>>
>>
>>
>>
>>
>>
>>
>> On Wed, Dec 18, 2019 at 5:14 AM Aaron Hill 
>> wrote:
>>
>> On 2019-12-17 6:01 pm, Paolo Prete wrote:
>> > And thanks again to the Scheme-master Aaron.
>>
>> I appreciate the kind words, though I doubt my experience rises to the
>> level of "master".
>>
>> > One last thing:
>> >
>> > how can I arrange that function so to obtain output-attributes =
>> > output-attributes + id ?
>> >
>> > For example: if output-attributes is (('a' . 'aa') ('i' . 'ii'))  it
>> > must
>> > become:(('a' . 'aa') ('i' . 'ii') ('id' . 'foobar_1'))
>>
>> Where or how are the other output-attributes being set?  It is my
>> understanding that output-attributes is unset by default, so any
>> \override or \tweak would not need to worry about existing definitions.
>>
>> That said, consider this pattern:
>>
>> 
>> \version "2.19.83"
>> { \tweak Accidental.output-attributes.id 123 bes'4 }
>> 
>>
>> Keep in mind this only *adds* a new key-value pair to the alist; it does
>> not change an existing entry with the same key.
>>
>>
>> -- Aaron Hill
>>
>>


Re: Need help with Scheme code

2019-12-18 Thread Paolo Prete
Hi Jaap,

it doesn't fit with what I'm searching for (sorry: my question was not
enough clear) .
I need to obtain the property set/calculated by Lilypond, not the one set
by me.
Shortly: for a Beam, how can I:

(set! myVar positions-of-the-beam-set-by-lilypond)

or:

(set! myVar Y-offset-of-the-beam-set-by-lilypond)

?

I don't understand if these properties are user-only settable, or if they
are set by Lilypond too.
If they are not set by Lilypond, how can I obtain them and  put them into
myVar ?

My aim is to pass these properties to the SVG script through the "
output-attributes" mechanism, instead of having to parse the SVG output
with JS (which is possible too, but I would like to avoid that)

Thanks,
P

On Wed, Dec 18, 2019 at 6:57 PM  wrote:

> Without giving you any solution, I can give you a hint:
>
>
>
> Write the music in the traditional way, with and without your modification.
>
>
>
> In your lilypond file put:
>
> \displayMusic oldmusic
>
> \displayMusic newmusic
>
>
>
> And what you can see wht you have to write by observing the differences
>
>
>
> Jaap
>
>
>
> *From:* lilypond-user 
> *On Behalf Of *Paolo Prete
> *Sent:* Wednesday, December 18, 2019 3:30 PM
> *To:* Aaron Hill 
> *Cc:* lilypond-user 
> *Subject:* Re: Need help with Scheme code
>
>
>
> Thanks again.
>
> Now, from what I see, I can extract if #mus is a Beam
> with  (ly:music-property mus 'name)  --> BeamEvent
>
> After that, how can I set, inside the same function you wrote, a variable
> with the  beam-thickness value of the corresponding Beam?
>
> something like (pseudo code):  (set! myVar current-value-of-beam-thickness
> )
>
>
>
>
>
>
>
> On Wed, Dec 18, 2019 at 5:14 AM Aaron Hill 
> wrote:
>
> On 2019-12-17 6:01 pm, Paolo Prete wrote:
> > And thanks again to the Scheme-master Aaron.
>
> I appreciate the kind words, though I doubt my experience rises to the
> level of "master".
>
> > One last thing:
> >
> > how can I arrange that function so to obtain output-attributes =
> > output-attributes + id ?
> >
> > For example: if output-attributes is (('a' . 'aa') ('i' . 'ii'))  it
> > must
> > become:(('a' . 'aa') ('i' . 'ii') ('id' . 'foobar_1'))
>
> Where or how are the other output-attributes being set?  It is my
> understanding that output-attributes is unset by default, so any
> \override or \tweak would not need to worry about existing definitions.
>
> That said, consider this pattern:
>
> 
> \version "2.19.83"
> { \tweak Accidental.output-attributes.id 123 bes'4 }
> 
>
> Keep in mind this only *adds* a new key-value pair to the alist; it does
> not change an existing entry with the same key.
>
>
> -- Aaron Hill
>
>


RE: Need help with Scheme code

2019-12-18 Thread lilypond
Without giving you any solution, I can give you a hint:

 

Write the music in the traditional way, with and without your modification.

 

In your lilypond file put:

\displayMusic oldmusic

\displayMusic newmusic

 

And what you can see wht you have to write by observing the differences

 

Jaap

 

From: lilypond-user  On 
Behalf Of Paolo Prete
Sent: Wednesday, December 18, 2019 3:30 PM
To: Aaron Hill 
Cc: lilypond-user 
Subject: Re: Need help with Scheme code

 

Thanks again.

Now, from what I see, I can extract if #mus is a Beam with  (ly:music-property 
mus 'name)  --> BeamEvent

After that, how can I set, inside the same function you wrote, a variable with 
the  beam-thickness value of the corresponding Beam? 

something like (pseudo code):  (set! myVar current-value-of-beam-thickness )

 

 

 

On Wed, Dec 18, 2019 at 5:14 AM Aaron Hill mailto:lilyp...@hillvisions.com> > wrote:

On 2019-12-17 6:01 pm, Paolo Prete wrote:
> And thanks again to the Scheme-master Aaron.

I appreciate the kind words, though I doubt my experience rises to the 
level of "master".

> One last thing:
> 
> how can I arrange that function so to obtain output-attributes =
> output-attributes + id ?
> 
> For example: if output-attributes is (('a' . 'aa') ('i' . 'ii'))  it 
> must
> become:(('a' . 'aa') ('i' . 'ii') ('id' . 'foobar_1'))

Where or how are the other output-attributes being set?  It is my 
understanding that output-attributes is unset by default, so any 
\override or \tweak would not need to worry about existing definitions.

That said, consider this pattern:


\version "2.19.83"
{ \tweak Accidental.output-attributes.id 
<http://Accidental.output-attributes.id>  123 bes'4 }


Keep in mind this only *adds* a new key-value pair to the alist; it does 
not change an existing entry with the same key.


-- Aaron Hill



Re: Need help with Scheme code

2019-12-18 Thread Paolo Prete
Thanks again.
Now, from what I see, I can extract if #mus is a Beam
with  (ly:music-property mus 'name)  --> BeamEvent
After that, how can I set, inside the same function you wrote, a variable
with the  beam-thickness value of the corresponding Beam?
something like (pseudo code):  (set! myVar current-value-of-beam-thickness )



On Wed, Dec 18, 2019 at 5:14 AM Aaron Hill  wrote:

> On 2019-12-17 6:01 pm, Paolo Prete wrote:
> > And thanks again to the Scheme-master Aaron.
>
> I appreciate the kind words, though I doubt my experience rises to the
> level of "master".
>
> > One last thing:
> >
> > how can I arrange that function so to obtain output-attributes =
> > output-attributes + id ?
> >
> > For example: if output-attributes is (('a' . 'aa') ('i' . 'ii'))  it
> > must
> > become:(('a' . 'aa') ('i' . 'ii') ('id' . 'foobar_1'))
>
> Where or how are the other output-attributes being set?  It is my
> understanding that output-attributes is unset by default, so any
> \override or \tweak would not need to worry about existing definitions.
>
> That said, consider this pattern:
>
> 
> \version "2.19.83"
> { \tweak Accidental.output-attributes.id 123 bes'4 }
> 
>
> Keep in mind this only *adds* a new key-value pair to the alist; it does
> not change an existing entry with the same key.
>
>
> -- Aaron Hill
>
>


Re: Need help with Scheme code

2019-12-17 Thread Aaron Hill

On 2019-12-17 6:01 pm, Paolo Prete wrote:

And thanks again to the Scheme-master Aaron.


I appreciate the kind words, though I doubt my experience rises to the 
level of "master".



One last thing:

how can I arrange that function so to obtain output-attributes =
output-attributes + id ?

For example: if output-attributes is (('a' . 'aa') ('i' . 'ii'))  it 
must

become:(('a' . 'aa') ('i' . 'ii') ('id' . 'foobar_1'))


Where or how are the other output-attributes being set?  It is my 
understanding that output-attributes is unset by default, so any 
\override or \tweak would not need to worry about existing definitions.


That said, consider this pattern:


\version "2.19.83"
{ \tweak Accidental.output-attributes.id 123 bes'4 }


Keep in mind this only *adds* a new key-value pair to the alist; it does 
not change an existing entry with the same key.



-- Aaron Hill



Re: Need help with Scheme code

2019-12-17 Thread Paolo Prete
And thanks again to the Scheme-master Aaron.

One last thing:

how can I arrange that function so to obtain output-attributes =
output-attributes + id ?

For example: if output-attributes is (('a' . 'aa') ('i' . 'ii'))  it must
become:(('a' . 'aa') ('i' . 'ii') ('id' . 'foobar_1'))




On Wed, Dec 18, 2019 at 2:07 AM Aaron Hill  wrote:

> On 2019-12-17 4:21 pm, Paolo Prete wrote:
> > Hi Stefano,
> >
> > unfortunately, it doesn't increment the counter globally, and the two
> > ids
> > in the SVG file are identical
>
> You will need to define a music function so that the (serial) procedure
> is called on each occurrence.  Here's an option that rolls in the
> counter logic:
>
> 
> \version "2.19.83"
>
> token = #(let* ((ctr 0) (ctr! (lambda () (set! ctr (1+ ctr)) ctr)))
>(define-music-function (mus) (ly:music?)
>  (let ((id (format #f "foobar_~a" (ctr!
>#{ \tweak output-attributes #`((id . ,id)) #mus #})))
>
> \relative { c'4 d8 -\token [ e ] f -\token [ g ] c,4 }
> 
>
>
> -- Aaron Hill
>
>


Re: Need help with Scheme code

2019-12-17 Thread Aaron Hill

On 2019-12-17 4:21 pm, Paolo Prete wrote:

Hi Stefano,

unfortunately, it doesn't increment the counter globally, and the two 
ids

in the SVG file are identical


You will need to define a music function so that the (serial) procedure 
is called on each occurrence.  Here's an option that rolls in the 
counter logic:



\version "2.19.83"

token = #(let* ((ctr 0) (ctr! (lambda () (set! ctr (1+ ctr)) ctr)))
  (define-music-function (mus) (ly:music?)
(let ((id (format #f "foobar_~a" (ctr!
  #{ \tweak output-attributes #`((id . ,id)) #mus #})))

\relative { c'4 d8 -\token [ e ] f -\token [ g ] c,4 }



-- Aaron Hill



Re: Need help with Scheme code

2019-12-17 Thread Paolo Prete
Hi Kieren,

yes, of course! please let me know how to use it

On Wed, Dec 18, 2019 at 1:32 AM Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:

> Hi Paolo,
>
> > The ids must be: foobar_1, foobar_2  etc.
>
> Can they be foobar.1, foobar.2, etc. instead?
> Lilypond has a nice built-in mechanism for that naming/pointer convention.
>
> Hope that helps!
> Kieren.
> 
>
> Kieren MacMillan, composer (he/him/his)
> ‣ website: www.kierenmacmillan.info
> ‣ email: i...@kierenmacmillan.info
>
>


Re: Need help with Scheme code

2019-12-17 Thread Kieren MacMillan
Hi Paolo,

> The ids must be: foobar_1, foobar_2  etc.

Can they be foobar.1, foobar.2, etc. instead?
Lilypond has a nice built-in mechanism for that naming/pointer convention.

Hope that helps!
Kieren.


Kieren MacMillan, composer (he/him/his)
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info




Re: Need help with Scheme code

2019-12-17 Thread Paolo Prete
Hi Stefano,

unfortunately, it doesn't increment the counter globally, and the two ids
in the SVG file are identical

On Wed, Dec 18, 2019 at 12:12 AM Stefano Troncaro 
wrote:

> Hi Paolo,
>
> After some googling and tweaking I managed to make the counter you wished:
>
> \version "2.19.83"
>
> #(define* (make-counter #:optional (cnt 0) (inc 1))
>(lambda ()
>  (set! cnt (+ cnt inc))
>  cnt))
>
> #(define serial (make-counter))
>
> token = -\tweak output-attributes #`((id . ,(string-append "foobar_"
> (number->string (serial) \etc
>
> \relative { c'4 d8 -\token [ e ] f -\token [ g ] c,4 }
>
> I will test your snippet for modifying beams later! Thank you for the work
> you are doing.
>
> Hope this helps!
> Stéfano
>
> El mar., 17 dic. 2019 a las 19:23, Paolo Prete ()
> escribió:
>
>> In addition, Stefano, If you have time, please try the snippet for tuning
>> the beams (second attachment). Any test of these things are very helpful
>> for me.
>>
>> On Tue, Dec 17, 2019 at 11:18 PM Stefano Troncaro <
>> stefanotronc...@gmail.com> wrote:
>>
>>> Hi Paolo,
>>>
>>> Look at this:
>>>
>>> \version "2.19.83"
>>>
>>> token = -\tweak output-attributes #'((id . "foobar")) \etc
>>>
>>> \relative { c'4 d8 -\token [ e ] f2 }
>>>
>>> That achieves half of what you want. Now, how to make "foobar"
>>> automatically increment I don't know, perhaps someone else can help with
>>> that.
>>>
>>> Hope that helps!
>>> Stéfano
>>>
>>> El mar., 17 dic. 2019 a las 19:06, Paolo Prete ()
>>> escribió:
>>>
 Hello all,

 In order to automate the reverse process of the lilypond+javascript
 snippets (write the GUI modifications of the grobs to the .ly file) I need
 to make the following code work:

 %
 token = \tweak output-attributes  #'((id . "foobar"))

 \score
 {
{
   a8 \token [ c' c' c']
}
 }

 %

 But it doesn't compile.
 What's the right way to define the "token" variable?

 Note that I can compile on 2.19.84 (but not on 2.19.55) the following
 code

 %

 \score
 {
{
   a8 \tweak output-attributes  #'((id . "foobar")) [ c' c' c']
}
 }

 %

 In addition: how can replace "foobar" with a global variable (string +
 number) that is incremented at each call of "token"  ?
 The ids must be: foobar_1, foobar_2  etc.

 Thanks,
 Paolo







Re: Need help with Scheme code

2019-12-17 Thread Stefano Troncaro
Hi Paolo,

After some googling and tweaking I managed to make the counter you wished:

\version "2.19.83"

#(define* (make-counter #:optional (cnt 0) (inc 1))
   (lambda ()
 (set! cnt (+ cnt inc))
 cnt))

#(define serial (make-counter))

token = -\tweak output-attributes #`((id . ,(string-append "foobar_"
(number->string (serial) \etc

\relative { c'4 d8 -\token [ e ] f -\token [ g ] c,4 }

I will test your snippet for modifying beams later! Thank you for the work
you are doing.

Hope this helps!
Stéfano

El mar., 17 dic. 2019 a las 19:23, Paolo Prete ()
escribió:

> In addition, Stefano, If you have time, please try the snippet for tuning
> the beams (second attachment). Any test of these things are very helpful
> for me.
>
> On Tue, Dec 17, 2019 at 11:18 PM Stefano Troncaro <
> stefanotronc...@gmail.com> wrote:
>
>> Hi Paolo,
>>
>> Look at this:
>>
>> \version "2.19.83"
>>
>> token = -\tweak output-attributes #'((id . "foobar")) \etc
>>
>> \relative { c'4 d8 -\token [ e ] f2 }
>>
>> That achieves half of what you want. Now, how to make "foobar"
>> automatically increment I don't know, perhaps someone else can help with
>> that.
>>
>> Hope that helps!
>> Stéfano
>>
>> El mar., 17 dic. 2019 a las 19:06, Paolo Prete ()
>> escribió:
>>
>>> Hello all,
>>>
>>> In order to automate the reverse process of the lilypond+javascript
>>> snippets (write the GUI modifications of the grobs to the .ly file) I need
>>> to make the following code work:
>>>
>>> %
>>> token = \tweak output-attributes  #'((id . "foobar"))
>>>
>>> \score
>>> {
>>>{
>>>   a8 \token [ c' c' c']
>>>}
>>> }
>>>
>>> %
>>>
>>> But it doesn't compile.
>>> What's the right way to define the "token" variable?
>>>
>>> Note that I can compile on 2.19.84 (but not on 2.19.55) the following
>>> code
>>>
>>> %
>>>
>>> \score
>>> {
>>>{
>>>   a8 \tweak output-attributes  #'((id . "foobar")) [ c' c' c']
>>>}
>>> }
>>>
>>> %
>>>
>>> In addition: how can replace "foobar" with a global variable (string +
>>> number) that is incremented at each call of "token"  ?
>>> The ids must be: foobar_1, foobar_2  etc.
>>>
>>> Thanks,
>>> Paolo
>>>
>>>
>>>
>>>
>>>


Re: Need help with Scheme code

2019-12-17 Thread Paolo Prete
In addition, Stefano, If you have time, please try the snippet for tuning
the beams (second attachment). Any test of these things are very helpful
for me.

On Tue, Dec 17, 2019 at 11:18 PM Stefano Troncaro 
wrote:

> Hi Paolo,
>
> Look at this:
>
> \version "2.19.83"
>
> token = -\tweak output-attributes #'((id . "foobar")) \etc
>
> \relative { c'4 d8 -\token [ e ] f2 }
>
> That achieves half of what you want. Now, how to make "foobar"
> automatically increment I don't know, perhaps someone else can help with
> that.
>
> Hope that helps!
> Stéfano
>
> El mar., 17 dic. 2019 a las 19:06, Paolo Prete ()
> escribió:
>
>> Hello all,
>>
>> In order to automate the reverse process of the lilypond+javascript
>> snippets (write the GUI modifications of the grobs to the .ly file) I need
>> to make the following code work:
>>
>> %
>> token = \tweak output-attributes  #'((id . "foobar"))
>>
>> \score
>> {
>>{
>>   a8 \token [ c' c' c']
>>}
>> }
>>
>> %
>>
>> But it doesn't compile.
>> What's the right way to define the "token" variable?
>>
>> Note that I can compile on 2.19.84 (but not on 2.19.55) the following code
>>
>> %
>>
>> \score
>> {
>>{
>>   a8 \tweak output-attributes  #'((id . "foobar")) [ c' c' c']
>>}
>> }
>>
>> %
>>
>> In addition: how can replace "foobar" with a global variable (string +
>> number) that is incremented at each call of "token"  ?
>> The ids must be: foobar_1, foobar_2  etc.
>>
>> Thanks,
>> Paolo
>>
>>
>>
>>
>>


Re: Need help with Scheme code

2019-12-17 Thread Paolo Prete
Thanks Stefano!

On Tue, Dec 17, 2019 at 11:18 PM Stefano Troncaro 
wrote:

> Hi Paolo,
>
> Look at this:
>
> \version "2.19.83"
>
> token = -\tweak output-attributes #'((id . "foobar")) \etc
>
> \relative { c'4 d8 -\token [ e ] f2 }
>
> That achieves half of what you want. Now, how to make "foobar"
> automatically increment I don't know, perhaps someone else can help with
> that.
>
> Hope that helps!
> Stéfano
>
> El mar., 17 dic. 2019 a las 19:06, Paolo Prete ()
> escribió:
>
>> Hello all,
>>
>> In order to automate the reverse process of the lilypond+javascript
>> snippets (write the GUI modifications of the grobs to the .ly file) I need
>> to make the following code work:
>>
>> %
>> token = \tweak output-attributes  #'((id . "foobar"))
>>
>> \score
>> {
>>{
>>   a8 \token [ c' c' c']
>>}
>> }
>>
>> %
>>
>> But it doesn't compile.
>> What's the right way to define the "token" variable?
>>
>> Note that I can compile on 2.19.84 (but not on 2.19.55) the following code
>>
>> %
>>
>> \score
>> {
>>{
>>   a8 \tweak output-attributes  #'((id . "foobar")) [ c' c' c']
>>}
>> }
>>
>> %
>>
>> In addition: how can replace "foobar" with a global variable (string +
>> number) that is incremented at each call of "token"  ?
>> The ids must be: foobar_1, foobar_2  etc.
>>
>> Thanks,
>> Paolo
>>
>>
>>
>>
>>


Re: Need help with Scheme code

2019-12-17 Thread Stefano Troncaro
Hi Paolo,

Look at this:

\version "2.19.83"

token = -\tweak output-attributes #'((id . "foobar")) \etc

\relative { c'4 d8 -\token [ e ] f2 }

That achieves half of what you want. Now, how to make "foobar"
automatically increment I don't know, perhaps someone else can help with
that.

Hope that helps!
Stéfano

El mar., 17 dic. 2019 a las 19:06, Paolo Prete ()
escribió:

> Hello all,
>
> In order to automate the reverse process of the lilypond+javascript
> snippets (write the GUI modifications of the grobs to the .ly file) I need
> to make the following code work:
>
> %
> token = \tweak output-attributes  #'((id . "foobar"))
>
> \score
> {
>{
>   a8 \token [ c' c' c']
>}
> }
>
> %
>
> But it doesn't compile.
> What's the right way to define the "token" variable?
>
> Note that I can compile on 2.19.84 (but not on 2.19.55) the following code
>
> %
>
> \score
> {
>{
>   a8 \tweak output-attributes  #'((id . "foobar")) [ c' c' c']
>}
> }
>
> %
>
> In addition: how can replace "foobar" with a global variable (string +
> number) that is incremented at each call of "token"  ?
> The ids must be: foobar_1, foobar_2  etc.
>
> Thanks,
> Paolo
>
>
>
>
>


RE: Need help with Lily Pond File

2019-03-17 Thread Mark Stephen Mrotek
Yeko,

I see four lines of code in your word document. Each has some very minor 
error/additions

1) remove the braces {  }
2) remove the braces {  }, change \trill to \startTrillSpan
3) remove the brace, }, after the \afterGrace and the brace, }, at the very end
4) remove the brace, }, after the \afterGrace and the brace, }, at the very end

Yes, 3 and 4 have the same error.

Mark

-Original Message-
From: lilypond-user [mailto:lilypond-user-bounces+carsonmark=ca.rr@gnu.org] 
On Behalf Of Yerko Difonis
Sent: Sunday, March 17, 2019 3:03 PM
To: lilypond-user@gnu.org
Subject: Re: Need help with Lily Pond File

Dear all,
Thank you very much for your replies, and I apologize for the inconvenience. As 
I am blind, and it was late when I sent the e-mail, I didn't feel I could 
figure out the errors on my own. Thomas, I asked permission of the people who 
transcribed the music into braille for me, so that I could transcribe it for 
the flautist I have to play a concert with. Andrew and Brian, thank you for 
your suggestions. I went through the file, copied everything after that which I 
knew to be correct into a Word file, and pasted in the code bit by bit to find 
out where the problems were. I corrected some errors, and the piece now 
processes successfully. The compilation file still gives me some errors having 
to do with bar checks and characters, but it is compiled. Thank you.

I do have a question about pitched trills and trills that end in grace notes. 
Are the attached examples correct?

Thank you again.

Regards,
Yerko
On 3/16/19, Brian Barker  wrote:
> At 03:05 16/03/2019 -0300, you wrote:
>>... I am new to Lily Pond. I am writing because I tried to write out a 
>>piece of music, but it gives me a lot of errors when I tried to 
>>compile it at the end.
>
> I think this is your first mistake. Don't wait until you have 
> completed your source file before compiling. Instead, repeatedly 
> compile it as you go. That way, you can correct any simple slips or 
> misunderstandings gradually, instead of being confronted with pages of 
> error messages at the end. You don't need to compile the complete 
> source every time: see 
> http://lilypond.org/doc/v2.18/Documentation/notation/skipping-correcte
> d-music
>
> for how to skip parts that you are confident are correct.
>
>>I used all the rules of syntax as I understood them.
>
> It's very easy to make slips in coding, of course.
>
>>If you could please help me with this, I would truly appreciate it. I 
>>have attached the .ly file, and the compilation  report.
>
> Reading through the log file and determining what needs to change in 
> your source file is very much your job, and you shouldn't expect 
> anyone to do your work for you. If you exhaust what you can do and ask 
> about remaining genuine problems, there will be plenty of help 
> available from people on the list. But you are expected to do at least 
> some work by identifying exactly where your problem lies. In this 
> process, you will be able to create a small example file - not your 
> actual source file - that is just enough to show the problem.
>
>>C:/Users/YERKO/Google Drive/Lily Pond/Poulenc - Flute Sonata - III. 
>>Presto giocoso.ly:27:13:
>>error: unknown escaped string: `\italics'
>>   \markup {
>> \italics "léger et mordant"
>
> It is very easy to see what is wrong here:
> Lilypond does not recognise "\italics". That is not surprising, as the 
> keyword is "\italic" - without the "s". See 
> http://lilypond.org/doc/v2.18/Documentation/notation/formatting-text .
>
>>C:/Users/YERKO/Google Drive/Lily Pond/Poulenc - Flute Sonata - III. 
>>Presto giocoso.ly:27:24: warning: non-UTF-8 input
>>   \markup { \italics "l
>>éger et mordant"
>
> You have saved your .ly file in ASCII format. If you need characters 
> outside the ASCII character set (as here your accented characters), 
> you need to save it in UTF-8 format. See 
> http://lilypond.org/doc/v2.18/Documentation/notation/writing-text .
>
> In addition, you can use \markup without braces here:
> \markup \italic "léger et mordant"
> or with braces:
> \markup { \italics "léger et mordant" }
> - but you have an opening brace but no closing brace. That has left 
> the rest of your source file within that braced expression, thus 
> disabling it.
> Make this simple correction and most of your errors disappear.
>
>>C:/Users/YERKO/Google Drive/Lily Pond/Poulenc - Flute Sonata - III. 
>>Presto giocoso.ly:31:1:
>>error: unrecognized string, not in text script or \lyricmode cis4~ 
>>cis8{) r8 | r2 | r | r | c4--\f b8-- b-- | bes\( c16 bes aes8 ges\) | 
>>\pitchedTrill { b4\trill

Re: Need help with Lily Pond File

2019-03-17 Thread Yerko Difonis
Dear all,
Thank you very much for your replies, and I apologize for the
inconvenience. As I am blind, and it was late when I sent the e-mail,
I didn't feel I could figure out the errors on my own. Thomas, I asked
permission of the people who transcribed the music into braille for
me, so that I could transcribe it for the flautist I have to play a
concert with. Andrew and Brian, thank you for your suggestions. I went
through the file, copied everything after that which I knew to be
correct into a Word file, and pasted in the code bit by bit to find
out where the problems were. I corrected some errors, and the piece
now processes successfully. The compilation file still gives me some
errors having to do with bar checks and characters, but it is
compiled. Thank you.

I do have a question about pitched trills and trills that end in grace
notes. Are the attached examples correct?

Thank you again.

Regards,
Yerko
On 3/16/19, Brian Barker  wrote:
> At 03:05 16/03/2019 -0300, you wrote:
>>... I am new to Lily Pond. I am writing because
>>I tried to write out a piece of music, but it
>>gives me a lot of errors when I tried to compile it at the end.
>
> I think this is your first mistake. Don't wait
> until you have completed your source file before
> compiling. Instead, repeatedly compile it as you
> go. That way, you can correct any simple slips or
> misunderstandings gradually, instead of being
> confronted with pages of error messages at the
> end. You don't need to compile the complete source every time: see
> http://lilypond.org/doc/v2.18/Documentation/notation/skipping-corrected-music
>
> for how to skip parts that you are confident are correct.
>
>>I used all the rules of syntax as I understood them.
>
> It's very easy to make slips in coding, of course.
>
>>If you could please help me with this, I would
>>truly appreciate it. I have attached the .ly file, and the compilation
>> report.
>
> Reading through the log file and determining what
> needs to change in your source file is very much
> your job, and you shouldn't expect anyone to do
> your work for you. If you exhaust what you can do
> and ask about remaining genuine problems, there
> will be plenty of help available from people on
> the list. But you are expected to do at least
> some work by identifying exactly where your
> problem lies. In this process, you will be able
> to create a small example file - not your actual
> source file - that is just enough to show the problem.
>
>>C:/Users/YERKO/Google Drive/Lily Pond/Poulenc -
>>Flute Sonata - III. Presto giocoso.ly:27:13:
>>error: unknown escaped string: `\italics'
>>   \markup {
>> \italics "léger et mordant"
>
> It is very easy to see what is wrong here:
> Lilypond does not recognise "\italics". That is
> not surprising, as the keyword is "\italic" - without the "s". See
> http://lilypond.org/doc/v2.18/Documentation/notation/formatting-text .
>
>>C:/Users/YERKO/Google Drive/Lily Pond/Poulenc -
>>Flute Sonata - III. Presto giocoso.ly:27:24: warning: non-UTF-8 input
>>   \markup { \italics "l
>>éger et mordant"
>
> You have saved your .ly file in ASCII format. If
> you need characters outside the ASCII character
> set (as here your accented characters), you need
> to save it in UTF-8 format. See
> http://lilypond.org/doc/v2.18/Documentation/notation/writing-text .
>
> In addition, you can use \markup without braces here:
> \markup \italic "léger et mordant"
> or with braces:
> \markup { \italics "léger et mordant" }
> - but you have an opening brace but no closing
> brace. That has left the rest of your source file
> within that braced expression, thus disabling it.
> Make this simple correction and most of your errors disappear.
>
>>C:/Users/YERKO/Google Drive/Lily Pond/Poulenc -
>>Flute Sonata - III. Presto giocoso.ly:31:1:
>>error: unrecognized string, not in text script or \lyricmode
>>cis4~ cis8{) r8 | r2 | r | r | c4--\f b8-- b-- |
>>bes\( c16 bes aes8 ges\) | \pitchedTrill {
>>b4\trill cis } ais8( b | c4) f8( c) |
>>\pitchedTrill { b4\trill cis } ais8( b | c4) f8(
>>c | ees2)\> | ees,2~\p | ees8 r8 ees4( | ees'~) ees8 r8 |
>
> That opening brace after "cis8" is simply an error, isn't it?
>
>>C:/Users/YERKO/Google Drive/Lily Pond/Poulenc -
>>Flute Sonata - III. Presto giocoso.ly:51:4: error: EOF found inside string
>>   \
>>midi {  }
>>
>>C:/Users/YERKO/Google Drive/Lily Pond/Poulenc -
>>Flute Sonata - III. Presto giocoso.ly:51:4: error: Unfinished main input
>>   \
>>midi {  }
>>
>>C:/Users/YERKO/Google Drive/Lily Pond/Poulenc -
>>Flute Sonata - III. Presto giocoso.ly:51:4:
>>error: syntax error, unexpected end of input
>>   \
>>midi {  }
>>
>>fatal error: failed files:
>>"C:\\Users\\YERKO\\Google Drive\\Lily
>>Pond\\Poulenc - Flute Sonata - III. Presto giocoso.ly"
>
> These errors almost certainly come from unpaired
> braces somewhere in your source text.
>
> Brian Barker - privately
>
>


Poulenc Flute Sonata Examples.docx
Description: 

Re: Need help with Lily Pond File

2019-03-16 Thread Thomas Morley
Am Sa., 16. März 2019 um 13:52 Uhr schrieb Andrew Bernard
:

> There's a convention on this list to just post Minimal Working Exmaples 
> (MWE), to make it possible for people to help, rather than full scores. 
> Making an MWEW instead of posting a huge chunk is a valuable exercise because 
> I find nine times out of ten it helps you isolate and solve the problem by 
> yourself anyway.

And this piece is for sure under copyright in many countries...

Cheers,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help with Lily Pond File

2019-03-16 Thread Andrew Bernard
HI Yerko, and welcome.

Can I make the politest suggestion? People on the list always object when I
say how I think things should be done, but this file is illegible and
unwieldy, with very, very long lines, making it a really hard slog to help
you. A good practice is to have each bar on one line. This is so much
easier to read.

There are no serious errors in your file, just little things, like \italics
instead oif \italic, and slight misuse fo markup.

Would you kindly make your file clean and legible and I'd be happy to point
out a few things.

Use a tool like Frescobaldi and just go through the errors one by one
starting at the top. Frescobaldi makes this process easy.

There's a convention on this list to just post Minimal Working Exmaples
(MWE), to make it possible for people to help, rather than full scores.
Making an MWEW instead of posting a huge chunk is a valuable exercise
because I find nine times out of ten it helps you isolate and solve the
problem by yourself anyway.

Andrew
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help creating Scheme functions to automate includes of many scores in a project

2018-06-26 Thread Aaron Hill

On 2018-06-26 16:02, Karlin High wrote:

On 6/26/2018 5:41 PM, Aaron Hill wrote:

So is the only option, then, to just dive into the code at this point?


Have you seen this post by Stéfano Troncaro?




I had not, though that seems a good starting point for the edition 
engraver in particular.  Thanks!


That said, what I was seeking was information about openLilyLib itself.  
How is the project structured?  What services does oll-core provide to 
packages/modules?  Basically, if I were to come up with an idea for an 
extension to LilyPond, how would I best evaluate whether openLilyLib 
would make a good platform on which to build and how would I go about 
integrating it?


Since I tend to learn best by example and experimentation, I am 
perfectly content with cracking open the source for existing 
packages/modules; but I did not want to overlook any useful design 
documentation or implementation guides.



-- Aaron Hill

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help creating Scheme functions to automate includes of many scores in a project

2018-06-26 Thread Karlin High

On 6/26/2018 5:41 PM, Aaron Hill wrote:

So is the only option, then, to just dive into the code at this point?


Have you seen this post by Stéfano Troncaro?



--
Karlin High
Missouri, USA

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help creating Scheme functions to automate includes of many scores in a project

2018-06-26 Thread Aaron Hill

On 2018-06-25 22:42, Urs Liska wrote:

Also, not directly. But you can make it happen.
Basically you have to define some variable in the top-level file, say
#(define is-main-file #t). Then you can check in the included file for
#(if (defined? is-main-file)


That was the general idea I was thinking for a workaround, possibly 
building on the tag system that already exists.



You may look at this file:
https://git.openlilylib.org/bfsc/das-trunkne-lied/blob/master/library/ly/makescore/compile-segment.ily
which does more or less what you are looking for.
However, I don't know whether that is at all understandable,
especially on its own. But it might give you an idea.


Actually, that was perfectly clear.  Thanks!

Speaking of openlilylib, I have seen you and others recommend it on many 
occasions.  The openlilylib.org website, though, appears to be all 
placeholder content.  The GitHub for openlilylib/oll-core mentions 
everything is in pre-alpha state, which does explain things.  So is the 
only option, then, to just dive into the code at this point?  Would 
there be a particular subset of plugins (e.g. edition-engraver) that you 
feel are most representative of the project?


-- Aaron Hill

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help creating Scheme functions to automate includes of many scores in a project

2018-06-26 Thread David Kastrup
Nah  writes:

> Thanks. That gives me a good starting point. Will it work in a
> procedure? Something like:
> createLessons = #(make-scheme-function ( ... ))
>
> Can I assume the infinite loop to be caused by the ".ly" suffix being
> the same as the suffix of the main file? If I use ".ily" suffix for
> all the scores and ".ly" only for the main file, then there is no
> problem? Or is there something more subtle going on?
>
> Looking around in the Guile manual, I found:
> scandir name [select? [entryhttps://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help creating Scheme functions to automate includes of many scores in a project

2018-06-26 Thread Nah
Thanks. That gives me a good starting point. Will it work in a 
procedure? Something like:

createLessons = #(make-scheme-function ( ... ))

Can I assume the infinite loop to be caused by the ".ly" suffix being 
the same as the suffix of the main file? If I use ".ily" suffix for all 
the scores and ".ly" only for the main file, then there is no problem? 
Or is there something more subtle going on?


Looking around in the Guile manual, I found:
scandir name [select? [entryIs scandir specific to Guile? Would it be bad form to use it in 
Lilypond, say in a file destined for Mutopia? Or is Guile the default 
for Lilypond?



On 06/25/2018 06:51 PM, David Kastrup wrote:

Nah  writes:


I have a project with 100+ scores, each in their own file. I tried to
create a Scheme function to \include each of them. After searching the
archive, I got the general idea of why my solution isn't
working. However, I didn't find something like a snippet that I could
coax into what I want. I have programming experience in C, Python,
etc., but I'm still pretty clueless with Scheme.

What I want is a function that does something like:
foreach fname #{ \include #fname #}

In Python, I would just read all the filenames in the directory, sort
them, then run the foreach. Can I do something like that in Scheme?
And how do I put the result in a form that will work with \include?





Be aware that this is quite a bad idea if the file itself is in the
directory we are talking about here...



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help creating Scheme functions to automate includes of many scores in a project

2018-06-25 Thread Urs Liska




Am 25.06.2018 um 21:19 schrieb Nah:
I have a project with 100+ scores, each in their own file. I tried to 
create a Scheme function to \include each of them. After searching the 
archive, I got the general idea of why my solution isn't working. 
However, I didn't find something like a snippet that I could coax into 
what I want. I have programming experience in C, Python, etc., but I'm 
still pretty clueless with Scheme.


What I want is a function that does something like:
foreach fname #{ \include #fname #}

In Python, I would just read all the filenames in the directory, sort 
them, then run the foreach. Can I do something like that in Scheme? 
And how do I put the result in a form that will work with \include?


openLilyLib's oll-core has the tool \includePattern that can be used 
directly for your cause. See 
https://github.com/openlilylib/oll-core/blob/master/util/usage/include-pattern.ly 
for an example file and 
https://github.com/openlilylib/oll-core/blob/master/util/include-pattern.ily 
for the implementation. What you really need (i.e. the function you 
might tweak into your own set-up) is the for-each starting on line 79.


HTH
Urs

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help creating Scheme functions to automate includes of many scores in a project

2018-06-25 Thread Urs Liska



Am 26.06.2018 um 01:25 schrieb Aaron Hill:

On 2018-06-25 15:51, David Kastrup wrote:

Nah  writes:


I have a project with 100+ scores, each in their own file. I tried to
create a Scheme function to \include each of them. After searching the
archive, I got the general idea of why my solution isn't
working. However, I didn't find something like a snippet that I could
coax into what I want. I have programming experience in C, Python,
etc., but I'm still pretty clueless with Scheme.

What I want is a function that does something like:
foreach fname #{ \include #fname #}

In Python, I would just read all the filenames in the directory, sort
them, then run the foreach. Can I do something like that in Scheme?
And how do I put the result in a form that will work with \include?


Be aware that this is quite a bad idea if the file itself is in the
directory we are talking about here...


A little unterminated recursion never hurt anyon... 
StackOverflowException.  :)


Out of curiosity, is there a way to do an inclusion guard like the 
C-style `#ifndef/#define/#endif` or `#pragma once` within LilyPond? 


Not directly.

Similarly, is there a way to know that a file was included vs. being 
the top-level file?


Also, not directly. But you can make it happen.
Basically you have to define some variable in the top-level file, say 
#(define is-main-file #t). Then you can check in the included file for 
#(if (defined? is-main-file)


Scenario: I am trying to typeset a work consisting of multiple 
pieces.  I have a single top-level `.ly` file that is responsible for 
including the individual pieces and assembling the scores into the 
book.  Each individual piece is an `.ily` that only defines the 
elements of the score but not the score itself.  As such, that means 
it is insufficient for compiling on its own.


To test an individual piece, I would comment out some of the parts 
within the top-level file so that only the one piece in question is 
processed, which saves time while iterating.  However, it would be 
interesting if I could structure the files in a way that it could be a 
standalone file yet still be useful as an include. Maybe something 
like this:



  \version "whatever"
  \includeOnce "common.ily" % Bring this file in as needed. %

  chordsPieceI = \chordmode { ... }
  notesPieceI = \relative c' { ... }
  lyricsPieceI = \lyricmode { ... }

  \ifNotIncluded { % Do this only if compiled as a standalone. %
    \score {
  <<
    \new ChordNames \chordsPieceI
    \new Voice = "notes" \notesPieceI
    \new Lyrics \lyricsto "notes" \lyricsPieceI
  >>
  \layout { ... }
    }
  }


When included, only the variables are defined and the definition of 
the score, layout, and what not are the responsibility of the 
top-level file.  However, if I want to preview just this file, I could 
compile it by itself in which case the explicit score definition would 
result in output.


You may look at this file: 
https://git.openlilylib.org/bfsc/das-trunkne-lied/blob/master/library/ly/makescore/compile-segment.ily 
which does more or less what you are looking for.
However, I don't know whether that is at all understandable, especially 
on its own. But it might give you an idea.


Urs



But then there is also the issue of the common include file. Normally, 
the top-level file would take care of that include so all of the 
individual pieces just assume it has been included.  To explicitly 
include it in each individual piece would mean that it is getting 
included and processed multiple times, potentially redefining a 
variable multiple times.  But it would need to be there when compiling 
the individual piece on its own, otherwise the common variables do not 
exist.



-- Aaron Hill

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help creating Scheme functions to automate includes of many scores in a project

2018-06-25 Thread Vaughan McAlley
On 26 June 2018 at 05:19, Nah  wrote:
> I have a project with 100+ scores, each in their own file. I tried to create
> a Scheme function to \include each of them. After searching the archive, I
> got the general idea of why my solution isn't working. However, I didn't
> find something like a snippet that I could coax into what I want. I have
> programming experience in C, Python, etc., but I'm still pretty clueless
> with Scheme.
>
> What I want is a function that does something like:
> foreach fname #{ \include #fname #}
>
> In Python, I would just read all the filenames in the directory, sort them,
> then run the foreach. Can I do something like that in Scheme? And how do I
> put the result in a form that will work with \include?
>
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user

You could modify your lilypond command to run a Python script to
create a dynamic file like allIncludes.ly:

\include "Piece01.ly"
\include "Piece02.ly"
...

This is pretty easy in Frescobaldi, or you could do it with Make for a
little bit of respectability…

Vaughan

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help creating Scheme functions to automate includes of many scores in a project

2018-06-25 Thread Aaron Hill

On 2018-06-25 15:51, David Kastrup wrote:

Nah  writes:


I have a project with 100+ scores, each in their own file. I tried to
create a Scheme function to \include each of them. After searching the
archive, I got the general idea of why my solution isn't
working. However, I didn't find something like a snippet that I could
coax into what I want. I have programming experience in C, Python,
etc., but I'm still pretty clueless with Scheme.

What I want is a function that does something like:
foreach fname #{ \include #fname #}

In Python, I would just read all the filenames in the directory, sort
them, then run the foreach. Can I do something like that in Scheme?
And how do I put the result in a form that will work with \include?


Be aware that this is quite a bad idea if the file itself is in the
directory we are talking about here...


A little unterminated recursion never hurt anyon... 
StackOverflowException.  :)


Out of curiosity, is there a way to do an inclusion guard like the 
C-style `#ifndef/#define/#endif` or `#pragma once` within LilyPond?  
Similarly, is there a way to know that a file was included vs. being the 
top-level file?


Scenario: I am trying to typeset a work consisting of multiple pieces.  
I have a single top-level `.ly` file that is responsible for including 
the individual pieces and assembling the scores into the book.  Each 
individual piece is an `.ily` that only defines the elements of the 
score but not the score itself.  As such, that means it is insufficient 
for compiling on its own.


To test an individual piece, I would comment out some of the parts 
within the top-level file so that only the one piece in question is 
processed, which saves time while iterating.  However, it would be 
interesting if I could structure the files in a way that it could be a 
standalone file yet still be useful as an include.  Maybe something like 
this:



  \version "whatever"
  \includeOnce "common.ily" % Bring this file in as needed. %

  chordsPieceI = \chordmode { ... }
  notesPieceI = \relative c' { ... }
  lyricsPieceI = \lyricmode { ... }

  \ifNotIncluded { % Do this only if compiled as a standalone. %
\score {
  <<
\new ChordNames \chordsPieceI
\new Voice = "notes" \notesPieceI
\new Lyrics \lyricsto "notes" \lyricsPieceI
  >>
  \layout { ... }
}
  }


When included, only the variables are defined and the definition of the 
score, layout, and what not are the responsibility of the top-level 
file.  However, if I want to preview just this file, I could compile it 
by itself in which case the explicit score definition would result in 
output.


But then there is also the issue of the common include file.  Normally, 
the top-level file would take care of that include so all of the 
individual pieces just assume it has been included.  To explicitly 
include it in each individual piece would mean that it is getting 
included and processed multiple times, potentially redefining a variable 
multiple times.  But it would need to be there when compiling the 
individual piece on its own, otherwise the common variables do not 
exist.



-- Aaron Hill

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help creating Scheme functions to automate includes of many scores in a project

2018-06-25 Thread David Kastrup
Nah  writes:

> I have a project with 100+ scores, each in their own file. I tried to
> create a Scheme function to \include each of them. After searching the
> archive, I got the general idea of why my solution isn't
> working. However, I didn't find something like a snippet that I could
> coax into what I want. I have programming experience in C, Python,
> etc., but I'm still pretty clueless with Scheme.
>
> What I want is a function that does something like:
> foreach fname #{ \include #fname #}
>
> In Python, I would just read all the filenames in the directory, sort
> them, then run the foreach. Can I do something like that in Scheme?
> And how do I put the result in a form that will work with \include?

$(ly:parser-include-string
  (format #f "~{\\include \"/tmp/~a\"\n~}"
	  (let ((d (opendir "/tmp")))
	(let loop ((f (readdir d)) (res '()))
	  (cond ((eof-object? f)
		 (closedir d)
		 (sort res string
Be aware that this is quite a bad idea if the file itself is in the
directory we are talking about here...

-- 
David Kastrup
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help with lilypond-book

2017-07-18 Thread 410172 Chief
Good point.

I did this and after some error management I got the compiling going fine.
Thanks.

2017-07-18 14:44 GMT+02:00 Phil Holmes :

> It seems clear that the system cannot find the lilypond executable.  Have
> you tried adding the path to lilypond to your PATH variable?
>
> --
> Phil Holmes
>
>
>
> - Original Message -
> *From:* 410172 Chief <410...@gmail.com>
> *To:* lilypond-user@gnu.org
> *Sent:* Tuesday, July 18, 2017 1:17 PM
> *Subject:* Need help with lilypond-book
>
> Dear all,
>
> I need some help on getting Lilypond to work with LaTeX. I have worked
> with both for quite some time now, but am unable to compile my .lytex.
>
> For a start, I did not write my own scripts, but tried examples from
> different websites like:
> https://martin-thoma.com/how-to-write-music-with-latex/
> https://tex.stackexchange.com/questions/280287/how-to-
> easily-include-ly-files-in-a-tex-document
>
> I understand that the compiling code should be entered via the command
> prompt, and figured out that (probably) I will need to specify paths to my
> Lilypond and LaTeX installations.. but commands inside the lilybook-script
> seem to apply to the working directory.. I'm confused.
>
> I have probably miswritten or forgotten something small. If you can help
> me, this would be greetly apprieciated! Thanks!
>
> This is my command prompt input and output:
> PS C:\Users\jc410\OneDrive\Documenten\Music\LaTeX Projects\Test>
> C:\"Program Files (x86)"\Lilypond\usr\bin\lilypond-book --pdf
> lilybook.lytex
> lilypond-book.py (GNU LilyPond) 2.18.2
> Reading lilybook.lytex...
> Running `pdflatex' on file `c:\users\jc410\appdata\local\temp\tmp1ii2fk.tex'
> to detect default page settings.
>
> Dissecting...
> Writing snippets...
> Processing...
> Running lilypond...
> 'lilypond' is not recognized as an internal or external command,
> operable program or batch file.
> command failed: lilypond --formats=ps -dbackend=eps  -I  "." --formats=eps
> --pdf -dinclude-eps-fonts -dgs-load-fonts  -deps-box-padding=3.00
> -dread-file-list -dno-strip-output-dir
>  "C:\Users\jc410\OneDrive\Documenten\Music\LaTeX Projects\Test\
> snippet-names-1880200976.ly"
> Child returned 1
>
>
> Greetings,
> Jonne
>
> --
>
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user
>
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help with lilypond-book

2017-07-18 Thread Phil Holmes
It seems clear that the system cannot find the lilypond executable.  Have you 
tried adding the path to lilypond to your PATH variable?

--
Phil Holmes


  - Original Message - 
  From: 410172 Chief 
  To: lilypond-user@gnu.org 
  Sent: Tuesday, July 18, 2017 1:17 PM
  Subject: Need help with lilypond-book


  Dear all,


  I need some help on getting Lilypond to work with LaTeX. I have worked with 
both for quite some time now, but am unable to compile my .lytex.


  For a start, I did not write my own scripts, but tried examples from 
different websites like:
  https://martin-thoma.com/how-to-write-music-with-latex/
  
https://tex.stackexchange.com/questions/280287/how-to-easily-include-ly-files-in-a-tex-document


  I understand that the compiling code should be entered via the command 
prompt, and figured out that (probably) I will need to specify paths to my 
Lilypond and LaTeX installations.. but commands inside the lilybook-script seem 
to apply to the working directory.. I'm confused.


  I have probably miswritten or forgotten something small. If you can help me, 
this would be greetly apprieciated! Thanks!



  This is my command prompt input and output:
  PS C:\Users\jc410\OneDrive\Documenten\Music\LaTeX Projects\Test> C:\"Program 
Files (x86)"\Lilypond\usr\bin\lilypond-book --pdf lilybook.lytex
  lilypond-book.py (GNU LilyPond) 2.18.2
  Reading lilybook.lytex...
  Running `pdflatex' on file `c:\users\jc410\appdata\local\temp\tmp1ii2fk.tex' 
to detect default page settings.

  Dissecting...
  Writing snippets...
  Processing...
  Running lilypond...
  'lilypond' is not recognized as an internal or external command,
  operable program or batch file.
  command failed: lilypond --formats=ps -dbackend=eps  -I  "." --formats=eps 
--pdf -dinclude-eps-fonts -dgs-load-fonts  -deps-box-padding=3.00  
-dread-file-list -dno-strip-output-dir
   "C:\Users\jc410\OneDrive\Documenten\Music\LaTeX 
Projects\Test\snippet-names-1880200976.ly"
  Child returned 1



  Greetings,

  Jonne



--


  ___
  lilypond-user mailing list
  lilypond-user@gnu.org
  https://lists.gnu.org/mailman/listinfo/lilypond-user
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help with tuplets on my first score

2017-07-16 Thread Mike Solomon
Hey Liam,

Welcome to LilyPond!

Unfortunately, I cannot help you out because your request lacks a few key 
elements. A couple suggestions:

1) In order to get help faster, please send the list a minimal example of what 
you are trying to accomplish in the .ly file.  The picture is excellent, but 
the .ly file should be confined only to the excerpt that you would like help 
with.

2) The file you have sent does not compile because of a matching bracket error 
(the 5/1 tuples is never closed).  Before sending anything out to the list, 
please make sure that it compiles.

All the best,
~Mike


On 15 July 2017 at 22.04.27, Liam Umbs (lumb...@gmail.com) wrote:

For my first score, I am transcribing Chopin’s Waltz in A Minor, and I am 
having trouble with the tuplets in measure 22.  
The ly file is how mine looks, and the picture is how it should look. Also 
confusing to me is the ottava I’m not quite sure how to do both without one 
messing the other one up. As I said, I am new to Lilypond and Frescobaldi so I 
am still getting used to it but I am very pleased so far compared to other 
music engraves such as musescore.  

___  
lilypond-user mailing list  
lilypond-user@gnu.org  
https://lists.gnu.org/mailman/listinfo/lilypond-user  
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Need help with tuplets on my first score

2017-07-15 Thread Malte Meyn



Am 16.07.2017 um 00:56 schrieb Liam Umbs:

For my first score, I am transcribing Chopin’s Waltz in A Minor, and I am 
having trouble with the tuplets in measure 22.
  




The ly file is how mine looks, and the picture is how it should look. Also 
confusing to me is the ottava I’m not quite sure how to do both without one 
messing the other one up. As I said, I am new to Lilypond and Frescobaldi so I 
am still getting used to it but I am very pleased so far compared to other 
music engraves such as musescore.



There are several errors, all of them in line 46 which should look like 
this:

  \tuplet 5/4 {e16 gis b \ottava 1 e gis } b8.
instead of
  \tuplet 5/1 {e16 gis b \ottava {#0 gis} b8

1. It’s 5 sixteenth notes in the place of 1 quarter or 4 sixteenth, so 
the tuplet scaling factor is 5/4, not 5/1.

2. There is a { between \ottava and #0 that doesn’t belong there.
3. The b8 at the end of line misses a dot (b8.).
4. The second e is missing.
5. \ottava 0 (or \ottava #0) does nothing here, for one octave up you 
need \ottava 1 (or \ottava #1). At the end of the ottavation (probably 
at the end of line 48 of your code) you then need \ottava 0 (or \ottava 
#0). The # isn’t necessary in LilyPond 2.18.2 anymore ;)


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: need help

2016-11-08 Thread Federico Bruni
Il giorno lun 7 nov 2016 alle 20:00, Carl Sorensen  
ha scritto:



On 11/7/16 8:48 AM, "Urs Liska"  wrote:


Am 07.11.2016 um 15:35 schrieb David Sumbler:

 On Sun, 2016-11-06 at 11:28 +0100, Malte Meyn wrote:


 Am 06.11.2016 um 11:25 schrieb David Sumbler:


 How do I find out what changes have been made between (for
 instance)
 2.19.48 and 2.19.49?

 You could read the commit messages in the git log:
 http://git.savannah.gnu.org/cgit/lilypond.git/log/


 Well, I could read them, and I have now done so.  But most of it 
makes

 little sense to me!



Which is perfectly understandable, but unfortunately it's the only 
way

to find what you're looking for (IISC). The Changes document always
refers to the latest stable version.

Maybe it would be a good thing to have the Changes document either
structured by unstable release (so one immediately can access the
"release notes" for, say, 2.19.45) or each item tagged by its release
number? This would probably need some organization overhead but 
might be

useful for users?


One could also search the issues database for Fixed tags.



Better idea, as this list takes off translation stuff and minor changes.

David, this is an example:
https://sourceforge.net/p/testlilyissues/issues/search/?q=labels:%22Fixed_2_19_49%22




___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: need help

2016-11-07 Thread Carl Sorensen


On 11/7/16 8:48 AM, "Urs Liska"  wrote:

>Am 07.11.2016 um 15:35 schrieb David Sumbler:
>> On Sun, 2016-11-06 at 11:28 +0100, Malte Meyn wrote:
>>>
>>> Am 06.11.2016 um 11:25 schrieb David Sumbler:

 How do I find out what changes have been made between (for
 instance)
 2.19.48 and 2.19.49?
>>> You could read the commit messages in the git log:
>>> http://git.savannah.gnu.org/cgit/lilypond.git/log/
>> 
>> Well, I could read them, and I have now done so.  But most of it makes
>> little sense to me!
>> 
>
>Which is perfectly understandable, but unfortunately it's the only way
>to find what you're looking for (IISC). The Changes document always
>refers to the latest stable version.
>
>Maybe it would be a good thing to have the Changes document either
>structured by unstable release (so one immediately can access the
>"release notes" for, say, 2.19.45) or each item tagged by its release
>number? This would probably need some organization overhead but might be
>useful for users?

One could also search the issues database for Fixed tags.

Carl


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: need help

2016-11-07 Thread David Sumbler
On Mon, 2016-11-07 at 16:11 +0100, Federico Bruni wrote:
> Il giorno lun 7 nov 2016 alle 15:35, David Sumbler  k> 
> ha scritto:
> > 
> > On Sun, 2016-11-06 at 11:28 +0100, Malte Meyn wrote:
> > > 
> > > 
> > >  Am 06.11.2016 um 11:25 schrieb David Sumbler:
> > >  >
> > >  > How do I find out what changes have been made between (for
> > >  > instance)
> > >  > 2.19.48 and 2.19.49?
> > >  You could read the commit messages in the git log:
> > >  http://git.savannah.gnu.org/cgit/lilypond.git/log/
> > Well, I could read them, and I have now done so.  But most of it
> > makes
> > little sense to me!
> These commit messages are not supposed to be read by users.
> We had a discussion on this topic some time ago:
> http://lists.gnu.org/archive/html/bug-lilypond/2016-05/msg00011.html
> 
> So I would use gitk or gitg (gnome application) to find the
> committish 
> of each release tag.
> These should be the commits between 2.19.48 and 2.19.49:
> http://git.savannah.gnu.org/gitweb/?p=lilypond.git;a=log;hp=fd22d6c;h
> =d9b80e6

With respect, I don't think that this will make things any clearer to
people like me!  I'll just be content with updating Lilypond when there
is evidence through the list of some useful (to me) new feature.  This
is what I have done up until now.

David

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


  1   2   >