lilypond-user
[Top][All Lists]
Advanced

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

Re: Add an arbitrary music property


From: Urs Liska
Subject: Re: Add an arbitrary music property
Date: Wed, 13 Jun 2018 17:41:07 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

Hi Harm,


Am 10.06.2018 um 15:15 schrieb Thomas Morley:
2018-06-09 23:59 GMT+02:00 Urs Liska <address@hidden>:

You mean I should use set-object-property! rather than set!
(ly:music-property .... ?
Well, look at the example below (for custom-grob-properties):

{
  \override NoteHead #'wtf = ##t
  c'
  d'
  \once \override NoteHead #'color =
  #(lambda (grob)
    (if (eq? (ly:grob-property grob 'wtf) #t)
        red
        '()))
  e'
  f'
}

This used to work, alas emitting a warning:
warning: cannot find property type-check for `wtf' (backend-type?).
perhaps a typing error?
warning: doing assignment anyway

Since 2.18.2 it fails with:
warning: cannot find property type-check for `wtf' (backend-type?).
perhaps a typing error?
warning: skipping assignment

Unless you prepend the example with something at the lines of:

#(define (define-grob-property symbol type? description)
  (if (not (equal? (object-property symbol 'backend-doc) #f))
      (ly:error (_ "symbol ~S redefined") symbol))

  (set-object-property! symbol 'backend-type? type?)
  (set-object-property! symbol 'backend-doc description)
  symbol)

#(for-each
  (lambda (x)
    (apply define-grob-property x))
    `(
      (wtf ,boolean? "DOCME")
      ;; other custom-properties
      ))

I just thought doing similar for custom-_music_-properties would be a
littel more robust for changes of our internals.

Thanks. Now that I've looked more closely I see your point.


Does that also work with whole music expressions (vs. single grobs)? I want
to "tag" the whole (sequential) music _expression_.
I expect so, but didn't check.


Indeed it does.
But now that I know how to mark up a whole music _expression_ with a custom music-property I see that it may not actually be what I need.
Is it possible to read out the properties of music expressions in an engraver? Or do these only respond to grobs? Is *that* what (process-music) is for?

What I want to achieve is:
  • Have a music function take a music argument
  • mark that up with an annotation (that addresses the whole _expression_, not just a single grob or moment)
  • in an engraver process the annotation as a whole, for example in order to print the begin and end of the annotated music.

If that isn't possible with the music-property I would probably attach grob-properties to the first and last element in the music _expression_ and try to figure out the extent of the annotation by that (will probably have to do some ID referencing to match the begin/end grobs).


Urs


Cheers,
  Harm


reply via email to

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