Janek Warchoł <janek.lilyp...@gmail.com> writes: > On Fri, Sep 21, 2012 at 2:02 PM, Janek Warchoł > <janek.lilyp...@gmail.com> wrote: >> What's your opinion? How would you do this? Maybe there's no need >> for new syntax constructs? > > To be more credible, here is my try at doing this with a music function: > > sust = > #(define-music-function (parser location note rhythm lasts music) > (ly:pitch? ly:duration? ly:duration? ly:music?) > #{ << > \mergeDifferentlyDottedOn > { \voiceOne $note $rhythm $music } > \new Voice { \voiceTwo $note $lasts } > >> #}) > > \new Staff { > \sust f' 16 4 \sust g' 16 8. \sust a'16 8 b'16 > } > > Hmm. Is it only my impression, or had music functions became easier > to write?
ly:pitch? and ly:duration? argument types sure help a lot when compared to the state used in <URL:http://nicolas.sceaux.free.fr/prelude/prelude.html>. I am not sure whether the function body itself would not actually have worked just in this form if we somehow got pitches and durations assigned to local variables of the right name. But the point is that now I am sure because I don't need to figure out whether I actually have all the strange preconditions for this working in place. Oh, and in case it had not worked, you'd have gotten obscure error messages talking about lilyvar-2745 and similar that did not point to the actual source of the problem. > Anyway, this is quite concise. However, voice "direction" is > hardcoded... probably this could be changed? \voiceOne or similar can be another music argument. > Also, without explicit Staff the output is crazy. No idea whether > this is easy to fix. Wrap your function content into \context Voice { ... } -- David Kastrup _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel