Re: Piping contents of SVG directly to stdout

2022-07-19 Thread David Wright
On Mon 18 Jul 2022 at 21:35:11 (+0200), Silvain Dupertuis wrote:
> Le 18.07.22 à 20:33, David Wright a écrit :
> > On Mon 18 Jul 2022 at 11:28:26 (-0500), DoubleFelix wrote:

> > > Actually this is exactly what I'm trying to do. My current setup uses a
> > > python library called svgpathtools to get the bounding box, then I do some
> > > basic manipulation of the width, height, and viewbox parameters to trim 
> > > all
> > > of the excess whitespace out. Although I am very interested in  can
> > > do this without any additional utilities.

> It'll be interesting to be able to ouput SVG directly to get snippet
> which can be integrated into other documents.

[Note to Jean Abou Samra: sorry, yes, I overlooked including the
command line, which was only given in the web page referred to.]

> Actually, one can get SVG files using Inkscape : import the PDF file
> (using PopplerCairo orption),  edit at will, select parts, crop, etc.
> and save as SVG.
> 
> This is what I did for this experimental page 
> .
> I used one LilyPond file, produced one PDF page output, which I edited
> with Inkscpae to cut it into 3 SVG files to include in my HTML page.

Being document- rather than web-oriented, and having been using …TeX
for over 35 years, my workflow was [Encapsulated]PostScript- and is
now PDF-based. As for the cropping LilyPond output, pdfcrop has been
around for 20 years, longer than I've been using LP.

Trying to typeset anything more than plain vanilla scores, just using
LilyPond itself, has never been my priority. I generate any
surrounding textual matter in …TeX, and then insert the cropped
LilyPond PDFs into that, using either bash or Python scripts,
depending on the complexity (eg, automatic transposition of
Anglican chants).

But I can understand that others are more web-oriented, and I've
read that browsers can handle SVGs better than PDFs. I don't know
what the OP's workflow/platforms/desired outcomes are.

Cheers,
David.



Re: Piping contents of SVG directly to stdout

2022-07-19 Thread DoubleFelix
Ohhh, I missed the part about Cairo not working for cross-compilation yet.
My bad.

On Tue, Jul 19, 2022 at 8:51 AM Jean Abou Samra  wrote:

> Le 19/07/2022 à 15:43, DoubleFelix a écrit :
> >
> > Have you installed the necessary packages as explained in
> >
> https://lilypond.org/doc/v2.23/Documentation/contributor/requirements-for-compiling-lilypond#ubuntu
> >
> >
> > Ah, I had to install a C compiler. I just found instructions for how
> > to do that on SO.
>
>
> The instructions above didn't install the compiler? OK, I would have
> expected them to do so ...
>
>
> > So now I have make install ran, so how can I construct binaries for
> > various platforms from this? Can you even compile to a windows binary
> > from Linux?
>
>
> It's the way we do the official releases, and in fact the _only_ way to
> create Windows binaries. To do that, you need to cd into
> release/binaries/ and read README.md. But the whole problem that brought
> you here in the first place was that this cross-compilation system does
> not support Cairo yet. So either you are ready to figure out how to
> cross-compile Cairo for MinGW and link it with LilyPond, and preferably
> you contribute this to LilyPond (see partial work in
> https://gitlab.com/lilypond/lilypond/-/merge_requests/913, it had some
> problems with missing libraries), or you stick with running these Linux
> binaries. in your Linux VM.
>
>


Re: Piping contents of SVG directly to stdout

2022-07-19 Thread Jean Abou Samra

Le 19/07/2022 à 15:43, DoubleFelix a écrit :


Have you installed the necessary packages as explained in

https://lilypond.org/doc/v2.23/Documentation/contributor/requirements-for-compiling-lilypond#ubuntu


Ah, I had to install a C compiler. I just found instructions for how 
to do that on SO.



The instructions above didn't install the compiler? OK, I would have 
expected them to do so ...



So now I have make install ran, so how can I construct binaries for 
various platforms from this? Can you even compile to a windows binary 
from Linux?



It's the way we do the official releases, and in fact the _only_ way to 
create Windows binaries. To do that, you need to cd into 
release/binaries/ and read README.md. But the whole problem that brought 
you here in the first place was that this cross-compilation system does 
not support Cairo yet. So either you are ready to figure out how to 
cross-compile Cairo for MinGW and link it with LilyPond, and preferably 
you contribute this to LilyPond (see partial work in 
https://gitlab.com/lilypond/lilypond/-/merge_requests/913, it had some 
problems with missing libraries), or you stick with running these Linux 
binaries. in your Linux VM.





Re: Piping contents of SVG directly to stdout

2022-07-19 Thread DoubleFelix
>
> Have you installed the necessary packages as explained in
>
> https://lilypond.org/doc/v2.23/Documentation/contributor/requirements-for-compiling-lilypond#ubuntu
>

Ah, I had to install a C compiler. I just found instructions for how to do
that on SO. So now I have make install ran, so how can I construct binaries
for various platforms from this? Can you even compile to a windows binary
from Linux?

On Tue, Jul 19, 2022 at 5:13 AM Jean Abou Samra  wrote:

> Le 18/07/2022 à 20:54, William a écrit :
> > Thanks for this, David. As unfortunately my method (set
> \header{tagline=##f} and run lilypond -dbackend=eps —png file.ly) doesn’t
> work for SVGs.
>
> I haven't completely understood the discussion, but it sounds like you
> just want to use
>
> lilypond --svg -dcrop file.ly
>
> which gives you file.svg and file.cropped.svg.
>
>


Re: Piping contents of SVG directly to stdout

2022-07-19 Thread Jean Abou Samra

Le 18/07/2022 à 20:54, William a écrit :

Thanks for this, David. As unfortunately my method (set \header{tagline=##f} 
and run lilypond -dbackend=eps —png file.ly) doesn’t work for SVGs.


I haven't completely understood the discussion, but it sounds like you 
just want to use


lilypond --svg -dcrop file.ly

which gives you file.svg and file.cropped.svg.




Re: Piping contents of SVG directly to stdout

2022-07-19 Thread Jean Abou Samra

Le 19/07/2022 à 04:59, DoubleFelix a écrit :
So I have my Ubuntu VM setup and per the link from Jean, I've ran 
autogen, but when I try to do "../configure --enable-cairo-backend", 
it says "configure: error: no acceptable C compiler found in $PATH". 
How should I fix this?



Have you installed the necessary packages as explained in
https://lilypond.org/doc/v2.23/Documentation/contributor/requirements-for-compiling-lilypond#ubuntu
?




Re: Piping contents of SVG directly to stdout

2022-07-18 Thread DoubleFelix
So I have my Ubuntu VM setup and per the link from Jean, I've ran autogen,
but when I try to do "../configure --enable-cairo-backend", it says
"configure: error: no acceptable C compiler found in $PATH". How should I
fix this?

On Mon, Jul 18, 2022 at 2:57 PM Silvain Dupertuis <
silvain-dupert...@bluewin.ch> wrote:

> It'll be interesting to be able to ouput SVG directly to get snippet which
> can be integrated into other documents.
>
> Actually, one can get SVG files using Inkscape : import the PDF file
> (using PopplerCairo orption),  edit at will, select parts, crop, etc. and
> save as SVG.
>
> This is what I did for this experimental page
> .
> I used one LilyPond file, produced one PDF page output, which I edited with
> Inkscpae to cut it into 3 SVG files to include in my HTML page.
>
> On the other side, you can put LilyPond code into OOoLilyPond extension
> for LibreOffice. It produces SVG code (and you can save the image as SVG),
> and these images can be used directly in the OpenDocument file to include
> them into some textual explanation...
>
> I would be interested in a web extension which would interpret directly
> Lilypond code into SVG files, it that is possible...
>
> *Silvain*
>
> Le 18.07.22 à 20:33, David Wright a écrit :
>
> On Mon 18 Jul 2022 at 11:28:26 (-0500), DoubleFelix wrote:
>
> Felix, I’m curious what you mean by cropping the file. Sounds to me like
> you are trying to just write a small snippet of music, maybe a few
> measures, and not have the output flooded by whitespace all around the size
> of an A4 paper? This is also similar to what I was using lilypond for and
> there are ways to do this without any external apps.
>
>
> Actually this is exactly what I'm trying to do. My current setup uses a
> python library called svgpathtools to get the bounding box, then I do some
> basic manipulation of the width, height, and viewbox parameters to trim all
> of the excess whitespace out. Although I am very interested in  can
> do this without any additional utilities.
>
> I thought this ought to be very simple.
>
> The attached are shamelessly plundered 
> fromhttps://lists.gnu.org/archive/html/lilypond-user/2021-01/msg00075.html
>
> (There will be files generated, with names not including ".cropped.",
> that need to be thrown away.)
>
> Cheers,
> David.
>
>
> --
> 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: Piping contents of SVG directly to stdout

2022-07-18 Thread Silvain Dupertuis
It'll be interesting to be able to ouput SVG directly to get snippet which can be 
integrated into other documents.


Actually, one can get SVG files using Inkscape : import the PDF file (using PopplerCairo 
orption),  edit at will, select parts, crop, etc. and save as SVG.


This is what I did for this experimental page 
. I used 
one LilyPond file, produced one PDF page output, which I edited with Inkscpae to cut it 
into 3 SVG files to include in my HTML page.


On the other side, you can put LilyPond code into OOoLilyPond extension for LibreOffice. 
It produces SVG code (and you can save the image as SVG), and these images can be used 
directly in the OpenDocument file to include them into some textual explanation...


I would be interested in a web extension which would interpret directly Lilypond code into 
SVG files, it that is possible...


/Silvain/


Le 18.07.22 à 20:33, David Wright a écrit :

On Mon 18 Jul 2022 at 11:28:26 (-0500), DoubleFelix wrote:

Felix, I’m curious what you mean by cropping the file. Sounds to me like
you are trying to just write a small snippet of music, maybe a few
measures, and not have the output flooded by whitespace all around the size
of an A4 paper? This is also similar to what I was using lilypond for and
there are ways to do this without any external apps.


Actually this is exactly what I'm trying to do. My current setup uses a
python library called svgpathtools to get the bounding box, then I do some
basic manipulation of the width, height, and viewbox parameters to trim all
of the excess whitespace out. Although I am very interested in  can
do this without any additional utilities.

I thought this ought to be very simple.

The attached are shamelessly plundered from
https://lists.gnu.org/archive/html/lilypond-user/2021-01/msg00075.html

(There will be files generated, with names not including ".cropped.",
that need to be thrown away.)

Cheers,
David.



--
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: Piping contents of SVG directly to stdout

2022-07-18 Thread DoubleFelix
My gosh it's that simple. I feel laughably stupid right now.

On Mon, Jul 18, 2022 at 1:33 PM David Wright 
wrote:

> On Mon 18 Jul 2022 at 11:28:26 (-0500), DoubleFelix wrote:
> >
> > > Felix, I’m curious what you mean by cropping the file. Sounds to me
> like
> > > you are trying to just write a small snippet of music, maybe a few
> > > measures, and not have the output flooded by whitespace all around the
> size
> > > of an A4 paper? This is also similar to what I was using lilypond for
> and
> > > there are ways to do this without any external apps.
> > >
> >
> > Actually this is exactly what I'm trying to do. My current setup uses a
> > python library called svgpathtools to get the bounding box, then I do
> some
> > basic manipulation of the width, height, and viewbox parameters to trim
> all
> > of the excess whitespace out. Although I am very interested in how you
> can
> > do this without any additional utilities.
>
> I thought this ought to be very simple.
>
> The attached are shamelessly plundered from
> https://lists.gnu.org/archive/html/lilypond-user/2021-01/msg00075.html
>
> (There will be files generated, with names not including ".cropped.",
> that need to be thrown away.)
>
> Cheers,
> David.
>


Re: Piping contents of SVG directly to stdout

2022-07-18 Thread William
Thanks for this, David. As unfortunately my method (set \header{tagline=##f} 
and run lilypond -dbackend=eps —png file.ly) doesn’t work for SVGs. 

-William

Sent from my iPhone

> On Jul 18, 2022, at 14:36, David Wright  wrote:
> 
> On Mon 18 Jul 2022 at 11:28:26 (-0500), DoubleFelix wrote:
>> 
>>> Felix, I’m curious what you mean by cropping the file. Sounds to me like
>>> you are trying to just write a small snippet of music, maybe a few
>>> measures, and not have the output flooded by whitespace all around the size
>>> of an A4 paper? This is also similar to what I was using lilypond for and
>>> there are ways to do this without any external apps.
>>> 
>> 
>> Actually this is exactly what I'm trying to do. My current setup uses a
>> python library called svgpathtools to get the bounding box, then I do some
>> basic manipulation of the width, height, and viewbox parameters to trim all
>> of the excess whitespace out. Although I am very interested in how you can
>> do this without any additional utilities.
> 
> I thought this ought to be very simple.
> 
> The attached are shamelessly plundered from
> https://lists.gnu.org/archive/html/lilypond-user/2021-01/msg00075.html
> 
> (There will be files generated, with names not including ".cropped.",
> that need to be thrown away.)
> 
> Cheers,
> David.
> 
> 
> 
> 




Re: Piping contents of SVG directly to stdout

2022-07-18 Thread David Wright
On Mon 18 Jul 2022 at 11:28:26 (-0500), DoubleFelix wrote:
> 
> > Felix, I’m curious what you mean by cropping the file. Sounds to me like
> > you are trying to just write a small snippet of music, maybe a few
> > measures, and not have the output flooded by whitespace all around the size
> > of an A4 paper? This is also similar to what I was using lilypond for and
> > there are ways to do this without any external apps.
> >
> 
> Actually this is exactly what I'm trying to do. My current setup uses a
> python library called svgpathtools to get the bounding box, then I do some
> basic manipulation of the width, height, and viewbox parameters to trim all
> of the excess whitespace out. Although I am very interested in how you can
> do this without any additional utilities.

I thought this ought to be very simple.

The attached are shamelessly plundered from
https://lists.gnu.org/archive/html/lilypond-user/2021-01/msg00075.html

(There will be files generated, with names not including ".cropped.",
that need to be thrown away.)

Cheers,
David.
\new Score {
c'1
d'1
e'1
}
\new Score {
c'1
\break
c'1
\break
c'1
}

\new Score {
d'1
\break
d'1
\break
d'1
}

\new Score {
c'1
\break
c'1
\break
c'1
}

\new Score {
d'1
\break
d'1
\break
d'1
}

\new Score {
c'1
\break
c'1
\break
c'1
}

\new Score {
d'1
\break
d'1
\break
d'1
}

\new Score {
c'1
\break
c'1
\break
c'1
}

\new Score {
d'1
\break
d'1
\break
d'1
}

\new Score {
c'1
\break
c'1
\break
c'1
}

\new Score {
d'1
\break
d'1
\break
d'1
}


Re: Piping contents of SVG directly to stdout

2022-07-18 Thread DoubleFelix
To William:

> Felix, I’m curious what you mean by cropping the file. Sounds to me like
> you are trying to just write a small snippet of music, maybe a few
> measures, and not have the output flooded by whitespace all around the size
> of an A4 paper? This is also similar to what I was using lilypond for and
> there are ways to do this without any external apps.
>

Actually this is exactly what I'm trying to do. My current setup uses a
python library called svgpathtools to get the bounding box, then I do some
basic manipulation of the width, height, and viewbox parameters to trim all
of the excess whitespace out. Although I am very interested in how you can
do this without any additional utilities.

To Henning Hraban Ramm:

> I never used the SVG backend, but maybe the lilypond-book header works
> with it, too?
> It helps to create small snippets, I used the following settings in my
> LilyPond setup for ConTeXt:
>
...
>

I gave this a go and it still seems to generate a large amount of
whitespace.

On Mon, Jul 18, 2022 at 1:44 AM Henning Hraban Ramm 
wrote:

> Am 18.07.22 um 06:39 schrieb William:
> > Felix, I’m curious what you mean by cropping the file. Sounds to me like
> > you are trying to just write a small snippet of music, maybe a few
> > measures, and not have the output flooded by whitespace all around the
> > size of an A4 paper? This is also similar to what I was using lilypond
> > for and there are ways to do this without any external apps.
>
> I never used the SVG backend, but maybe the lilypond-book header works
> with it, too?
> It helps to create small snippets, I used the following settings in my
> LilyPond setup for ConTeXt:
>
> % --- start of setup for single-line output files ---
> #(define default-toplevel-book-handler
>print-book-with-defaults-as-systems )
>
> #(define toplevel-book-handler
>(lambda ( . rest)
>(set! output-empty-score-list #f)
>(apply print-book-with-defaults rest)))
>
> #(define toplevel-music-handler
>(lambda ( . rest)
> (apply collect-music-for-book rest)))
>
> #(define toplevel-score-handler
>(lambda ( . rest)
> (apply collect-scores-for-book rest)))
>
> #(define toplevel-text-handler
>(lambda ( . rest)
> (apply collect-scores-for-book rest)))
>
> #(set! output-empty-score-list #t)
>
> % --- stop single-line setup ---
>
>
> Hraban
>
>
>


Re: Piping contents of SVG directly to stdout

2022-07-18 Thread Henning Hraban Ramm

Am 18.07.22 um 06:39 schrieb William:
Felix, I’m curious what you mean by cropping the file. Sounds to me like 
you are trying to just write a small snippet of music, maybe a few 
measures, and not have the output flooded by whitespace all around the 
size of an A4 paper? This is also similar to what I was using lilypond 
for and there are ways to do this without any external apps.


I never used the SVG backend, but maybe the lilypond-book header works 
with it, too?
It helps to create small snippets, I used the following settings in my 
LilyPond setup for ConTeXt:


% --- start of setup for single-line output files ---
#(define default-toplevel-book-handler
  print-book-with-defaults-as-systems )

#(define toplevel-book-handler
  (lambda ( . rest)
  (set! output-empty-score-list #f)
  (apply print-book-with-defaults rest)))

#(define toplevel-music-handler
  (lambda ( . rest)
   (apply collect-music-for-book rest)))

#(define toplevel-score-handler
  (lambda ( . rest)
   (apply collect-scores-for-book rest)))

#(define toplevel-text-handler
  (lambda ( . rest)
   (apply collect-scores-for-book rest)))

#(set! output-empty-score-list #t)

% --- stop single-line setup ---


Hraban




Re: Piping contents of SVG directly to stdout

2022-07-18 Thread Andrew Bernard
File IO _expensive_ in 2022? What do you mean exactly? What sort of 
computer and disks are you referring to? Surely lilypond processing 
completely dominates any IO it does?


Andrew


On 16/07/2022 5:15 am, DoubleFelix wrote:

Hello,

I'm using lilypond to programmatically generate sheet music. I already 
have a system in place to crop the SVGs, but now I need to load them 
in my software. I could use the default behavior of letting lilypond 
write to some file, and then reading it, but file I/O tends to be 
pretty expensive, especially when you're doing it in bulk like I am, 
so I'd like to avoid that.






Re: Piping contents of SVG directly to stdout

2022-07-17 Thread William
Hope you won’t mind me hopping in here a little late because this sounds 
similar to a project that I was using lilypond for. My workaround is, as you 
know, spinning up a temporary directory for the output and all the extra eps 
files, run lilypond, read the output file into program memory, delete the 
temporary directory, then serve over http via the buffer in memory. 

So to answer your question, there is no way to pipe output from lilypond, but 
the IO overhead even if you’re using something like a cloud provider HDD is 
very minimal compared to how long lilypond takes to render the output (more 
time would be saved by utilizing virtual host caching for the results, for 
example)

Felix, I’m curious what you mean by cropping the file. Sounds to me like you 
are trying to just write a small snippet of music, maybe a few measures, and 
not have the output flooded by whitespace all around the size of an A4 paper? 
This is also similar to what I was using lilypond for and there are ways to do 
this without any external apps. 

Thanks,
-William

Sent from my iPhone

> On Jul 15, 2022, at 15:17, DoubleFelix  wrote:
> 
> 
> Hello,
> 
> I'm using lilypond to programmatically generate sheet music. I already have a 
> system in place to crop the SVGs, but now I need to load them in my software. 
> I could use the default behavior of letting lilypond write to some file, and 
> then reading it, but file I/O tends to be pretty expensive, especially when 
> you're doing it in bulk like I am, so I'd like to avoid that.
> 
> My question is this: Is there a way to get lilypond to write the output to 
> stdout to save on performance, or do I need to use a file as a middleman? For 
> reference, my current command is:
> "lilypond --svg --loglevel=none file.ly"
> 
> Thanks,
> Felix


Re: Piping contents of SVG directly to stdout

2022-07-17 Thread Andrew Bernard
I'd avoid WSL like the plague. It's still half hearted, terribly slow 
with various filesystems and offers no advantages that I have seen so 
far over simply putting in Virtualbox and running full blown Linux of 
your choice. This is not merely my own opinion - there are dozens of 
websites mentioning the same thing. No need to detain the list further 
with all the gory details. Microsoft is in no way committed to Linux and 
sadly it is not a glorious new era.


Andrew


On 18/07/2022 1:12 pm, DoubleFelix wrote:

So

You could also use the Windows Subsystem for Linux, which is
easy to install as far as I could hear (yes, Microsoft officially
provides an option to install Linux these days, which speaks
volumes...)


Re: Piping contents of SVG directly to stdout

2022-07-17 Thread DoubleFelix
Sorry. I think this should reply to all now. As for the example I sent,
that's the barebones type. The ones I need to generate dynamically will
have random notes and key signatures and what not. I'll try WSL though. I
didn't even think of using that. I'll give it a go and respond here if
something comes up.

On Sun, Jul 17, 2022 at 4:32 PM Jean Abou Samra  wrote:

> Again, please keep the list in the recipients. In your mail client,
> click "Reply to all", not "Reply".
>
> Le 17/07/2022 à 23:19, DoubleFelix a écrit :
> > Oh I see. I looked at compiling LilyPond, but I'm windows and it seems
> > like a pain (I have to set up some VM for a custom OS is what I got
> > from the docs).
>
>
> You could also use the Windows Subsystem for Linux, which is
> easy to install as far as I could hear (yes, Microsoft officially
> provides an option to install Linux these days, which speaks
> volumes...)
>
>
> > As for my input, it's pretty barebones:
> >
> > \version"2.22.2"
> > \language"english"
> > \header{
> > tagline = ""
> > }
> > {
> > \omitScore.TimeSignature
> > \omitScore.Rest
> > \keya \major
> > r4
> > }
>
>
> So you just want to show an image of a key signature?
>
> How about generating those images for all 15 possible
> key signatures once and for all, and never calling LilyPond
> afterwards?
>
> Jean
>
>


Re: Piping contents of SVG directly to stdout

2022-07-17 Thread Jean Abou Samra
Again, please keep the list in the recipients. In your mail client, 
click "Reply to all", not "Reply".


Le 17/07/2022 à 23:19, DoubleFelix a écrit :
Oh I see. I looked at compiling LilyPond, but I'm windows and it seems 
like a pain (I have to set up some VM for a custom OS is what I got 
from the docs).



You could also use the Windows Subsystem for Linux, which is
easy to install as far as I could hear (yes, Microsoft officially
provides an option to install Linux these days, which speaks
volumes...)



As for my input, it's pretty barebones:

\version"2.22.2"
\language"english"
\header{
    tagline = ""
}
{
\omitScore.TimeSignature
\omitScore.Rest
\keya \major
r4
}



So you just want to show an image of a key signature?

How about generating those images for all 15 possible
key signatures once and for all, and never calling LilyPond
afterwards?

Jean




Re: Piping contents of SVG directly to stdout

2022-07-17 Thread Jean Abou Samra

Hi,

Please keep the list posted, which allows everyone to comment and
benefit from the answers.


Le 17/07/2022 à 22:11, DoubleFelix a écrit :
Oh I see. Thank you! While we're here, do you have any tips for 
speeding up lilypond generation times?



If you're using the SVG backend, it is likely that most of the time
is spent generating the SVG. The current SVG backend is very slow;
this is a known issue. It is being improved upon currently, with
a new SVG backend based on the Cairo library, but Cairo support
isn't yet in the official binaries.

If you can avoid SVG and want speed, better avoid it.

If you can't, and you're comfortable with using the command line,
you can try building LilyPond yourself. The procedure is
explained thoroughly in
https://lilypond.org/doc/v2.23/Documentation/contributor/compiling,
but basically it's just "./autogen.sh --noconfigure; ./configure; make",
after you have installed all dependencies. To build LilyPond with
Cairo support, you need to run configure with --enable-cairo-backend.
Then compile your LilyPond files with out/bin/lilypond --svg -dbackend=cairo
(the flags must be in that order).

Apart from that, it's hard to tell what you can to to speed up
compilation without seeing the input you're giving to LilyPond.

Best,
Jean





Re: Piping contents of SVG directly to stdout

2022-07-17 Thread Jean Abou Samra

Le 15/07/2022 à 21:15, DoubleFelix a écrit :

Hello,

I'm using lilypond to programmatically generate sheet music. I already 
have a system in place to crop the SVGs, but now I need to load them 
in my software. I could use the default behavior of letting lilypond 
write to some file, and then reading it, but file I/O tends to be 
pretty expensive, especially when you're doing it in bulk like I am, 
so I'd like to avoid that.


My question is this: Is there a way to get lilypond to write the 
output to stdout to save on performance, or do I need to use a file as 
a middleman? For reference, my current command is:

"lilypond --svg --loglevel=none file.ly "



I don't think this exists. On the other hand, I strongly
doubt that file I/O can prove expensive compared to the
time required to process the LilyPond file. For example,
with Python,

$ time lily -s --svg input/regression/parenthesize.ly

real    0m0,719s
user    0m0,637s
sys    0m0,061s

$ python
Python 3.10.5 (main, Jun  9 2022, 00:00:00) [GCC 12.1.1 20220507 (Red 
Hat 12.1.1-1)] on linux

Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> from timeit import timeit
>>> timeit("Path('parenthesize.svg').read_bytes()", number=1000, 
globals=globals())

0.01524080800284


As you can see, the time taken to read the output SVG
file was 2% of the time to compile the file in this example.

Best,
Jean