lilypond-user
[Top][All Lists]
Advanced

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

Re: Relative mode


From: Jean Abou Samra
Subject: Re: Relative mode
Date: Thu, 7 Oct 2021 13:50:21 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

Le 07/10/2021 à 12:36, Mahanidhi a écrit :
If so why the command  "global=" works for every lines?


As Leo said, \global just inserts music content.
\relative is not music in itself, it is a
function applying to music. When you say

{ \relative c' { a' b' } { c' d' } }

only the { a' b' } is processed by \relative,
because that's what you feed it as an argument.
{ c' d' } is not part of it. In other words,
\relative is not placed somewhere, but affects
an expression between one point and another.

What you want here is to refactor \global
to make it a function itself instead of a
music variable.

\version "2.22.1"

\language "english"

\layout {
  \context {
    \Score
    \remove "Bar_number_engraver"
     defaultBarType = ""
  }
  \context {
    \Staff
    \remove "Time_signature_engraver"
  }
  \set includeGraceNotes = ##t
}

global = {
  \key gf \major
  \time 4/4
  \override Glissando.style = #'trill
  \override Score.SpacingSpanner.base-shortest-duration =
    #(ly:make-moment 1/128)
  \set includeGraceNotes = ##t
  \override Score.GraceSpacing.common-shortest-duration =
    #(ly:make-moment 1/132)
}

line =
#(define-music-function (music) (ly:music?)
   #{
      \relative c' { \global #music }
   #})

\line {
  \tempo "Slow" 4 = 80
 ef8 ef4 f8 f4 ef8 f8 gf2\glissando af2. \glissando gf4..  gf16 gf2.^"               fine" \bar "||"}
 \addlyrics {A -- mi  to -- mār __ _ su -- dhār __ _ _ dhā -- rā }

\line {
 f8 f8 af4.. af16 af4. gf16 \melisma af  \melismaEnd bf4.  cf16 bf (bf4.)  \bar "|"}
 \addlyrics {tā -- i -- to ā -- māi  dā -- ke tā -- rā __ _ }


About music functions, read

http://lilypond.org/doc/v2.22/Documentation/notation/using-music-functions.html


However, this complication is not needed here,
since you can put all of your \global in the
\layout block, like so:

\version "2.22.1"

\language "english"

\layout {
  \context {
    \Score
    \remove Bar_number_engraver
     defaultBarType = ""
    \override SpacingSpanner.base-shortest-duration =
      #(ly:make-moment 1/128)
    \override GraceSpacing.common-shortest-duration =
      #(ly:make-moment 1/132)
  }
  \context {
    \Staff
    \remove Time_signature_engraver
  }
  \context {
    \Voice
    includeGraceNotes = ##t
    \key gf \major
    \time 4/4
    \override Glissando.style = #'trill
  }
}

\relative c' {
  \tempo "Slow" 4 = 80
 ef8 ef4 f8 f4 ef8 f8 gf2\glissando af2. \glissando gf4..  gf16 gf2.^"               fine" \bar "||"}
 \addlyrics {A -- mi  to -- mār __ _ su -- dhār __ _ _ dhā -- rā }

\relative c' {
 f8 f8 af4.. af16 af4. gf16 \melisma af  \melismaEnd bf4.  cf16 bf (bf4.)  \bar "|"}
 \addlyrics {tā -- i -- to ā -- māi  dā -- ke tā -- rā __ _ }


If you don't like typing \relative c', you can
use the one-argument form (\relative { ... })
which takes the starting point from the first note.
Or you can define a shortcut with

rel = \relative c' \etc

\rel { c1 d2 }

That's a convenient way to spell

rel =
#(define-music-function (music) (ly:music?)
   #{ \relative c' #music #})

\rel { c1 d2 }

and the documentation is at
http://lilypond.org/doc/v2.22/Documentation/notation/substitution-function-examples

I hope that was clear.

Best,
Jean




reply via email to

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