David and Jerry,

I've been using the "method" shown on that Lilypond doc page for years. I confirm that it does work for me. I can put

\set midiInstrument = #"<name>"

anywhere in a voice and LP will change the midi instrument. Which is why I suggested it to Jerry.

But there is no denying that David (of all people) certainly knows whereof he speaks. The example code he provided does exactly the same thing, without needing to modify the \staff and \voice contexts. It has the advantage that it's much easier to code (imagine that!)

JH - A working code example for you is David's code

%%%CODE
\version "2.20.0"
\language "English"
\score {
  \new Staff \with { midiInstrument = "violin" }
  { c'' c'' c'' c''
    \set Staff.midiInstrument = "pizzicato strings"
    c'' c'' c'' c''
    \set Staff.midiInstrument = "violin"
    c'' c'' c'' c''
  }
  \midi {}
}
%%%CODE

--
--

“Happiness is the meaning and the purpose of life, the whole aim and end of 
human existence.”

― Aristotle

Reply via email to