Duplication of pages with slight changes to color of grobs?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Duplication of pages with slight changes to color of grobs?

Knut Petersen
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
_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Duplication of pages with slight changes to color of grobs?

Karlin High
On 7/17/2017 1:30 AM, Knut Petersen wrote:
> 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.

I don't care.

>
> b) The way this project works will be broken by a change to cairo.

I don't care.

>
> Knut

"I don't care what anything was designed to do. I care about what it CAN
do." -- Gene Kranz, Apollo 13

I just want to be able to make video scores like your latest example!

Of course, having the features based on modifying important source code
and unaligned with possible directions of future development is far from
ideal. It's hard to see that these efforts will age well in their
current state. But visual aids like video scores are valuable when
teaching complex choral works to groups that haven't had much experience
with that sort of music. I'm excited to see that it's possible to make
them in LilyPond. Go, Knut!
--
Karlin High
Missouri, USA
_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
dak
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Duplication of pages with slight changes to color of grobs?

dak
Karlin High <[hidden email]> writes:

> On 7/17/2017 1:30 AM, Knut Petersen wrote:
>> 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.
>
> I don't care.
>
>>
>> b) The way this project works will be broken by a change to cairo.
>
> I don't care.

I actually don't understand what Knut is aiming at here.  If something
is integrated into LilyPond, why would one need to change its scm and ps
files?

And I have no idea what b) is about.  Obviously a change to use Cairo
would lead to different internals but that means that any actions within
LilyPond's code base would need mapping to new internals.

> I just want to be able to make video scores like your latest example!
>
> Of course, having the features based on modifying important source
> code and unaligned with possible directions of future development is
> far from ideal. It's hard to see that these efforts will age well in
> their current state.

Exactly.

> But visual aids like video scores are valuable when teaching complex
> choral works to groups that haven't had much experience with that sort
> of music. I'm excited to see that it's possible to make them in
> LilyPond. Go, Knut!

But where to?

One obvious thing we likely want is to be able to track the timing of
graphical elements.  Currently, PDF tracks source positions as links.
That's not quite the same thing, particularly as long as Midi does not
offer doing the same.  I'm not sure PDF is the best format for that (or
PostScript either): SVG seems like it would be better suited for
graphical post-processing.  Possibly even the socket backend?

--
David Kastrup

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Duplication of pages with slight changes to color of grobs?

Paul Morris
In reply to this post by Knut Petersen
Hi Knut,

Nice work on the videos.  Just a couple quick thoughts.

On 07/17/2017 02:30 AM, Knut Petersen wrote:
> B) Is there a practical way to redefine color? within a .ly file in a
> way that it is recognized
> by lilyponds code?

I take it you have tried this?

#(define (color? ...) ...)

> 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.

Would it help to define your own custom properties (grob or context) to
avoid overloading the color property.  I have this in my include file
for Clairnote:

#(let*
   ;; translator-property-description function
   ;; from "scm/define-context-properties.scm" (modified)
   ((context-prop
     (lambda (symbol type?)
       (set-object-property! symbol 'translation-type? type?)
       (set-object-property! symbol 'translation-doc "custom context
property")
       (set! all-translation-properties (cons symbol
all-translation-properties))
       symbol))

    ;; define-grob-property function
    ;; from "scm/define-grob-properties.scm" (modified)
    (grob-prop
     (lambda (symbol type?)
       (set-object-property! symbol 'backend-type? type?)
       (set-object-property! symbol 'backend-doc "custom grob property")
       symbol)))

   (context-prop 'myfoo list?)

   (grob-prop 'mybar integer?)
   ;; etc...
   )

Then I can use my custom properties just like the built-in ones.

-Paul


_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Duplication of pages with slight changes to color of grobs?

Knut Petersen
Hi Paul!
>
>> B) Is there a practical way to redefine color? within a .ly file in a way that it is recognized
>> by lilyponds code?
>
> I take it you have tried this?
>
> #(define (color? ...) ...)
>
;-)  Also "#(set! ...." does not help ...

> Would it help to define your own custom properties (grob or context) to avoid overloading the color property.  I have this in my include file for Clairnote:

Interesting approach ... I think it would only shift the problem to other places in the code.

Knut

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
dak
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Duplication of pages with slight changes to color of grobs?

dak
Knut Petersen <[hidden email]> writes:

> Hi Paul!
>>
>>> B) Is there a practical way to redefine color? within a .ly file in
>>> a way that it is recognized
>>> by lilyponds code?
>>
>> I take it you have tried this?
>>
>> #(define (color? ...) ...)
>>
> ;-)  Also "#(set! ...." does not help ...

Well, the problem is that the signature looks something like

(list color? ...)

and is stored with the functions.  That is, the symbol resolution has
already been done.

Things would be different if the stored value were

(lambda () (list color? ...))

in which case the signature would notice the change of color? (in newer
LilyPond versions at least).

>> Would it help to define your own custom properties (grob or context)
>> to avoid overloading the color property.  I have this in my include
>> file for Clairnote:
>
> Interesting approach ... I think it would only shift the problem to
> other places in the code.

Well, but they might be less surprising.  I am also not sure that our
color? definition is the knee's bees: it does not appear suitable for
CMYK or RGBA or other possibly backend-specific definitions.

Still, a color that is not actually fixed at the time a grob is put to
"paper" seems strange, to say the least.

--
David Kastrup

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Duplication of pages with slight changes to color of grobs?

Knut Petersen
Hi David!

>
>>> Would it help to define your own custom properties (grob or context)
>>> to avoid overloading the color property.  I have this in my include
>>> file for Clairnote:
>> Interesting approach ... I think it would only shift the problem to
>> other places in the code.
> Well, but they might be less surprising.  I am also not sure that our
> color? definition is the knee's bees: it does not appear suitable for
> CMYK or RGBA or other possibly backend-specific definitions.
>
> Still, a color that is not actually fixed at the time a grob is put to
> "paper" seems strange, to say the least.
>

Indeed, it is strange, but it works very well ;-)

What do you think about the possible extensions to lilypond described below?

It would be helpful for video generation to define videohack? with a default of #f at the toplevel  and to let color? and setcolor change its behaviour according to that flag. color? would skip checking the range of the numbers, setcolor would emit colors with an extended precision.

dump-page could be  extended to allow inclusion of some additional postscript code at the beginning and at the end of a page. That could also be useful for a number of other purposes. dump-page would check if an alist with key page number would define some code to emit for the page it processes.

A last nice hook would be to change write-preamble in a way to write some user-defined postscript code immediately before it emits "%%EndProlog".

@Karl: I know that I'm not the only one who likes to process the postscript code generated by lilypond. What do you think about the topic?

Knut


_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Loading...