lilypond-user
[Top][All Lists]
Advanced

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

Re: simplify the program code


From: Jean Abou Samra
Subject: Re: simplify the program code
Date: Mon, 27 Jun 2022 08:48:26 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0

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]