lilypond-user
[Top][All Lists]
Advanced

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

function argument computation


From: Peter Buhr
Subject: function argument computation
Date: Fri, 25 Feb 2011 09:20:46 -0500

I'm trying to factor out common code in some music functions. Below is a
fragment of the code illustrating my problem. It's been years since I've used
Lisp so please appreciate the naivety in this question.

I want to do a computation at the call and pass the result as an argument to
a function parameter:

        \base (concat "XXX" $suffix) #$suffix   % DOES NOT WORK

I've tried a number of things but I'm just guessing. Is this possible? And if
it is possible, what is the syntax?

============================================================================

\version "2.13.40"
\include "english.ly"
#(set-default-paper-size "letter")
#(set-global-staff-size 24)

base = #(define-music-function (parser location prefix suffix) (string? string?)
#{
        \once \override TextSpanner #'bound-details #'left #'text = \markup { 
\concat { $prefix ":" $suffix } }
#})

specialA = #(define-music-function (parser location suffix) (string?)
#{
        \base #"Foo" #$suffix
#})

specialB = #(define-music-function (parser location suffix) (string?)
#{
        \base (concat "XXX" $suffix) #$suffix   % DOES NOT WORK
#})

\score {
        \relative c' {
                \base #"Foo" #"Bar" a \startTextSpan b c d e g \stopTextSpan
                \specialA #"Bar"    a \startTextSpan b c d e g \stopTextSpan
                \specialB #"YYY"    a \startTextSpan b c d e g \stopTextSpan
        } % relative
} % score

% Local Variables: %
% tab-width: 4 %
% compile-command: "lilypond --ps test.ly" %
% End: %



reply via email to

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