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: Lukas-Fabian Moser
Subject: Re: Ensemble of two instruments in the code
Date: Fri, 17 Sep 2021 10:37:57 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

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]