lilypond-user
[Top][All Lists]
Advanced

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

Re: Current octave in relative mode


From: Flaming Hakama by Elaine
Subject: Re: Current octave in relative mode
Date: Fri, 15 May 2020 18:31:40 -0700



---------- Forwarded message ----------
From: Klaus Blum <address@hidden>
To: "address@hidden" <address@hidden>
Cc: 
Bcc: 
Date: Fri, 15 May 2020 12:01:06 +0200
Subject: Current octave in relative mode
Hi,

I have a function that uses a music _expression_ twice.
My problem is:
In relative mode, this _expression_ can lead into a different octave. Then
the second application of the music _expression_ starts from that new octave.
(See the last two invocations of "\highlight" in the example below)

Is there something I can do INSIDE my function to prevent this? E.g.
storing and re-applying the current octave? Thanks for any hint.  :)


% ----------------------------------------
highlight =
#(define-music-function (mus)
    (ly:music?)
    #{
      <<
        $mus
        \makeClusters $mus
      >>
    #})

\new Staff {
   \highlight { c'8 d' e' f' g' a' b' c'' }
   \relative c' {
     c1  \highlight { c8 d e f g f e d }
     c1  \highlight { c8 d e f g a b c }
     c1  \highlight { f,4 e d c }
     c1
   }
}
% ----------------------------------------

Cheers,
Klaus

I'm not quite sure what you are after here, except that some things are not in the octave you want, but I'm not sure which.

In any case, the solution to runaway relatives is actually to use more of them.  

You see, each music _expression_ with curly braces { } may or may not be  distinct.  If you do not say \relative or \fixed, then that music _expression_ { } does take it's octave from whatever the current octave is, and whatever follows it starts off from the octave that the music _expression_ { } ends with.

However, if you use \relative on every one, then:
 
1) The octave of the notes inside the \relative c' {} you pass to your function is defined and it does not matter what the current octave is of the enclosing _expression_.

But more importantly
2) The entirety of the music _expression_ inside the \relative c' {} you pass to your function is omitted from the calculation of the octave of what follows.

So, in your example, if all the c1's are supposed to be the same octave
this is accomplished by just specifying each of the ones you pass to your function. 
 

\version "2.19.81"
% ----------------------------------------
highlight =
#(define-music-function (mus)
  (ly:music?)
  (make-relative (mus) mus
   #{
     <<
       $mus
       \makeClusters $mus
     >>
   #}))

% Unsafe
\new Staff {
  \highlight { c'8 d' e' f' g' a' b' c'' }
  \relative c' {
    c1  \highlight { c8 d e f g f e d }
    c1  \highlight { c8 d e f g a b c }
    c1  \highlight { f,4 e d c }
    c1
  }
}

% Safe
\new Staff {
  \highlight { c'8 d' e' f' g' a' b' c'' }
  \relative c' {
    c1  \highlight \relative c' { c8 d e f g f e d }
    c1  \highlight \relative c' { c8 d e f g a b c }
    c1  \highlight \relative c' { f,4 e d c }
    c1
  }
}
% ----------------------------------------


HTH,

Elaine Alt
415 . 341 .4954                                           "Confusion is highly underrated"
address@hidden
Producer ~ Composer ~ Instrumentalist ~ Educator
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

reply via email to

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