lilypond-user
[Top][All Lists]
Advanced

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

Re: midiPanPosition in midi context block


From: Aaron Hill
Subject: Re: midiPanPosition in midi context block
Date: Fri, 08 Nov 2019 11:39:02 -0800
User-agent: Roundcube Webmail/1.3.8

On 2019-11-08 11:07 am, Thomas Morley wrote:
Below seems to work for \layout.

\version "2.19.83"

idFontSize =
  \applyContext
    #(lambda (ctx)
      (ly:context-set-property! ctx 'fontSize
        (cond ((string=? (ly:context-id ctx) "foo")
               -6)
              ((string=? (ly:context-id ctx) "bar")
               6)
              (else (ly:context-property ctx 'fontSize)))))

\score {
  <<
    \new Staff = "foo"  \relative c' { e4 f g a }
    \new Staff = "bar"  \relative c' { c4 d e f }
  >>
  \layout {
    \context {
      \Staff
      \idFontSize
    }
  }
}

Didn't test for midi, though, why shouldn't the method work there as well.

Created a helper to wrap up the conditional context modification:

%%%%
\version "2.19.83"

modify = #(define-music-function (name mod) (string? ly:context-mod?)
  #{ \applyContext #(lambda (ctx)
        (and (string=? (ly:context-id ctx) name)
              (ly:context-mod-apply! ctx mod))) #})

\score {
  <<
    \new Staff = "foo" \fixed c' { g4 c' a b | c'1 }
    \new Staff = "bar" \fixed c' { e4 g f d | e1 }
  >>
  \layout {
    \context { \Staff
      \modify "foo" \with { fontSize = 3 }
      \modify "bar" \with { \override NoteHead.color = #blue }
    }
  }
  \midi {
    \tempo 4 = 100
    \context { \Staff
      \modify "foo" \with { midiInstrument = "flute" }
      \modify "bar" \with { midiPanPosition = #LEFT }
    }
  }
}
%%%%

MIDI output block works too.  (:


-- Aaron Hill



reply via email to

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