lilypond-user
[Top][All Lists]
Advanced

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

Re: simplify the program code


From: Лысов Дмитрий
Subject: Re: simplify the program code
Date: Wed, 17 Aug 2022 16:01:48 +0300

Dear Jean. I have not been able to understand the define-music-function structure. Help please. How can I add a line with lyrics above and below the note bearer? Each note-bearer will have his own lyrics. Both lyrics are related to the melody. Fonts are different. Sample code for a single data item.
 
%\version "2.22.1"  % necessary for upgrading to future LilyPond versions.
 
\header 
   copyright = "Вѧ́тка, ҂вк҃в"
} %header
 
\paper 
{
  (set-paper-size "a4") 
  tagline=##f 
  ragged-last = ##t
  myStaffSize = #21
  #(define fonts (make-pango-font-tree 
    "Times New Roman"
    "Times New Roman"
    "Times New Roman"
    (/ myStaffSize 21)))
  system-system-spacing = #'((padding . 3.9)) 
}
 
\layout 
{
  indent = 0.0 
  \context 
  {
    \Lyrics 
    \remove Time_signature_engraver
    \remove "Forbid_line_break_engraver"
  } 
  \context 
  {
    \Score
    \override SpacingSpanner.spacing-increment = 0.5
    \Staff
  }
  \context 
  {
    \KievanVoice
    \stemDown
    fontSize = 1.0
  }
 
\midi 
{
  \context 
  {
    \Score
    tempoWholesPerMinute = #(ly:make-moment 110 2)
  }
  \context 
  {
    \Staff
    \remove Staff_performer
  }
  \context 
  {
    \Voice
    \consists Staff_performer
  }
}
 
melody = 
{
  \[(d4 c)\] \[(d e)\] f1 \[(e4 d)\] f2 e d1\bar "|" 
}
 
text = \lyricmode
{
  \override LyricText.font-name = #"Arial" 
  \override LyricText.font-size = #4 
  \override LyricSpace.minimum-distance = #0.8 
  
  la la la la la la la
 
znamen = \lyricmode
{
  \override LyricText.font-name = #"Courier"
  \override LyricText.font-size = #4
  \override LyricSpace.minimum-distance = #2
  
  ta ta ta ta ta ta ta
 
\markup { \huge { "Гла́съ д҃: ᲂу҆до́ль" }}
\score
  <<
    \new KievanStaff  = slavonic 
    <<
      \new KievanVoice = "one" 
      \relative c'
      {
        \cadenzaOn 
        \melody
        \bar "k"
        \cadenzaOff
      }
    >>
    
    \new Lyrics 
    \lyricsto "one" 
    \text
    
    \new Lyrics \with {alignAboveContext = slavonic} 
    \lyricsto "one" 
    \znamen            
  >>
  \layout{}
  \midi{}
} %score
 
27.06.2022, 09:48, "Jean Abou Samra" <jean@abou-samra.fr>:

Le 26/06/2022 à 20:25, Лысов Дмитрий a écrit :

 Thanks. That's not bad. Probably, the insertion of the \markup block
 in \score should not be done. Then you will get one midi file. Still,
 it is more convenient to listen to individual midi files.



1. It is usually more convenient if you move global \layout
and \midi settings to a separate block on the top-level rather
than duplicating them.

2. To move the markups inside the score, you can use headers:

\score {
   \header {
     piece = \markup ...
   }
   ...
}

3. Define a substitution function to do the rest. (This is easier
with the previous bullet point since it only has to return one single
value.)




\version "2.23.9"

\header {
   title = "Сборник мелодических формул знаменного распева" %\markup {
\override #'(line-width . 60) \wordwrap-string  { "Конда́къ ..., гла́съ
є҃:"  } }
   %subtitle = ""
   %subsubtitle =  ""
   composer= "Штейнберг Б."
   poet = "Москва 2017"
   %copyright = ""
}

\paper {
   #(set-paper-size "a4")
   %page-count = # 1
   tagline=##f
   %ragged-last = ##t
   ragged-right = ##t
   myStaffSize = #21
   #(define fonts (make-pango-font-tree
                   "Times New Roman"
                   "Times New Roman"
                   "Times New Roman"
                   (/ myStaffSize 21)))
}

\layout {
   indent = 0.0
   \context {
     \Lyrics
     \override LyricText #'font-size = #4
     \override LyricText #'font-name = #"Times New Roman"
     \override LyricSpace.minimum-distance = #0.8
   }
}

#(define counter-alist '())

#(define-markup-command (counter layout props name) (string?)
    "Increases and prints out the value of the given counter named
@var{name}.
    If the counter does not yet exist, it is initialized with 1."
    (let* ((oldval (assoc-ref counter-alist name))
           (newval (if (number? oldval) (+ oldval 1) 1)))
      (set! counter-alist (assoc-set! counter-alist name newval))
      (interpret-markup layout props
                        (markup (number->string newval)))))

#(define-markup-command (setcounter layout props name value) (string?
number?)
    "Set the given counter named @var{name} to the given @var{value} and
prints
    out the value. The counter does not yet have to exist."
    (set! counter-alist (assoc-set! counter-alist name (- value 1)))
    (interpret-markup layout props (make-counter-markup name)))

\markup { \setcounter #"mycounter" #-1 }
\markup { \fill-line \huge { "Глас 1" }}
\markup { \fill-line \huge { "Начальные" }}
\markup { Номер midi файла: \counter #"mycounter" }

\layout {
   \context {
     \Score
     \override SpacingSpanner.spacing-increment = 0.5
   }
   \context {
     \KievanVoice
     \stemDown
     fontSize = 1.0
   }
}

\midi {
   \context {
     \Score
     tempoWholesPerMinute = #(ly:make-moment 110 2)
   }
   \context {
     \Staff
     \remove Staff_performer
   }
   \context {
     \Voice
     \remove Staff_performer
   }
}

makeScore =
#(define-scheme-function (mark notes) (markup? ly:music?)
    #{
      \score {
        \header {
          piece = \markup { Номер midi файла: \counter #"mycounter" }
        }
        \new KievanVoice = "melody" \relative c' {
          \cadenzaOn
          \mark #mark
          #notes
          \bar "|"
        }
        \layout { }
        \midi { }
      }
    #})

\makeScore Удра { e4 c d f e d c d e d e1 }
\makeScore Рымза { e4 c d e f e d c2 d e1 }
\makeScore Рутва { e2 e4 c d f e d c d e d e1 }
\makeScore Перегиб { e2 e4 c d f e d c2 d e1 }
\makeScore "Вознос последний" { d2 d4 f e d c b a1 g }




See these pages in the documentation:

https://lilypond.org/doc/v2.23/Documentation/notation/creating-titles-headers-and-footers#default-layout-of-bookpart-and-score-titles
https://lilypond.org/doc/v2.23/Documentation/extending/scheme-functions.html

(You need define-scheme-function rather than the more usual
define-music-function because this function returns a whole
\score block, not some music that could be used within a larger
piece of music.)

Best,
Jean
 


reply via email to

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