lilypond-user
[Top][All Lists]
Advanced

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

Re: (Urgent:) Getting start and end translation-timestep of a (hairpin)


From: Urs Liska
Subject: Re: (Urgent:) Getting start and end translation-timestep of a (hairpin) grob
Date: Mon, 13 Apr 2015 04:05:56 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

Hi David,

thank you for your head start.
See my attached results. I'd be grateful for any comments to improve the coding.
One basic question is if it will be possible to extend it with other types (dynamic text spanners etc.) without having to write another engraver with duplicating code.
And unfortunately the attached file compiles, while applying it to a real-world file I get  an error:

In procedure ly:grob-set-property! in _expression_ (ly:grob-set-property! (car equal-hairpins) (quote color) ...):

/home/uliska/git/bfsc/fried/das-trunkne-lied/library/ly/to-lilylib/remove-double-hairpins-engraver.ily:91:19: Wrong type argument in position 1 (expecting Grob): (#<Grob Hairpin > #<Grob Hairpin >)


Looks quite similar to the problems I had during development, but I don't see yet what is actually wrong with it.

Best
Urs

Am 11.04.2015 um 16:07 schrieb David Nalesnik:


On Sat, Apr 11, 2015 at 9:01 AM, David Nalesnik <address@hidden> wrote:
Hi Urs,

On Sat, Apr 11, 2015 at 3:31 AM, Urs Liska <address@hidden> wrote:
Hi,

this is related to my previous thread and particularly to the file attached to
http://lists.gnu.org/archive/html/lilypond-user/2015-04/msg00263.html

If I have a Scheme engraver listening to TextScript-s I can get a list of entries at the same timestep and then compare them for equality.
This even works without changes for DynamicText because that also has a 'text property. But if i have spanners such as hairpins it's not that simple anymore. So I'm asking myself if I can access the starting and ending timesteps of hairpins that are present in such a list. Of course I can collect hairpins in a list like I can collect TextScripts (currently I'm listening for line-interface). But is it possible to retrieve the start *and* end position of such items?

The goal is to iterate over the list and find matching hairpins to remove duplicate ones.


A simple way to determine when a hairpin starts and ends is by using an acknowledger and an end-acknowledger:

 myEngraver =
#(lambda (context)
     (make-engraver
      
      (acknowledgers
       ((hairpin-interface engraver grob source-engraver)
        (format #t "My start is at ~a~%" (ly:context-current-moment context))))
      
      (end-acknowledgers
       ((hairpin-interface engraver grob source-engraver)
        (format #t "My end is at ~a~%" (ly:context-current-moment context))))
     ))

\layout {
  \context {
    \Score
    \consists \myEngraver
  }
}

{
  c''1~\<
  c''1\!
  c''2.\< c''4\!
  c''1~\>
  \break
  c''2~ c''\!
}


If you're collecting the hairpins for processing later, you could find the timings of beginnings and endings through the columns at their bounds:

myEngraver =
#(lambda (context)
   (let ((hairpins '()))
     (make-engraver
      (acknowledgers
       ((hairpin-interface engraver grob source-engraver)
        (set! hairpins (cons grob hairpins))))
      
      ((finalize trans)
       (for-each
        (lambda (hp)
          (format #t "BEGINNING ~a END: ~a~%"
 

Not that you will use this method, but the following two lines ought to be


            (grob::when (ly:spanner-bound hp LEFT))
            (grob::when (ly:spanner-bound hp RIGHT))))

            (grob::when (ly:item-get-column (ly:spanner-bound hp LEFT)))
            (grob::when (ly:item-get-column (ly:spanner-bound hp RIGHT)))))
        hairpins))
      )))

 
DN

Attachment: remove-double-hairpins-engraver.ily
Description: Text document


reply via email to

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