lilypond-user
[Top][All Lists]
Advanced

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

How to define functions that generate music functions?


From: Juha Erkkila
Subject: How to define functions that generate music functions?
Date: Wed, 15 Dec 2010 18:29:35 +0200
User-agent: Mutt/1.4.2.3i

Is it possible to define functions that generate music functions
in Lilypond?  I'm looking something to this effect:

-----
\version "2.12.3"

musicA = #(define-music-function (parser location music)
                                 (ly:music?)
           #{ c4 d e f $music #})

\musicA { g4 a b a }

% makeMusicFn = #(define-music-function (parser location prepend-music)
%                                       (ly:music?)
%                 (define-music-function (parser location append-music)
%                                        (ly:music?)
%                  #{ $prepend-music $append-music #}))
%
% musicB = \makeMusicFn { c4 d e f }
% 
% \musicB { g4 a b a }
-----

Here expressions "\musicA { g4 a b a }" and "\musicB { g4 a b a }"
should evaluate to same music expression, that is
{ c4 d e f g4 a b a }.  The expressions that are commented out are
attempts to achieve what I'm looking for.  The above syntax is,
however, wrong, as define-music-function must return a music
expression, not a function.

Any ideas?

Juha



reply via email to

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