Re: help with Wrong type of argument

2023-05-03 Thread Jean Abou Samra
Le mercredi 03 mai 2023 à 23:32 +0200, Jean Abou Samra a écrit :
> Le lundi 01 mai 2023 à 12:52 +0200, Lukas-Fabian Moser a écrit :
> Well, these styles are almost equivalent but not quite; the difference trips 
> up people at times.
> I think I need to briefly mention this fact somewhere in the tutorial; most 
> of the times it doesn't matter, but in the few cases where it does, tracking 
> down the problem can be extremely confusing
> if you are not aware of this subtlety.

I've updated https://extending-lilypond.gitlab.io/en/scheme/quoting.html to 
reflect this, and generally reworded it. Let me know if that's understandable.



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


Re: help with Wrong type of argument

2023-05-03 Thread Jean Abou Samra
Le lundi 01 mai 2023 à 12:52 +0200, Lukas-Fabian Moser a écrit :

>  
> There's one other way which is sometimes useful (but admittedly won't 
> simplify the present use case much):
>  
> #`((lineto 0 ,hgt) (closepath))
>  
> is the a list with two elements, namely  
>  - the 3-element list containing 'lineto, 0 and the value of the variable hgt 
>  
>  - the 1-element list containing the symbol 'closepath.
>  
> This may also be written as:
>  
> #(list (list 'lineto 0 hgt) (list 'closepath))
>  
> or, mixing the two styles,  
>  
>  
> #(list (list 'lineto 0 hgt) '(closepath))  
>


Well, these styles are almost equivalent but not quite; the difference [trips 
up people at 
times](https://lists.gnu.org/archive/html/lilypond-user/2023-04/msg00030.html).

I think I need to briefly mention this fact somewhere in the tutorial; most of 
the times it doesn't matter, but in the few cases where it does, tracking down 
the problem can be extremely confusing if you are not aware of this subtlety.



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


Re: help with Wrong type of argument

2023-05-03 Thread Valentin Petzel
Hi Jeff, hi Michael,

though a bit late want to throw in some bits. First of all I’d advice you to 
check out the relevant part in Jean’s scheme tutorial:

https://extending-lilypond.gitlab.io/de/scheme/quoting.html

This should probably clean up lots of uncertainties. Then I’d like to give a 
few remarks:

A common paradigm in LISP is that almost everything is either a list or a 
primitive data type. This does then include function calls. A function call of 
the type (function arg1 arg2 ...) can be seen as a list where the first 
argument evaluates to a function reference. This means that inherently there 
is no difference between data and language.

Using this we can do a lot of dynamic programming, using lazy evaluation and 
such. Compared to other languages where eval evaluates a string the scheme 
eval evaluates a list, so essentially a data structure. This has has the nice 
advantage that we can separate parsing and evaluation, and it makes 
constructing function calls programmatically quite easy.

Some example:
#(use-modules (ice-9 local-eval))
#(define (test a expr)
   (local-eval expr (the-environment)))
#(display (test 1 '(+ a 1)))
#(newline)
#(display (test 2 '(+ a 1)))

Now, for this we get a cool concept which is quoting. Starting a scheme 
expression with a quote or calling it withing (quote expression) will tell the 
parser to parse the expression, but not evaluate it. As in scheme language is 
either a list, a literal or a symbol we then get thus a list, a primitive data 
type or a symbol.

So inputting '(...) will result in a list of of everything that is given in 
... in exactly the form it is given.

We often abuse this to get a shorthand for defining lists, e.g. instead of 
doing

(list 1 2 3)

we do

'(1 2 3)

But we need to keep in mind that this is not the same thing, as the first 
expression is evaluated, the second isn’t. This we can see if we add some 
language:

(list (+ 1 1) 2 3) → 2, 2, 3
'((+ 1 1) 2 3) → (+ 1 1), 2, 3

Now we also have the concept of quasi-quoting, which is like quoting, but with 
certain parts being evaluated. This is done using backticks (to quasiquote) 
and commas (to unquote) or using the functions quasiquote and unquote. So 
starting an expression with a backtick will only evaluate those parts that are 
started with a comma. Example:

#(use-modules (ice-9 local-eval))
#(define (test a expr)
   (local-eval expr (the-environment)))
#(define a 1)
#(display (test 2 `(cons ,a a)))

Now, Lilypond path commands are designed to look like language, but they are 
not handled like language (so they are never evaluated). This means that when 
you do '(lineto 0 hgt) the procedure handling the drawing will find the symbol 
hgt in second position and not know what to do. If this was actually evaluated 
we’d get a different error, as we won’t be able to resolve the symbol hgt.

In any case, we see that this symbol hgt needs to be resolved before it is 
passed to the path procedure. Thus we’ll need to use

`(lineto 0 ,hgt)

or explicitely construct the list

(list 'lineto 0 hgt)

Cheers,
Valentin

Am Montag, 1. Mai 2023, 08:20:13 CEST schrieb Michael Werner:
> Hi Jeff,
> 
> To say I'm no expert in Scheme is a vast understatement. However, I think I
> found the answer to this one. Or, at least, something that seems to make
> this code work for me here.
> 
> On Mon, May 1, 2023 at 1:00 AM Jeff Olson  wrote:
> %< snip >%
> 
> > Here's my code (small if not minimal):
> > 
> > \version "2.24.0"
> > 
> > #(define-markup-command (dopath layout props xtip ytip hgt wid txt rot)
> > 
> >(number? number? number? number? string? number?)
> >(let (
> >
> >   (a (* wid 0.4))
> >   )
> >
> >(interpret-markup layout props
> >
> >  #{\markup \translate #(cons xtip ytip) \rotate #rot \path #0.25
> 
>  Basically, as I understand things, this bit:
> >#'((lineto 0 hgt)
> 
> Accosrding to my rather vague understanding of Scheme syntax the ' between
> the # and the 1st ( is saying don't interpret anything in that expression,
> just pass it as is. Which means that your variable hgt isn't getting passed
> as a variable but is getting passed as simply a series of three characters.
> What seems to be needed (and what made this appear to work here) is to use
> what's called quasiquoting. Basically, it lets you designate certain bits
> within an expression as "this part should be interpreted before getting
> passed on". This entails changing the above line to:
> 
> #`((lineto 0 ,hgt)
> 
> By changing the ' into a ` (BTW, that's the one that on my keyboard is up
> near the top left, just under the Escape key) you say that there's
> something in the following expression that will need interpreted. Then the
> comma before the variable name points out which item to interpret. There's
> a great deal more to all this, but this is the bare basics as I sorta kinda
> vaguely understand them. All the gory details can be found at:
> 
> 

Re: Separate dynamics from notes

2023-05-03 Thread Gianmaria Lari
Thanks Leo, very interesting!

I report here, for other users, your same example adding the
command displayLilyMusic at the end.
When compiled, lilypond outputs (in the standard output) the resulting
music expression. For example for the following code:

\version "2.25.4"
%%
convertToSkips =
#(define-music-function (music) (ly:music?)
   (music-map
 (lambda (m)
   (if (or (music-is-of-type? m 'rest-event)
   (music-is-of-type? m 'note-event))
   (make-music 'SkipEvent m)
   m))
 music))
%%

music = { r2\p  c'4( d')\ff s4 r4 }
music = { r2\p  c'4( d')\ff s4 r4 }
\score {\music}

\displayLilyMusic \convertToSkips \music


this is lilypond output:

Starting lilypond.exe 2.25.4 [Untitled]...

Processing
`C:/Users/gianm/AppData/Local/Temp/frescobaldi-4jzfn8zf/tmpigq7hcux/
document.ly'

Parsing...

Interpreting music...

Preprocessing graphical objects...

Interpreting music...

Preprocessing graphical objects...

Finding the ideal number of pages...

Fitting music on 1 page...

Drawing systems...

Converting to `document.pdf'...


{ s2\p < s s >2 s4( s4)\ff s4 s4 }

Success: compilation successfully completed

Completed successfully in 0.6".

Thanks Leo (& Jean)!
g.

On Tue, 2 May 2023 at 13:42, Leo Correia de Verdier <
leo.correia.de.verd...@gmail.com> wrote:

> If not too late, here is an example, based on Jeans code in
> https://lists.gnu.org/archive/html/lilypond-user/2021-09/msg00209.html
>
> %%
> convertToSkips =
> #(define-music-function (music) (ly:music?)
>(music-map
>  (lambda (m)
>(if (or (music-is-of-type? m 'rest-event)
>(music-is-of-type? m 'note-event))
>(make-music 'SkipEvent m)
>m))
>  music))
>
> \convertToSkips { r2\p  c'4( d)\ff s4 r4 }
>
> %%
>
> Take care with things that ar still interpreted, like Scripts.
>
> > 26 apr. 2023 kl. 22:55 skrev Leo Correia de Verdier <
> leo.correia.de.verd...@gmail.com>:
> >
> > You can do like this if it’s useful to you, removing the engravers that
> read what you don’t want at a specific place.
> > %%
> > \version "2.25.1"
> >
> > rh = \fixed c' {c4\pp d\p e\f f\ff}
> >
> > \score {
> >  <<
> >\new Voice \with {
> >\remove Dynamic_engraver }
> >  \rh
> >  \new Dynamics %Dynamics context doesn’t have the Note_Heads_Engraver
> anyway
> >  \rh
> >>>
> > }
> > %%
> >
> > Otherwise it is possible to create music functions that replace notes
> and rests with spacers or remove dynamics, but I can’t do that for you at
> the moment. While they’re not difficult functions they’re not ”built-in”.
> >
> > The second question is also probably not too hard to write a function
> for, but you’ll probably need to be a little more specific about the use
> case, perhaps also supply example code.
> >
> > Best wishes
> > /Leo
> >> 26 apr. 2023 kl. 22:23 skrev Gianmaria Lari :
> >>
> >> First question
> >> Suppose I wrote this score:
> >>
> >> \version "2.25.2"
> >> rh = \fixed c' {c4\pp d\p e\f f\ff}
> >>
> >> \score {
> >>  \new Staff \rh
> >> }
> >>
> >> Is there any "automatic" way to extract the dynamics in the score
> (maybe assigning it to a variable)?
> >> At the end I would like to easily transform the previous code in the
> following one:
> >>
> >> \version "2.25.2"
> >> rh = \fixed c' {c4 d e f}
> >> dy = {s4\pp s4\p s4\f s4\ff}
> >> \score {
> >>  <<
> >>\new Staff \rh
> >>\new Dynamics \dy
> 
> >> }
> >>
> >> Second question
> >> Sometimes I copy a long score without the dynamic and add them
> separately later. For this operation I need to establish the dynamic
> location in the score counting and adding the notes length. This is tedious
> and error prone. Is there any way to make it?
> >>
> >> Thanks,
> >> Gianmaria
> >
>
>


Re: FIXED: Re: Frescobaldi: Weird error with 3.3.0 (OT?)

2023-05-03 Thread Jean Abou Samra
Le dimanche 30 avril 2023 à 23:46 +0200, Stephan Schöll a écrit :
> So to me it seems that the uninstaller doesn't do a clean job.


I wasn't aware of it, but it looks like this is a known problem.

https://github.com/frescobaldi/frescobaldi/issues/1252


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


Re: MacOS Ventura Quick Look not working for .ly files

2023-05-03 Thread Hans Aikema
Looks like some app on your system wrongly claims quicklook support for ly files.On my system (Ventura on a M1 Macbook pro, Frescobaldi 3.3.0 and Lilypond lilypond 2.24 .1 installed via macports) quicklook does not act at all on .ly files (shows the file summary and icon like other unsupported files).Based onhttps://developer.apple.com/documentation/quicklookany app can define quicklook pluginsApple has a CLI command to show the quicklook registered apps:qlmanage -m(see qlmanage --help for a full overview of the quicklook management capabilities)On 3 May 2023, at 03:42, Mark Harris  wrote:Thanks. I’ve tried changing the program that opens them, as you suggest, but it still doesn’t work, and gives the same error message.On 2/05/2023, at 11:48 PM, Jeff Kopmanis  wrote:Try Get Info on one of the files and change the program used for all.I have the same issue, but haven't dug into it yet.On Tue, May 2, 2023, 4:24 AM Mark Harris  wrote:Hi, I’ve recently tried to use Lilypond on a MacBook Air M2 with Ventura. Quick Look is a vital part of my workflow, as I work with hundreds of .ly files, and always used to work on my old Mac with an older operating system. Now when I try to Quick Look a .ly file, I get the message:

“The extension com.apple.tips.TipsAppQuicklook-macOS does not implement file previews”

Can anyone help me solve this?

Many thanks,

Mark