On 08/11/2019 14:30, David Kastrup wrote:
Matt Wallis <[email protected]> writes:
But it doesn't work if I try to set the midiPanPosition inside a midi
context block like this:
\version "2.19.83"
\include "english.ly"
sopStaff = \new Staff = "sop" {
\relative c' { e4 f g a }
}
altoStaff = \new Staff = "alto" {
\relative c' { c4 d e f }
}
\score {
<<
\sopStaff
\altoStaff
>>
\midi {
\context Staff = "sop" {
\set Staff.midiPanPosition = #1.0
\set Staff.midiBalance = #1.0
}
\context Staff = "alto" {
\set Staff.midiPanPosition = #-1.0
\set Staff.midiBalance = #-1.0
}
}
}
This is terrible. Really, really terrible. \context Staff = "xxx"
should never be allowed in an output block since setting name-specific
context defs is not supported and does not make sense, either. I'll see
whether I can stop the parser from accepting this abomination.
Strong words! My code, above, was the result of an error in pasting.
What I had meant to do is this:
\score {
<<
\sopStaff
\altoStaff
\context Staff = "sop" {
\set Staff.midiPanPosition = #1.0
}
\context Staff = "alto" {
\set Staff.midiPanPosition = #-1.0
}
>>
\midi { }
... which works. But now I'm worried, because the example I copied was
from other code I have written. Is this another abomination?
I look forward to the day when I understand enough about how lilypond
works internally in order to avoid abominations that happen to get past
the parser.
Perhaps someone could point me to the relevant syntax reference docs
that say (or at least imply) that my original abomination is illegal
syntax, and to check that my amendment (above) is valid syntactically.
I've had a look for some reference material, and found this
(http://lilypond.org/doc/v2.19/Documentation/notation/contexts-explained):
"Output definitions define the relation between contexts as well as
their respective default settings. While most changes will usually
be made inside of a|\layout|block, Midi-related settings will only
have an effect when made within a|\midi|block."
This does little to discourage my abomination. Also, itmakes me suspect
that my code above (with the context block within the score) is also
working only by accident (because it sets midi settings outside the midi
block). So, am I right in thinking that the only legal place for midi
settings for a Staff as inside the original definition of that Staff?
Furthermore, the result of doing this is that both staffs are played
through the left, and nothing on the right.
Am I doing something wrong?
As a rule, changing syntax until something passes the parser instead of
working from documented syntax and examples is a bad idea.
I couldn't agree more.
Most of the
time, you'll trigger error messages pinpointing the problem.
But sometimes there are oversights.
I want to do the setting in the midi context block because I require
different pan positions for a staff depending on which score it
appears in.
Then create different variables/expressions for that purpose. But the
\midi block cannot sensibly differentiate between differently named
contexts.
Thanks for the advice. I shall use variables.