lilypond-user
[Top][All Lists]
Advanced

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

Re: How to define some context statements


From: Thomas Morley
Subject: Re: How to define some context statements
Date: Fri, 18 Jan 2019 22:25:29 +0100

Am Fr., 18. Jan. 2019 um 11:01 Uhr schrieb Werner Arnhold
<address@hidden>:
>
> Dear list,
>
> I often need to have Midi output with different volume or instruments in
> some voices. Here an example:
>
> \version "2.18.2"
>
> global = {
>   \key c \major
>   \time 4/4
> }
>
> soprannoten = \relative c'' {
>   g e e2 f4 d d2
> }
>
> altnoten = \relative c'' {
>   c2 g g2 b4 f
> }
>
> \score {
>   \new ChoirStaff <<
>     \new Staff <<
>       \set Staff.instrumentName = #"Sopran"
>       \new Voice = "sopran" <<
>         \set midiInstrument = #"flute"
>         \global
>         \soprannoten
>       >>
>     >>
>     \new Staff <<
>       \set Staff.instrumentName = #"Alt"
>       \new Voice = "alt" <<
>         \set midiInstrument = #"violin"
>         \global
>         \altnoten
>       >>
>     >>
>   >>
>   \layout{}
>   \midi{
>     \tempo 4 = 80
>       \context {
>         \Staff
>         \remove "Staff_performer"
>       }
>       \context {
>         \Voice
>         \consists "Staff_performer"
>       }
>   }
> }
>
> This works fine. Now I tried to separate the "\context" parts in the
> midi section like
>
> verschiedene_stimmen = {
>   \context \Staff \remove "Staff_performer"
>   \context \Voice \consists "Staff_performer"
> }
>
> score {
> .
> .
> .
>   \midi{
>     \verschiedene_stimmen
>   }
> }
>
> Lilypond complains about unvalid escape sequence "\Staff" at the Place
> of the definition, unexpected "\remove" and so on. That happens even if
> I do not call the defined macro in the midi section.
>
> What will be the reason and how can I make it better. I intend to
> collect such often used constructs in a separate file.
>
> Thanks in advance!
>
> Werner

Hi Werner,

looking at your example, there is no need to move "Staff_performer" at all.
Just set midiInstrument in Staff, You could do so with \set Staff.midiInstrument
But this is done better in \with { ... }, otherwise it may happen you
meet issue 34 in some cases. Same for instrumentName.

Only if you have more than one Voice per Staff moving
"Staff_performer" would make sense.

To store the settings in a callable variable you could do:

\version "2.18.2"

soprannoten = \relative c'' {
  g e e2 f4 d d2
}

altnoten = \relative c'' {
  c2 g g2 b4 f
}

verschiedene_stimmen_midi = \midi {
  \context { \Staff \remove "Staff_performer" }
  \context { \Voice \consists "Staff_performer" }
}

\score {
  \new ChoirStaff <<
    \new Staff <<
      \new Voice = "sopran" \with { midiInstrument = #"flute" }
        { \voiceOne \soprannoten }
      \new Voice = "alt" \with { midiInstrument = #"violin" }
        { \voiceTwo \altnoten }
    >>
  >>
  \layout{}
  \midi {
    \verschiedene_stimmen_midi
%% needs to be called after 'verschiedene_stimmen_midi'
    \tempo 4 = 80
  }
}

HTH,
  Harm



reply via email to

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