David Kastrup <d...@gnu.org> writes: > Gianmaria Lari <gianmarial...@gmail.com> writes: > >> On 27 August 2017 at 08:57, David Kastrup <d...@gnu.org> wrote: >> >>> However, LilyPond does not permit adding "post events" after the fact >>> (never mind their name). You can use >>> >>> { >>> <>[ \note b b b] >>> } >>> >>> to have the beam start event on an empty chord with duration 0. This >>> will work reasonably well for beaming but not for post events (like >>> string numbers) that need to be attached to single notes rather than >>> moments of time. >>> >> >> Great David, thank you! And what about the note duration? Is there any why >> to avoid to specify the note duration and write something like this: >> >> \version "2.19.60" >> >> nc = c_3 >> nd = d_2 >> ne = e_3 >> nf = f_4 >> >> { >> \fixed c' {<>8 [\nc \nd \ne \nf} >> \fixed c' {<>16 [\nc \nd \ne \nf} >> } >> >> (I know I can use a snippet, but I'm curious to see if in simple case like >> this there is simplier solution). > > Well, you can cheat by going inside of chords like > > \version "2.19.60" > > nc = c_3 > nd = d_2 > ne = e_3 > nf = f_4 > > { > \fixed c' {<\nc>8 [ <\nd> <\ne> <\nf>]} > \fixed c' {<\nc>16 [ <\nd> <\ne> <\nf>]} > } > > > since then the durations get removed and reassigned, but you are hardly > going to make your source code more readable by that. > > I think you are likely better off by creating music functions for the > job.
Here is how to do this cheaply: \version "2.19.60" wf = #(define-scheme-function (p f) (ly:pitch? ly:event?) (define-music-function () () #{ $p $f #})) nc = \wf c_3 nd = \wf d_2 ne = \wf e_3 nf = \wf f_4 { \fixed c' {<>8 [\nc \nd \ne <>] \nf} \fixed c' {<>16 [\nc \nd \ne <>] \nf} } Now the <>] thingy is still sort of ugly. I have a patch that can get rid of it. In fact, that patch also makes your example in the first post in this thread compile. And it has lots of other implications. Like letting { c \tweak color #red \p } work as expected. However, it also has some strange consequences. When writing { \displayLilyMusic c \tweak color #red \p } the dynamic will not be included in the output while with { \displayLilyMusic c -\tweak color #red \p } it will. The reason is that in the first case, LilyPond has no way of knowing whether \tweak color #red \p is a post-event or not before calling \tweak, and if it were to end up _not_ being a post-event, \displayLilyMusic should have gotten evaluated before \tweak even got called. So basically LilyPond processes things as normal but allows spurious post events to remain in braced lists and does another pass sweeping them into the right expressions before further processing. For people who want to be in full understanding what is happening, this might be puzzling. For people who want to have things "just work", it might often produce useful results before they start asking questions. -- David Kastrup _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user