[Top][All Lists]

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

Re: midiPanPosition in midi context block

From: Thomas Morley
Subject: Re: midiPanPosition in midi context block
Date: Mon, 11 Nov 2019 23:14:33 +0100

Hi Matt,

I had a hard time to compile your code, because your email-client
inserts not common spacers at line-begin, but something else. I didn't
bother to identify...
Please: Use plain text !!!

Here your _compilable_ example:

sopStaff = \new Staff = "sop" {
  \relative c' { e4 f g a }
altoStaff = \new Staff = "alto" {
  \relative c' { c4 d e f }
\score {
    \context Staff = "sop" {
      \set Staff.midiPanPosition = #1.0
    \context Staff = "alto" {
      \set Staff.midiPanPosition = #-1.0
  \midi { }

What happens is: you create two named Staffs. In score you use
simultaneous-music, i.e. << ... >>
Inside of the simultaneous-music you continue or amend or ... (don't
know the correct english term) the already started Staffs.
That's the meaning of
\context Staff = "foo" ...
If a Staff-context named "foo" exists continue with it otherwise
create a new one, named "foo"

Thus, \set Staff.midiPanPosition is added to the relevant Staff

Am Mo., 11. Nov. 2019 um 14:03 Uhr schrieb Matt Wallis <address@hidden>:
> On 08/11/2019 14:30, David Kastrup wrote:

> ... which works. But now I'm worried, because the example I copied was from 
> other code I have written. Is this another abomination?

No abomination, LilyPond is fine with it, but I'd never code it that way.
Context-settings for the whole context belog into \with or the score-
or even book-layout, imho.
Ofcourse \with ... can be stored in a variable.

> 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 
> (
> "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."

I think there's a misunderstanding.
The command \context can be used at different places with different
syntax and meaning.
Look at:

\score {
    \context Voice = "foo" { R1*2 }
    \new Voice {
      \context Score
        #(lambda (ctx)
           (pretty-print ctx)
           (ly:context-set-property! ctx 'barAlways #t))
      \repeat unfold 8 b8

  \layout {
    \context {
      \override MultiMeasureRest.color = #green

The first occurrence is done to initiate a certain named context (if
not already  there), as explained above.
The second occurrence specifies the context the procedure should be
applied to. Comment "\context Score" and it will not work any more.
Admittedly this whole command could be written more easily, I used
this way to demonstrate a certain aspect of \context.
With the third occurence in score-layout, first the definition for
Voice is copied and then amended with the override.

Your example code relies only on the first mentioned possibility, as
far as the \context-command is meant, actually the context is modified
by the \set-command.

> This does little to discourage my abomination. Also, it makes me suspect that 
> my code above (with the context block within the score)

Well, what's a context-block?
You modify the contexts there with \set
Else, see above.

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

Contexts can be modified by setting context-properties (among others).
They can be specified in book- or score-layout/midi. Syntax:
\layout {
  \context {
    whatEverContextProperty = <value>

Or in \with... Syntax:
\new/context WhatEverContext \with { whatEverContextProperty = <value> }

Or "on the fly". Syntax:
  \set WhatEverContext.whatEverContextProperty = <value>

Actually your example demonstrated only the last case.
I recommend to reread the docs. Probably the examples above help ...


P.S. Did I mention:
Please always use plain text !!

reply via email to

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