Dear David thank you for explaining the problem and pointing me out
the documentation where this is discussed.

Yes, I could organize my code differently but this would be less
clear. Try to have a look to the attached image capture.png.
The first line is the wanted screen output, the second line the wanted
midi output  (that is normally not intended to print).
Now let me discuss how I would like to obtain it.


* * * Score blocks * * *
I would like to write the two score blocks in the following way:

\score
{
  \new Staff = "left" {\keepWithTag #'screenOut \left}
  \layout { }
}

\score
{
  \new Staff = "left" {\keepWithTag #'midiOut \left}
  \midi { }
}


* * * Variables * * *
Because the piece I'm going to write uses a simple and repetitive bass
structure I create the following variables

cbar =  {\xco \keepWithTag #'chordLetter \xcM \xcM \xcM}
fbar =  {\xfo \keepWithTag #'chordLetter \xfM \xfM \xfM}
gsbar = {\xgo \keepWithTag #'chordLetter \xgs \xgs \xgs}

Here you can see I use the keepWithTag keyword because I want some
some specific formatting with some elements. Unfortunately this does
not work because doing in this way is like having the nested
\keepWithTag we are discussing.

* * * Whole code NOT working * * *

This is the whole code (that does not work) in case you want to try
it. (Attached to this mail you can find the AccordionStandardBass.ly
that I'm working on)

version "2.19.40"
\include "AccordionStandardBass.ly"

cbar =  {\xco \keepWithTag #'chordLetter \xcM \xcM \xcM}
fbar =  {\xfo \keepWithTag #'chordLetter \xfM \xfM \xfM}
gsbar = {\xgo \keepWithTag #'chordLetter \xgs \xgs \xgs}

left =
{
  \clef "bass"
  \fbar
  \gsbar
  \cbar
}

\score
{
  \new Staff = "left" {\keepWithTag #'screenOut \left}
  \layout { }
}

\score
{
  \new Staff = "left" {\keepWithTag #'midiOut \left}
  \midi { }
}

* * * Whole code working * * *

Finally this is how I wrote the previous code so that is works. It's a
bit less clear and less straightforward.
The changes are
- the variable definitions written in a "negative form"
- the score block use \keepWithTag #'(screenOut chordLetter)

\version "2.19.40"
\include "AccordionStandardBass.ly"

cbar =  {\xco \xcM \removeWithTag #'chordLetter \xcM \removeWithTag
#'chordLetter \xcM}
fbar =  {\xfo \xfM \removeWithTag #'chordLetter \xfM \removeWithTag
#'chordLetter \xfM}
gsbar = {\xgo \xgs \removeWithTag #'chordLetter \xgs \removeWithTag
#'chordLetter \xgs}


left =
{
  \clef "bass"
  \fbar
  \gsbar
  \cbar
}

\score
{
  \new Staff = "left"  {\keepWithTag #'(screenOut chordLetter) \left}
  \layout { }
}

\score
{
  \new Staff = "left" \with { midiInstrument = "accordion"}
{\keepWithTag #'midiOut \left}
  \midi { }
}

Best regards, g.
\version "2.19.40"

% Accordion Standard Bass library
% Last change: 2016 May 6

% This definitios is to use when need "chord type letter" on chord
% majorChordLetter = -\tag#'chordLetter _\tweak #'direction #UP _\markup {M}
% minorChordLetter = -\tag#'chordLetter _\tweak #'direction #UP _\markup {m}
% dominantSeventhChordLetter = -\tag#'chordLetter _\tweak #'direction #UP _\markup {7}
% diminishedSeventhChordLetter = -\tag#'chordLetter _\tweak #'direction #UP _\markup {d}

% This definitios is to use when need "chord type letter" on note
majorChordLetter = -\tag#'chordLetter ^\markup {M}
minorChordLetter = -\tag#'chordLetter ^\markup {m}
dominantSeventhChordLetter = -\tag#'chordLetter ^\markup {7}
diminishedSeventhChordLetter = -\tag#'chordLetter ^\markup {d}

majorChord = \chordmode {a}
minorChord = \chordmode {a:m}
dominantSeventhChord = \chordmode {a:7^5}
diminishedSeventhChord = \chordmode {a:m7^5}

%%% *** %%% *** %%% *** %%% *** %%% *** %%% *** %%%
rootNote = c

rootNoteExp = { \rootNote} 
rootNoteDouble = {<\rootNote' \rootNote>}
midiMajorChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \majorChord}
midiMinorChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \minorChord}
midiDominantSeventhChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \dominantSeventhChord}
midiDiminishedSeventhChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \diminishedSeventhChord}

screenMajorChord = {\rootNote' \majorChordLetter}
screenMinorChord = {\rootNote' \minorChordLetter}
screenDominantSeventhChord = {\rootNote' \dominantSeventhChordLetter}
screenDiminishedSeventhChord = {\rootNote' \diminishedSeventhChordLetter}

xco = {\tag #'midiOut \rootNoteDouble 
      \tag #'screenOut \rootNoteExp }

xcM = {\tag #'midiOut \midiMajorChord 
       \tag #'screenOut \screenMajorChord }

xcm = {\tag #'midiOut \midiMinorChord
       \tag #'screenOut \screenMinorChord}

xcs = {\tag #'midiOut \midiDominantSeventhChord
       \tag #'screenOut \screenDominantSeventhChord}

xcd = {\tag #'midiOut \midiDiminishedSeventhChord
       \tag #'screenOut \screenDiminishedSeventhChord}

xcr = {<<\xco \xcM>>}

%%% *** %%% *** %%% *** %%% *** %%% *** %%% *** %%%
rootNote = d,

rootNoteExp = { \rootNote} 
rootNoteDouble = {<\rootNote' \rootNote>}
midiMajorChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \majorChord}
midiMinorChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \minorChord}
midiDominantSeventhChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \dominantSeventhChord}
midiDiminishedSeventhChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \diminishedSeventhChord}

screenMajorChord = {\rootNote' \majorChordLetter}
screenMinorChord = {\rootNote' \minorChordLetter}
screenDominantSeventhChord = {\rootNote' \dominantSeventhChordLetter}
screenDiminishedSeventhChord = {\rootNote' \diminishedSeventhChordLetter}

xdo = {\tag #'midiOut \rootNoteDouble 
      \tag #'screenOut \rootNoteExp }

xdM = {\tag #'midiOut \midiMajorChord 
       \tag #'screenOut \screenMajorChord }

xdm = {\tag #'midiOut \midiMinorChord
       \tag #'screenOut \screenMinorChord}

xds = {\tag #'midiOut \midiDominantSeventhChord
       \tag #'screenOut \screenDominantSeventhChord}

xdd = {\tag #'midiOut \midiDiminishedSeventhChord
       \tag #'screenOut \screenDiminishedSeventhChord}

xdr = {<<\xdo \xdM>>}
%%% *** %%% *** %%% *** %%% *** %%% *** %%% *** %%%
rootNote = f,

rootNoteExp = { \rootNote} 
rootNoteDouble = {<\rootNote' \rootNote>}
midiMajorChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \majorChord}
midiMinorChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \minorChord}
midiDominantSeventhChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \dominantSeventhChord}
midiDiminishedSeventhChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \diminishedSeventhChord}

screenMajorChord = {\rootNote' \majorChordLetter}
screenMinorChord = {\rootNote' \minorChordLetter}
screenDominantSeventhChord = {\rootNote' \dominantSeventhChordLetter}
screenDiminishedSeventhChord = {\rootNote' \diminishedSeventhChordLetter}

xfo = {\tag #'midiOut \rootNoteDouble 
      \tag #'screenOut \rootNoteExp }

xfM = {\tag #'midiOut \midiMajorChord 
       \tag #'screenOut \screenMajorChord }

xfm = {\tag #'midiOut \midiMinorChord
       \tag #'screenOut \screenMinorChord}

xfs = {\tag #'midiOut \midiDominantSeventhChord
       \tag #'screenOut \screenDominantSeventhChord}

xfd = {\tag #'midiOut \midiDiminishedSeventhChord
       \tag #'screenOut \screenDiminishedSeventhChord}

xfr = {<<\xfo \xfM>>}
%%% *** %%% *** %%% *** %%% *** %%% *** %%% *** %%%
rootNote = g,

rootNoteExp = { \rootNote} 
rootNoteDouble = {<\rootNote' \rootNote>}
midiMajorChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \majorChord}
midiMinorChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \minorChord}
midiDominantSeventhChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \dominantSeventhChord}
midiDiminishedSeventhChord = \chordmode {\transpose a #(car (event-chord-pitches rootNoteExp)) \diminishedSeventhChord}

screenMajorChord = {\rootNote' \majorChordLetter}
screenMinorChord = {\rootNote' \minorChordLetter}
screenDominantSeventhChord = {\rootNote' \dominantSeventhChordLetter}
screenDiminishedSeventhChord = {\rootNote' \diminishedSeventhChordLetter}

xgo = {\tag #'midiOut \rootNoteDouble 
      \tag #'screenOut \rootNoteExp }

xgM = {\tag #'midiOut \midiMajorChord 
       \tag #'screenOut \screenMajorChord }

xgm = {\tag #'midiOut \midiMinorChord
       \tag #'screenOut \screenMinorChord}

xgs = {\tag #'midiOut \midiDominantSeventhChord
       \tag #'screenOut \screenDominantSeventhChord}

xgd = {\tag #'midiOut \midiDiminishedSeventhChord
       \tag #'screenOut \screenDiminishedSeventhChord}

xgr = {<<\xgo \xgM>>}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to