lilypond-user
[Top][All Lists]
Advanced

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

Re: Ensemble of two instruments in the code


From: Виноградов Юрий
Subject: Re: Ensemble of two instruments in the code
Date: Wed, 22 Sep 2021 00:16:14 +0300

Hello. Yes, that's what I wanted to do. Thank you very much. The only thing is that it is still very difficult for me to understand. I don't know much about programming. Thank you again.
 
 
С уважением,
Виноградов Юрий.
 
 
 
17.09.2021, 11:38, "Lukas-Fabian Moser" <lfm@gmx.de>:

Hi Yuri,

Am 17.09.21 um 07:39 schrieb Виноградов Юрий:

 It seems like \RemoveAllEmpyStaves is what you want:

 %%%
 \version "2.22.1"

 instrOne = \relative c' { \repeat unfold 16 { c4 c c c } }
 instrTwo = \relative c' { R1 * 8 \repeat unfold 8 { c4 c c c } }

 \score {
   <<
     \new Staff \with { instrumentName = "Instr 1" } \instrOne
     \new Staff \with { instrumentName = "Instr 2" } \instrTwo
   >>
   \layout {
     \context {
       \Staff
       \RemoveAllEmptyStaves
     }
   }
 }
 %%%
 

 Hello. Thanks for the help. But another problem has opened up. This
 command removes empty bars in the entire product. And I need to delete
 the bars only at the beginning. Help please.


For this, you need to modify the keepAliveInterfaces list: It contains
the list of interfaces (think of them as "events" in a staff) that the
staff is kept visible for. We want to switch mid-piece to a mode where
rests are enough to keep a staff alive.

For example, one can write a convenient shorthand:

\version "2.22"

\layout {
   \context {
     \Score
     \RemoveAllEmptyStaves
   }
}

removeKeepAliveCriterion =
#(define-music-function (interface) (symbol?)
    #{
      \context Staff {
        \applyContext
        #(lambda (ctx)
           (ly:context-set-property!
            ctx 'keepAliveInterfaces
            (delete (symbol-append interface '-interface)
                    (ly:context-property ctx 'keepAliveInterfaces)
                    eq?)))
      }
    #})

addKeepAliveCriterion =
#(define-music-function (interface) (symbol?)
    #{
      \context Staff {
        \applyContext
        #(lambda (ctx)
           (ly:context-set-property!
            ctx 'keepAliveInterfaces
            (cons (symbol-append interface '-interface)
                  (ly:context-property ctx 'keepAliveInterfaces))))
      }
    #})


<<
   \new Staff { \repeat unfold 300 c'4 }
   \new Staff {
     R1*20

     \repeat unfold 60 e'4

     \addKeepAliveCriterion rest
     R1*40

     % in order to allow hiding of staff when only rests are encountered, do
     % \removeKeepAliveCriterion rest
     % also try other criteria, e.g. note-head :-)
   }
 >>

Lukas
 


reply via email to

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