lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Duplication of pages with slight changes to color of grobs?


From: Knut Petersen
Subject: Duplication of pages with slight changes to color of grobs?
Date: Mon, 17 Jul 2017 08:30:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

Hi everybody!

I'd like to ask a questions:

A) Is there a practical  way to duplicate pages (with slight changes to the 
color of grobs)
from within an procedure activated by the after-line-breaking hook or at 
another place
after page breaking without changes to lilyponds own scm files? If that would 
be possible
the changes described below in 3) 4) and 5) would not be necessary.

B) Is there a practical way to redefine color? within a .ly file in a way that 
it is recognized
by lilyponds code?

Some background information:

I use lilypond and some additional open source tools to generate score videos 
like
J. S. Bach: Invention Nr 1 <https://www.youtube.com/watch?v=EqWYmrwTcqQ> Hugo Wolf: Resignation 
(Nr.3 from "Sechs geistliche Lieder") <https://www.youtube.com/watch?v=cBXVB8uSTxk>
(there are additional videos of Wolf's music with Sopranos 
<https://www.youtube.com/watch?v=SYHh3LMTMKk> / Altos 
<https://www.youtube.com/watch?v=6W8aV65y_qI> / Tenors 
<https://www.youtube.com/watch?v=QTEMH3U2fd0> / Basses 
<https://www.youtube.com/watch?v=IonPmbdY7ME>
emphasized)

To generate videos with noteheads / dots / stems / flags /rest and
multimeasure rest that change their color for the time they are active
I intercept time-signature and tempo-change-events and implemented
an after-line-breaking function activated for  noteheads / rests and
multimeasure rests.

In the after-line-breaking function I give color the objects ... well, not 
really:
I abuse the color property to encode the moment and duration of the
color change.

In a procedure activated by the page-post-process hook I build an alist
with the page number used as key and a list of all moments that change
the color on that page. That alist is evaluated in an extended dump-page
procedure that wraps the postscript code of every pages in some code
that tells ghostscript to repeat that page with modified coloring as often
as needed.

I also needed to change some lilyponds scm / ps files:

1: It was necessary to remove the limitation of RGB values to the range 0..1 in
color? in output-lib.scm.

2: It was necessary to change the format definition for the RGB fields in
setcolor (output-ps.scm) to allow more than 4 digits.

3. Some additional code was put into music-drawing-routines.ps

4. The alist filled with data in the page-post-process code needs to be
visible by dump-page, therefore I needed to define it globally in a top-level
scm file.

5. dump-page in framework.ps needed some extra code.

All that works pretty well, it even does not break normal coloring of other 
objects
as all the RGB values I use for information passing are encoded in a way to
be either greater than or less than the normally allowed range 0..1 for R G B
values.

The result of all that is a pdf file that contains a properly colored page for 
every
moment that either has a note / rest event. That pdf and midi data also
generated by lilypond is the base for the video generation.

I could release the code now, but I hesitate to do so for a number of reasons:

a) It's normally a really bad idea to tell the user to modify lilypond's scm 
and ps files.
b) The way this project works will be broken by a change to cairo.

Knut


reply via email to

[Prev in Thread] Current Thread [Next in Thread]