lilypond

Lilypond: Produce MIDI and PDF output simultaneously


When I am evoking lilypond in order to produce midi output, I comment in an empty midi block in the score block. Then, lilypond produces a midifile instead of a PDF file. I want to create both outputs simultaneously to be able to listen to the changes and see the changes in the pdf file. Is this possible? Commenting the midi block in and out becomes a bit cumbersome after a while, and an option to produce both outputs at the same time would help me a lot!

This is an example ly file to demonstrate my workflow:


\score {
  \midi {} % Commented out each time I want to produce PDF
  
  \new PianoStaff << 
    \new Staff {
      \key f \minor
      \mp
      \relative c''' {
        c
      }
    }

    \new Staff {
      \relative c {
       c
      }
    }
  >>
}


Solution

  • As Ole V.V suggested in his comment, it is possible to create both outputs simultaneously by adding a layout block in the score block as follows:

    
    \score {
      \midi {} % Commented out each time I want to produce PDF
      
      \layout{} % Adding this does the trick, thanks to Ole V.V's comment
    
      \new PianoStaff << 
        \new Staff {
          \key f \minor
          \mp
          \relative c''' {
            c
          }
        }
    
        \new Staff {
          \relative c {
           c
          }
        }
      >>
    }