\version "2.19.10" % Create a new xxxStaff and xxxVoice contexts with specified settings, % derived from specified yyyStaff and yyyVoice contexts. % % TODO: instead of having 3 arguments: (parentstaff, parentvoice, parentname) % the function should take just parentname and get parentstaff and parentvoice % from that. newLayoutInstrument = #(define-scheme-function (parser location name parentstaff parentvoice parentname grouping staffsettings voicesettings) (string? ly:context-def? ly:context-def? string? ly:context-def? ly:context-mod? ly:context-mod?) (let ((staffname (string-append name "Staff")) (voicename (string-append name "Voice")) (parentstaffname (string-append parentname "Staff")) (parentvoicename (string-append parentname "Voice"))) #{ \layout { \context { #grouping \accepts #staffname } \context { #parentstaff \name #staffname \alias #parentstaffname \accepts #voicename % is it possible to make it accept Voices of derived instruments? \defaultchild #voicename #staffsettings } \context { #parentvoice \name #voicename \alias #parentvoicename #voicesettings } } #})) % UGH!!! CODE DUPLICATION!!! % This function is almost identical to the one above - obviously, they should be merged, % but I didn't yet find a way to put both \layout and \midi stuff into one function :( newMidiInstrument = #(define-scheme-function (parser location name parentstaff parentvoice parentname grouping staffsettings voicesettings) (string? ly:context-def? ly:context-def? string? ly:context-def? ly:context-mod? ly:context-mod?) (let ((staffname (string-append name "Staff")) (voicename (string-append name "Voice")) (parentstaffname (string-append parentname "Staff")) (parentvoicename (string-append parentname "Voice"))) #{ \midi { \context { #grouping \accepts #staffname } \context { #parentstaff \name #staffname \alias #parentstaffname \accepts #voicename \defaultchild #voicename #staffsettings } \context { #parentvoice \name #voicename \alias #parentvoicename #voicesettings } } #})) % define "instruments" - one generic and another one derived: \layout { \newLayoutInstrument "Vocal" \Staff \Voice "" \ChoirStaff \with { \consists "Ambitus_engraver" instrumentName = "Vocals" shortInstrumentName = "Voc." \dynamicUp \tupletUp } \with { } } \midi { \newMidiInstrument "Vocal" \Staff \Voice "" \ChoirStaff \with { \remove "Staff_performer" } \with { \consists "Staff_performer" midiInstrument = "voice oohs" } } \layout { \newLayoutInstrument "Soprano" \VocalStaff \VocalVoice "Vocal" \ChoirStaff \with { instrumentName = "Soprano" shortInstrumentName = "S" \clef G } \with { } } \midi { \newMidiInstrument "Soprano" \VocalStaff \VocalVoice "Vocal" \ChoirStaff \with { } \with { } } % test: \score { \new SopranoVoice \relative f' { c f c' f } \layout { \override Staff.Stem.thickness = 4 \override VocalStaff.Stem.color = #blue \override SopranoVoice.NoteHead.color = #green } \midi { \set SopranoVoice.midiInstrument = "clarinet" } }