From 0747e618a4fa23048e8a8806fd4e1319555c4c11 Mon Sep 17 00:00:00 2001 From: Valentin Date: Thu, 18 Dec 2008 15:10:58 +0100 Subject: [PATCH] Piano staves problem: FIXED At last!! Took me a while, but now the piano staves only appear together, whenever one of the two hands is playing something. The code also supports cross-staff voices, ottavas, clef changes, internal voices etc. A slight bug remains with cross-staff slurs, but IMHO this is quite good already. --- definitions/functions.ly | 44 ++++++++++++++++++++++++++++---------------- definitions/settings.ly | 16 ++++++++-------- master/master.ly | 6 +++--- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/definitions/functions.ly b/definitions/functions.ly index 61b802a..d1408a5 100755 --- a/definitions/functions.ly +++ b/definitions/functions.ly @@ -47,18 +47,22 @@ parallel= %%% Piano stuff (Issue #442 workaround) +#(define (remove music) +"Sends the whole thing to Devnull whenever possible" + (context-spec-music music 'Devnull)) + #(define (event-filter event) - (let ((n (ly:music-property event 'name))) - (not - (or ;; add here event name you do NOT want - (eq? n 'ContextSpeccedMusic) - (eq? n 'ContextChange) - (eq? n 'SimultaneousMusic)) - ))) + (let ((n (ly:music-property event 'name))) + (if (or + (eq? n 'ContextSpeccedMusic) ; to avoid clefs and ottavas + (eq? n 'ContextChange)) ; cross-staff voices are supported + (music-map remove event)) + (if (eq? n 'SimultaneousMusic) ; we don't want a new Voice to be created + (ly:music-set-property! event 'name 'NoteEvent)))) makeGhost = #(define-music-function (parser location music) (ly:music?) - (context-spec-music (music-filter event-filter music) 'PseudoVoice)) + (context-spec-music (music-filter event-filter music) 'PseudoVoice)) showAnyway = #(define-music-function (parser location music) (ly:music?) @@ -81,12 +85,12 @@ PianoDeuxMains= \new Staff = "md" \with { \remove Accidental_engraver } << \new Voice \with { \consists Accidental_engraver } { \clef treble $droite } - %\new Voice { \makeGhost $gauche } + \new Voice { \makeGhost $gauche } >> \new Staff = "mg" \with { \remove Accidental_engraver } << \new Voice \with { \consists Accidental_engraver } { \clef bass $gauche } - %\new Voice { \makeGhost $droite } + \new Voice { \makeGhost $droite } >> >> #}) @@ -97,12 +101,20 @@ gauche = { \change Staff = "percuGauche" } PercuDeuxMains= #(define-music-function (parser location droite gauche) (ly:music? ly:music?) -#{ << %%%FIXME: I /definitely/ should get rid of this option. -\new Staff = "percuDroite" -{ \clef treble $droite } -\new Staff = "percuGauche" \with { \override VerticalAxisGroup #'remove-empty = ##f } -{ \clef bass $gauche } ->> #}) +#{ + \new PianoStaff << + \new Staff = "percuDroite" \with { \remove Accidental_engraver } + << + \new Voice \with { \consists Accidental_engraver } { \clef treble $droite } + \new Voice { \makeGhost $gauche } + >> + \new Staff = "percuGauche" \with { \remove Accidental_engraver } + << + \new Voice \with { \consists Accidental_engraver } { \clef bass $gauche } + \new Voice { \makeGhost $droite } + >> + >> +#}) %% Music formatting -----------------------------------------------% diff --git a/definitions/settings.ly b/definitions/settings.ly index 6153c31..ae8762f 100755 --- a/definitions/settings.ly +++ b/definitions/settings.ly @@ -178,14 +178,14 @@ includeLayout = \layout { \remove Mark_engraver \accepts GhostVoice } - \context { + \context { \name PseudoVoice \alias Voice - \type "Engraver_group" - \consists "Note_heads_engraver" + \type Engraver_group + \consists Note_heads_engraver \consists Pitch_squash_engraver squashedPosition = #0 - \override NoteHead #'stencil = ##f + \override NoteHead #'stencil = #empty-stencil } \context { \Staff @@ -271,14 +271,14 @@ includePartsLayout = \layout { \remove Mark_engraver \accepts GhostVoice } - \context { + \context { \name PseudoVoice \alias Voice - \type "Engraver_group" - \consists "Note_heads_engraver" + \type Engraver_group + \consists Note_heads_engraver \consists Pitch_squash_engraver squashedPosition = #0 - \override NoteHead #'stencil = ##f + \override NoteHead #'stencil = #empty-stencil } \context { \Staff diff --git a/master/master.ly b/master/master.ly index 901059e..cc33abb 100644 --- a/master/master.ly +++ b/master/master.ly @@ -100,19 +100,19 @@ acte = \ActeDeuxTitre piece = \SceneUnTitre } -} %} +} % \score { \ActeDeuxSceneUnBis \header { piece = \Separateur } -} %{ +} %} \score { \ActeDeuxSceneDeux \header { piece = \SceneDeuxTitre } -} % +} %{ \score { \ActeDeuxSceneTrois \header { -- 2.11.4.GIT