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: Paul Hodges
Subject: Re: Ensemble of two instruments in the code
Date: Fri, 17 Sep 2021 12:18:18 +0100
User-agent: eM_Client/8.2.1473.0

My first thought for this was:

\version "2.22.1"

instrTwo = \relative c' { \repeat unfold 8 { c4 c c c }
                           R1 * 12
                           \repeat unfold 4 { c4 c c c } }
instrOne = \relative c' {
   \repeat unfold 7 { c4 c c c }
   << { \repeat unfold 24 { c4 c c c } }
      \new Staff \with { instrumentName = "Instr 2" } { \instrTwo }
   >>
}
\score {
   <<
     \new Staff \with { instrumentName = "Instr 1" } \instrOne
   >>
   \layout {
   }
}

You may need to fiddle with some rests at the start of the second 
instrument (and hence where you create the second staff) to get a clean 
line start.

Regards,
Paul

On 17/09/2021 09:37:57, "Lukas-Fabian Moser" <lfm@gmx.de> wrote:

>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]