Re: Custom engraver to draw frame around notes

2023-04-03 Thread Jean Abou Samra
Le lundi 03 avril 2023 à 20:12 -0400, Nate Whetsell a écrit :
> Because this engraver doesn’t mention staffs at all, I’m not sure how this is 
> happening or how to fix it, and I’m hoping I’m missing something simple. Any 
> help would be greatly appreciated! A small test program follows.

I see

```
#(lambda (context)
   (let ((span '())
 (stub '())
 (event-drul '(() . (
 ^^^
```

then

```
 `((listeners
 (frame-event .
   ,(lambda (engraver event)
 (if (= START (ly:event-property event 'span-direction))
 (set-car! event-drul event)
 ^^
 (set-cdr! event-drul event)
 ^^
```

This is Bad (™). Quoting is a more subtle concept than many people think. For 
example, many beginner/intermediate and even advanced Scheme programmers do not 
realize that

```
$ LC_ALL=C.UTF-8 ~/lilies/2.25.3/bin/lilypond scheme-sandbox
GNU LilyPond 2.25.3 (running Guile 2.2)
Processing `/home/jean/lilies/2.25.3/share/lilypond/2.25.3/ly/scheme-sandbox.ly'
Parsing...
GNU Guile 2.2.7
Copyright (C) 1995-2019 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(#{ g123}#)> (define (f) (list 'a 'b 'c))
scheme@(#{ g123}#)> (eq? (f) (f))
$1 = #f
scheme@(#{ g123}#)> (define (f2) '(a b c))
scheme@(#{ g123}#)> (eq? (f2) (f2))
$2 = #t
```

When you quote something, you always get the same thing, as per `eq?`, i.e., 
identity. Therefore, the two engraver instances are sharing the same pair of 
events, which is obviously troublesome.

By the way, you can debug Scheme code by adding `#(ly:set-option 
'compile-scheme-code)` (see 
[this](https://lilypond.org/doc/v2.25/Documentation/extending/debugging-scheme-code);
 caveat: does not work on Windows right now). If you do this, you will get a 
Guile error about attempting to mutate a literal pair.

If you read section 3.4 of the 
[R5RS](https://conservatory.scheme.org/schemers/Documents/Standards/R5RS/r5rs.pdf),
 you can find

“In many systems it is desirable for constants (i.e. the val-
ues of literal expressions) to reside in read-only-memory.
To express this, it is convenient to imagine that every
object that denotes locations is associated with a flag
telling whether that object is mutable or immutable. In
such systems literal constants and the strings returned by
symbol->string are immutable objects, while all objects
created by the other procedures listed in this report are
mutable. It is an error to attempt to store a new value
into a location that is denoted by an immutable object.”

Note that “it is an error” means the program is invalid, not that the 
implementation is required to detect the error. Guile does it for byte-compiled 
code (when you use `compile-scheme-code`). It unfortunately doesn't for 
interpreted code, as in the default mode in LilyPond.

The fix here is to change `'(() . ())` to `(cons '() '())` to create a fresh 
pair for each engraver.

Jean


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


Custom engraver to draw frame around notes

2023-04-03 Thread Nate Whetsell
Hi,

I’m trying to use an engraver that was shared on the lilypond-user list in 2012:

https://mail.gnu.org/archive/html/lilypond-user/2012-03/msg00363.html 


This engraver draws a frame around notes, followed by an arrow.

I’ve been able to update this engraver so that it can be used in more recent 
versions of LilyPond; this is available at

https://github.com/nwhetsell/lilypond-frame-engraver/blob/main/frame-engraver.ily
 


This engraver works when a score has a single staff, but compilation fails when 
a score has multiple staffs:

/usr/local/Cellar/lilypond-unstable/2.25.3/share/lilypond/2.25.3/ly/init.ly:64:2:
 error: Guile signaled an error for the expression beginning here
#
 (let ((book-handler (if (defined? 'default-toplevel-book-handler)
In procedure ly:grob-property: Wrong type argument in position 1 (expecting 
Grob): ()

I can compile successfully if I comment out what happens in lines 183–6—

https://github.com/nwhetsell/lilypond-frame-engraver/blob/310c2f0776c217fcc486e933badde6a56940f9c1/frame-engraver.ily#L183-L186
 


—like this—

   ;(if (ly:stream-event? (cdr event-drul))
   ;(begin (set! stub (ly:engraver-make-grob trans 'FrameStub (cdr 
event-drul)))
   ;   (ly:grob-set-property! stub 'direction RIGHT)
   ;   (ly:grob-set-object! stub 'frame span)))
   ))

—but I can only get frames in one staff (and it must be the first staff).

Because this engraver doesn’t mention staffs at all, I’m not sure how this is 
happening or how to fix it, and I’m hoping I’m missing something simple. Any 
help would be greatly appreciated! A small test program follows.

Many thanks,
Nate

\version "2.22.0"

\include "frame-engraver.ily"

music = \relative c'' {
  \override Stem.transparent = ##t
  \override Beam.transparent = ##t
  \once \override Frame.extender-length = #8
  \frameStart dis'8[ e f \frameEnd ges] s2
}

\score {
  <<
\new Staff {
  \music
}
\new Staff {
  \music
}
  >>
}

\layout {
  \context {
\Global
\grobdescriptions #all-grob-descriptions
  }
  \context {
\Voice
\consists \frameEngraver
  }
}



Re: Creating Text with Hyperlinks

2023-04-03 Thread Jean Abou Samra
Le mardi 04 avril 2023 à 01:25 +0200, Jean Abou Samra a écrit :
> Le lundi 03 avril 2023 à 19:15 -0400, Ken Ledeen a écrit :
> 
> > Hello All,  
> >  I would like to be able to add conventional text to a score, but provide 
> > associated hyperlinks in the PDF.  FOr example, the title might have a 
> > hyperlink to a youtube video of the score being performed.
> > So far, I've not found anything in the documentation that would support 
> > this functionality
> 
> Look for “URL” in the notation manual's index  
> https://lilypond.org/doc/v2.24/Documentation/notation/lilypond-index.html  


PS: In version 2.25.3 (released last Saturday), there is also a `\qr-code` 
command, which may be better if you want to print the scores.


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


Re: Creating Text with Hyperlinks

2023-04-03 Thread Jean Abou Samra
Le lundi 03 avril 2023 à 19:15 -0400, Ken Ledeen a écrit :
> Hello All,  
> I would like to be able to add conventional text to a score, but provide 
> associated hyperlinks in the PDF.  FOr example, the title might have a 
> hyperlink to a youtube video of the score being performed.
> 
> So far, I've not found anything in the documentation that would support this 
> functionality  

Look for “URL” in the notation manual's index

https://lilypond.org/doc/v2.24/Documentation/notation/lilypond-index.html

Best,

Jean


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


Creating Text with Hyperlinks

2023-04-03 Thread Ken Ledeen
Hello All,

I would like to be able to add conventional text to a score, but provide
associated hyperlinks in the PDF.  FOr example, the title might have a
hyperlink to a youtube video of the score being performed.

So far, I've not found anything in the documentation that would support
this functionality

Ken Ledeen

Mobile:   617-817-3183

www.nevo.com
www.bitsbook.com
tiny.cc/KenLedeen 


Re: sectionLabel with box - global formatting

2023-04-03 Thread Stephan Schöll

Hi Simon

Thanks for your reply.

Jean had answered me way earlier already - fortunately with the same
solution ;-) Seems that you suffered from the delay that happens on the
list (server) from time to time (or: quite often).

Stephan

Am 02.04.2023 um 02:38 schrieb Simon Martineau:

Hi Stephan,

You can try this way :

\override Score.SectionLabel.stencil = #(make-stencil-boxer 0.1 0.5
ly:text-interface::print)

Simon


Le sam. 1 avr. 2023 à 21:04,  a écrit :

Send lilypond-user mailing list submissions to
lilypond-user@gnu.org

To subscribe or unsubscribe via the World Wide Web, visit
https://lists.gnu.org/mailman/listinfo/lilypond-user
or, via email, send a message with subject or body 'help' to
lilypond-user-requ...@gnu.org

You can reach the person managing the list at
lilypond-user-ow...@gnu.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of lilypond-user digest..."


Today's Topics:

   1. Alternative beginnings (John Burt)
   2. Re: Alternative beginnings (David Kastrup)
   3. Re: Alternative beginnings (Jean Abou Samra)
   4. Re: Alternative beginnings (Jonathan Poulin)
   5. sectionLabel with box - global formatting (Stephan Schöll)
   6. LilyPond 2.25.3 (Jonas Hahnfeld)


--

Message: 1
Date: Sat, 1 Apr 2023 12:05:19 -0400
From: John Burt 
To: lilypond-user 
Subject: Alternative beginnings
Message-ID:
       

Content-Type: text/plain; charset="utf-8"

I know how to use \repeat volta to produce alternative endings.
I'm trying
to set a song in which the music for verses 2 and 3 is different
from the
music for verse 1. Is there something like \repeat volta for
alternative
beginnings?
thanks
John
-- next part --
An HTML attachment was scrubbed...
URL:



--

Message: 2
Date: Sat, 01 Apr 2023 18:21:04 +0200
From: David Kastrup 
To: John Burt 
Cc: lilypond-user 
Subject: Re: Alternative beginnings
Message-ID: <87bkk7d15b@fencepost.gnu.org>
Content-Type: text/plain

John Burt  writes:

> I know how to use \repeat volta to produce alternative endings.
I'm trying
> to set a song in which the music for verses 2 and 3 is different
from the
> music for verse 1. Is there something like \repeat volta for
alternative
> beginnings?

Would

{ Verse 1
  \repeat volta 3 { chorus
    \alternative { { verse 2 }
                   { verse 3 }
                   { final bar } } } }

do the trick for you?


--
David Kastrup



--

Message: 3
Date: Sat, 01 Apr 2023 18:22:10 +0200
From: Jean Abou Samra 
To: John Burt , lilypond-user
        
Subject: Re: Alternative beginnings
Message-ID:
        
Content-Type: text/plain; charset="utf-8"

Le samedi 01 avril 2023 à 12:05 -0400, John Burt a écrit :

> > I know how to use \repeat volta to produce alternative
endings. I'm trying to set a song in which the music for verses 2
and 3 is different from the music for verse 1. Is there something
like
> > \repeat volta for alternative beginnings?


Since version 2.24, `\alternative` is not limited to the end of a
repeat. You can use

```
\version "2.24.1"

{
  \repeat volta 2 {
    \alternative {
      \volta 1 {
        c'1
      }
      \volta 2 {
        d'1
      }
    }
    e'1
  }
}
```

Note that the legacy syntax `\repeat volta x { ... } \alternative
{ ... }` is not
encouraged anymore, the syntax `\repeat volta x { ... \alternative
{ ... } }` is
preferred now.

Best,

Jean


-- next part --
An HTML attachment was scrubbed...
URL:


-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part
URL:



--

Message: 4
Date: Sat, 1 Apr 2023 14:03:23 -0400
From: Jonathan Poulin 
To: John Burt 
Cc: lilypond-user 
Subject: Re: Alternative beginnings
Message-ID:
       

Content-Type: text/plain; charset="utf-8"

Maybe, this is what you want to get.

\version "2.24.1"

{
  a'1
  \repeat volta 3 {
    b'1
    \alternative {
      \volta 1 

Re: -dgui option dropped in 2.24 - how to stop the black box on Windows now?

2023-04-03 Thread Jonas Hahnfeld via LilyPond user discussion
On Mon, 2023-04-03 at 11:19 +0100, Richard Shann wrote:
> On Sun, 2023-04-02 at 11:54 -0700, Aaron Hill wrote:
> > I have never looked at Denemo or its source code, so what I am going
> > to  say might not be so trivially applicable. 
> 
> You were quite right to be doubtful - Denemo tries to off-load the
> target machine dependent stuff onto libraries, in this case glib which
> provides the routine to spawn a process, and sadly does not expose the
> CREATE_NO_WINDOW part of the Win32 API.

This shouldn't be needed: g_spawn_sync internally uses a helper
executable that should take care exactly of this aspect. LilyPond uses
it internally to call Ghostscript.

> For now I'll disable the autocompilation option for Windows with
> LilyPond 2.24. Is there any chance the developers might re-instate
> the lilypond-windows.exe?

I wouldn't be a fan, really, because it would mean shipping the same
(statically linked) executable twice...

Jonas
> 


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


Re: -dgui option dropped in 2.24 - how to stop the black box on Windows now?

2023-04-03 Thread Aaron Hill

On 2023-04-03 10:31 am, Jean Abou Samra wrote:
Le 3 avr. 2023 à 12:21, Richard Shann  a 
écrit :


Is there any chance the developers might re-instate the
lilypond-windows.exe?


Maybe. Is it as easy as compiling with -mconsole ? Does that have other 
effects to take care of? Is there a use case where the current mode is 
important or could we just switch to the other mode?


LilyPond would still need to be able to be run purely from the terminal, 
so the main target should continue to use the console subsystem.  This 
importantly covers the scenarios of scripting and automation where you 
need standard I/O to be mapped properly.


The use case for a third-party GUI application running LilyPond 
behind-the-scenes is where the "windows" subsystem could be useful, 
providing the application is unable to spawn the child process in a 
hidden manner.


This goes to my question of which application has the real problem.  
Denemo relied on LilyPond providing two entrypoints, so it was not 
really at fault.  But Denemo probably should have been spawning the 
worker process hidden to begin with, thus never relying on 
lilypond-windows.exe in the first place.  However, that would require 
working around glib to use the Win32 API directly (and adding 
platform-specific development overhead), or by getting the glib 
developers to expose the underlying process creation flag.  But for all 
I know, it might be out-of-scope for glib to support this scenario, thus 
pushing the work back to Denemo.


It should be noted that this dual subsystem approach is very common on 
Windows.  Take the Windows scripting host itself.  It comes in two 
flavors: wscript.exe and cscript.exe.  The first is for use without an 
attached terminal, and the second is meant to be run from the 
command-line.  Java likewise has always shipped with two frontends: 
java.exe and javaw.exe.  So, LilyPond would not be doing anything 
unusual by shipping two executables.



-- Aaron Hill



Re: -dgui option dropped in 2.24 - how to stop the black box on Windows now?

2023-04-03 Thread Jean Abou Samra



> Le 3 avr. 2023 à 12:21, Richard Shann  a écrit :
> 
> Is there any chance the developers might re-instate the
> lilypond-windows.exe?


Maybe. Is it as easy as compiling with -mconsole ? Does that have other effects 
to take care of? Is there a use case where the current mode is important or 
could we just switch to the other mode?





Re: -dgui option dropped in 2.24 - how to stop the black box on Windows now?

2023-04-03 Thread Aaron Hill

On 2023-04-03 3:19 am, Richard Shann wrote:

On Sun, 2023-04-02 at 11:54 -0700, Aaron Hill wrote:

I have never looked at Denemo or its source code, so what I am going
to
say might not be so trivially applicable.
 But in the Win32 API, you can
call CreateProcess and use the process flag CREATE_NO_WINDOW.


You were quite right to be doubtful - Denemo tries to off-load the
target machine dependent stuff onto libraries, in this case glib which
provides the routine to spawn a process, and sadly does not expose the
CREATE_NO_WINDOW part of the Win32 API.


Ah, such is the bane of cross-platform programming.  Often these edge 
cases get overlooked with API abstractions.




For now I'll disable the autocompilation option for Windows with
LilyPond 2.24. Is there any chance the developers might re-instate the
lilypond-windows.exe?


The question of the hour is: Is this a LilyPond problem or a Denemo 
problem?  (Well, one could also ask whether this is a glib problem.)  If 
another third-party tool like Frescobaldi is still working given the 
change in LilyPond, then the case could be made that this is something 
best addressed in Denemo itself.  However, if LilyPond could easily 
provide both entrypoints as it used to, then the issue should be filed 
against LilyPond.




This is something I have not tested, but there are some indications that 
the subsystem of a Windows portable executable can be changed after it 
has been built.  There are two references to Perl modules that do this:


  https://metacpan.org/pod/Win32::Exe
  https://metacpan.org/dist/Tk/view/exetype

It sounds like you could manually copy lilypond.exe to 
lilypond-windows.exe and then change the copy's subsystem.  Not really a 
long-term solution, but it might help you keep auto-compilation as that 
really does sound like a useful workflow.



-- Aaron Hill



keep measures on the same line

2023-04-03 Thread Gianmaria Lari
Sometimes I want to keep some measures on the same line. To do this I use
\nobreaks and I set the fontsize manually by trial and error. Isn't there
an easier way?
Thank you,
gianmaria


Re: -dgui option dropped in 2.24 - how to stop the black box on Windows now?

2023-04-03 Thread Richard Shann
On Sun, 2023-04-02 at 11:54 -0700, Aaron Hill wrote:
> On 2023-04-02 8:38 am, Richard Shann wrote:
> > there used to be an executable lilypond-windows.exe in addition to
> > the
> > lilypond.exe which has also vanished. I suspect it was compiled
> > using
> > the option
> > 
> > -mconsole
> > 
> > passed to gcc as this is how Denemo is compiled to avoid leaving a
> > terminal around that would tempt the user to kill everything by
> > dismissing it (Windows users are generally not familiar with
> > terminals).
> 
> Yup.  On Windows, the executable takes two forms based on whether it
> is 
> CLI-based or GUI-based.  lilypond-windows.exe was in all practical
> ways 
> identical to lilypond.exe except that it had WinMain as its
> entrypoint 
> instead of main.  This meant Windows did not automatically allocate a
> console window.  Do note that even GUI-based applications are
> afforded a 
> text console but they must explicitly call the AllocConsole API.
> 
> 
> > If I understand this correctly, it looks like I will have to spawn
> > a
> > process that runs a windows batch file that processes the command
> > line
> > parameters and synthesizes the names of the log file that LilyPond
> > used
> > to create and then calls LilyPond with re-direction of the output.
> > I'm
> > not sure that this can be done without a terminal popping up to
> > annoy
> > the user.
> 
> I have never looked at Denemo or its source code, so what I am going
> to 
> say might not be so trivially applicable. 

You were quite right to be doubtful - Denemo tries to off-load the
target machine dependent stuff onto libraries, in this case glib which
provides the routine to spawn a process, and sadly does not expose the
CREATE_NO_WINDOW part of the Win32 API.
For now I'll disable the autocompilation option for Windows with
LilyPond 2.24. Is there any chance the developers might re-instate the
lilypond-windows.exe?

Richard Shann

> 

>  But in the Win32 API, you can 
> call CreateProcess [1] and use the process flag CREATE_NO_WINDOW
> [2].  
> This should prevent the console window appearing if the child process
> is 
> CLI-based.
> 
> [1]: 
>   
> https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa
> [2]: 
>   
> https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags
> 
> 
> > Is there anyway of spawning a LilyPond 2.24 process on Windows now
> > without plaguing the user with terminals?
> 
> You might be able to shim with a VBS wrapper.  I do this a lot for 
> custom scheduled tasks that would normally run in the terminal but
> that 
> I do not want to interrupt what I am doing by spawning a window at
> odd 
> times.  Something like this should work, passing arguments to the
> script 
> along to LilyPond:
> 
> 
> ' Turn WScript.Arguments into a proper array.
> Dim args()
> ReDim args(WScript.Arguments.Count - 1)
> For i = 0 To WScript.Arguments.Count - 1
>    args(i) = Chr(34) & WScript.Arguments(i) & Chr(34)
> Next
> 
> Dim shell
> Set shell = WScript.CreateObject("WScript.Shell")
> shell.Run "lilypond.exe " & Join(args), 0, True
> 
> 
> NOTE: The important parameter here is the zero (0) to shell.Run. 
> This 
> hides the spawned process.  The True waits for the child process to 
> finish, which probably is what you need for this use case.  But if
> you 
> just want to fire off a child process and not have the scripting host
> stick around, change that to False.
> 
> 
> -- Aaron Hill