Wow, what an adorable solution! Merci beaucoup, Jean! You have a gift!
F. El mar, 9 may 2023 a las 11:35, Jean Abou Samra (<j...@abou-samra.fr>) escribió: > Le mardi 09 mai 2023 à 11:10 -0300, Federico Sarudiansky a écrit : > > Hi everyone! Please consider the following problem: a work for a soloist > and accompaniment in which there is an «alternative» part. For instance, a > work for flute and guitar which the composer allows to be played on violin. > The solo parts are almost identical, and differ only in isolated places. > Following the example, I'd like to generate a flute part, a violin part and > a score in which the flute is printed in full and the violin part is only > shown in the form of ossias. This MWE shows the idea: > > Is there a way of automatically generate \musicoss from \music? For if it > is, everything can be made from only one musical source. Hope someone has > an idea. I looked for it in LSR and in the lilypond-user archives to no > avail. But perhaps the answer is obvious. > > Try like this? > > \version "2.24.1" > > \tagGroup fl,vl,vl-ossia > > fluteViolinDifferent = > #(define-music-function (flute violin) (ly:music? ly:music?) > (make-relative (flute violin) #{ #flute #violin #} > #{ > << > \tag fl $flute > \tag vl $violin > \tag vl-ossia > \new Staff \with { > alignAboveContext = "main" > \magnifyStaff #2/3 > \remove Clef_engraver > \remove Time_signature_engraver > } > $violin > >> > #})) > > music = \relative { > c'4 d e f | > \fluteViolinDifferent > { g a b c } > { g f d c } > g' g g g | > } > > \markup{flute part} > \score { \new Staff \keepWithTag fl \music } > \markup{violin part} > \score { \new Staff \keepWithTag vl \music } > \markup{score} > \score { \new Staff = main \keepWithTag fl,vl-ossia \music } > > Basically, the idea is to use a function which emits the violin music > twice, once in the main context for the separate violin part, and once > wrapped in \new Staff \with { ... } for the ossia. >