2018-06-08 21:26 GMT+02:00 Urs Liska <li...@openlilylib.org>: > Hi, > > is there anything wrong with adding an arbitrary property to a > SequentialMusic like that: > > \version "2.19.80" > > someNote = { c' d' } > > #(set! (ly:music-property someNote 'foo) "bar") > > \displayMusic \someNote > > ? > > The following is a MWE of a new extension I plan for scholarLY, and it seems > to work. \sic and \corr add such an arbitrary property to the music while > \choice uses that to retrieve one element out of a list of music > expressions. > > \version "2.19.80" > > #(define selection 'sic) > %#(define selection 'corr) > > choice = > #(define-music-function (mus) (ly:music?) > (let* > ((elts > (map > (lambda (expr) > (cons (ly:music-property expr 'choiceType) expr)) > (ly:music-property mus 'elements))) > (chosen (assq-ref elts selection))) > (if chosen > chosen > (first (ly:music-property mus 'elements))))) > > tagMusic = > #(define-void-function (mus tag)(ly:music? symbol?) > (set! (ly:music-property mus 'choiceType) tag)) > > sic = > #(define-music-function (mus) (ly:music?) > (tagMusic mus 'sic) > mus) > > corr = > #(define-music-function (mus) (ly:music?) > (tagMusic mus 'corr) > mus) > > \relative { > c' c g' g | > \choice { > \sic { g } > \corr { a } > } > a g2 > } > > But before proceeding I'd like to know if I'm not doing anything stupid by > injecting two list items like so: > > (make-music > > 'SequentialMusic > > 'choiceType > > 'sic > > 'elements > > (list (make-music > > 'NoteEvent > > 'pitch > > (ly:make-pitch -1 4) > > 'duration > > (ly:make-duration 2)))) > > > Urs
Hi Urs, this looks more or less the same as with custom-grob-properties. Probably a bit safer, if you register them in `all-music-properties' calling `music-property-description'. Look at http://lsr.di.unimi.it/LSR/Item?id=977 for an example Cheers, Harm _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user