lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme question on strict substitution


From: Trevor Bača
Subject: Re: Scheme question on strict substitution
Date: Wed, 29 Nov 2006 11:27:56 -0600

On 11/29/06, Mats Bengtsson <address@hidden> wrote:
No, this doesn't work.

What does work is
\version "2.10.0"

fraction = #(define-music-function (parser location music) (ly:music?)
     #{
        \tweak #'text #tuplet-number::calc-fraction-text $music
     #})

This is exactly what I was looking for. Thanks, as usual, Mats.


\relative c'{
\fraction
        \times 2/3 {
            c'8 c'8 c'8
        }

}

However, what is the reason to use \tweak at all? Why not simply do
an ordinary \once \override:

\version "2.10.0"

fraction = \override TupletNumber #'text =
#tuplet-number::calc-fraction-text

\relative c'{
\fraction
        \times 2/3 {
            c'8 c'8 c'8
        }
}

Ah, because we apparently need \tweak in the (rather specific) case of
nested tuplets whose TupletNumbers carry different 'text values.

Here's a snippet from the 2.9 NEWS file that shows both fraction text
and denominator text working together happily in a nested tuplet:

% ****************************************************************
% ly snippet:
% ****************************************************************
\new Staff {
 \time 5/4
 \tweak #'text #tuplet-number::calc-fraction-text
 %\once \override TupletNumber #'text = #tuplet-number::calc-fraction-text
 \times 5/3 {
    %\once \override TupletNumber #'text =
#tuplet-number::calc-denominator-text
    \tweak #'text  #tuplet-number::calc-denominator-text
    \times 2/3 {
       c'8[ c'8 c'8]
    }
    \times 2/3 {
       c'8[ c'8 c'8]
    }
    \times 2/3 {
       c'8[ c'8 c'8]
    }
 }
}

% ****************************************************************
% end ly snippet
% ****************************************************************

Note, however, that if we swap the comments around and change the
\tweaks to \overrides, that the example won't work -- both sets of
TupletNumbers will have denominator text only, thus ignoring the
fraction text for the outer tuplet.

I guess I've never really had a good grasp on how \tweak works; can
anybody explain why the example above doesn't work with \overrides but
does work with \tweaks?

Section 9.3.5 "Objects connected to the input" says "In some cases, it
is possible to take a short-cut for tuning graphical objects. For
objects that result directly from a piece of the input, you can use
the \tweak function ...". But I've never really understood what this
means. What does it mean for an objected to "be connected to the
input"? Are all objects connected to input? Objects only come about
from input, right?

Instead, of understanding "connectedness to input" as being behind
\tweak, I've instead mentally adopted the idea that \tweak is
necessary (instead of \override) when you want to separately modify
the attributes of two or more objects that instantiate at the *same
musical moment*. 9.5.3 gives the example of \tweaking noteheads in a
chord, and the noteheads in a chord certainly instantiate at the same
musical moment. Likewise for the nested tuplets in the example here:
the nested tuplets instantiate at the same musical moment, so that
seems to trigger the need for \tweak instead of \override.

Is the understanding I've worked out for myself correct, ie, that we
use \tweak when we want to modify objects that instantiate at the same
musical moment? And, if so, maybe the idea of "sameness of musical
moment" can replace the idea of "connectedness to input" in 9.3.5.


--
Trevor Bača
address@hidden

reply via email to

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