[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AW: "Quote" Chord Track in another Staff
From: |
sir.teddy.the.first |
Subject: |
AW: "Quote" Chord Track in another Staff |
Date: |
Sat, 8 Feb 2020 14:18:19 +0100 |
If I've understood everything you said correctly, I should have now made all
the necessary changes:
%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.19.83"
quoteChord = #(define-music-function
(staffName music)
(string? ly:music?)
#{
\context ChordNames = #(string-append staffName "-chords")
\quoteDuring "chrds" {
\context Staff = $staffName { $music }
}
#}
)
chordTrack = \chordmode {
\repeat unfold 2 {
c1 d e f |
}
}
%% make 'chordTrack' quotable
\addQuote "chrds" { \chordTrack }
notes = \relative c' {
\repeat unfold 8 {
c4 d e f |
}
}
otherNotes = \relative c' {
c1 d e f g a \quoteChord "second" { b } c
}
\score {
<<
\new ChordNames \chordTrack
\new Staff \notes
%% initiate a ChordNames-context which may be filled form 'otherNotes'
\new ChordNames = "second-chords" { #(skip-of-length otherNotes) }
\new Staff = "second" \otherNotes
>>
}
%%%%%%%%%%%%%%%%%%%%%%%%%
Now I should not encounter any problems as long as I always name the ChordNames
corresponding the staff, "(name-of-the-staff)-chords".
Is there a way to store ' \quoteChord "second" ' in a variable so I only have
to define it once per staff?
That would shorten it even further.
> -----Ursprüngliche Nachricht-----
> Von: Thomas Morley <address@hidden>
> Gesendet: Samstag, 8. Februar 2020 13:42
> An: address@hidden
> Cc: lilypond-user <address@hidden>
> Betreff: Re: "Quote" Chord Track in another Staff
>
> Am Sa., 8. Feb. 2020 um 13:23 Uhr schrieb <address@hidden>:
> >
> > Hi,
> > thank you for this solution.
> > I only made a very small adjustment and now at least I would call it
> "elegant".
> > I put all the commands needed to "quote" from the chord track into a
> function, so now I only have to type one command instead of three.
> > I'm not versed enough in using Lilypond to know if this can be shortened
> even more or if there are some situations where it won't work at all, but I'm
> going to stick with it because it's still more elegant than what I used
> before.
> > Thank you.
>
> Glad I could help.
>
> Some remarks:
>
> >
> > %%%%%%%%%%%%%%%%%%%
> > \version "2.19.83"
> >
> > chordTrack = \chordmode {
> > \repeat unfold 2 {
> > c1 d e f |
> > }
> > }
> >
> > %% make 'chordTrack' quotable
> > \addQuote "chrds" { \chordTrack }
> >
> > notes = \relative c' {
> > \repeat unfold 8 {
> > c4 d e f |
> > }
> > }
> >
>
> This relies on matching context-names, so you have to care about them
> manually
>
> > quoteChord = #(define-music-function
>
> No need for 'parser location' in music-functions for 2.19.x, you could delete
> them
>
> > (parser location music)
> > (ly:music?)
> > #{
> > \context ChordNames = "chrds-2"
> > \quoteDuring "chrds" {
>
> I'd use $music instead, refer to the Extending manual for the difference.
> Although I doubt it makes a difference here, I'm used to be a paranoiac ...
>
> > \context Staff = "2" { #music }
> > }
> > #}
> > )
> >
> > otherNotes = \relative c' {
> > c1 d e f g a \quoteChord { b } c
> > }
> >
> > \score {
> > <<
> > \new ChordNames \chordTrack
> > \new Staff \notes
> > %% initiate a ChordNames-context which may be filled form 'otherNotes'
>
> Likely more robust to do:
> \new ChordNames = "chrds-2" { #(skip-of-length otherNotes) }
>
> > \new ChordNames = "chrds-2"
> > \new Staff = "2" \otherNotes
> > >>
> > }
> > %%%%%%%%%%%%%%%%%%%
>
> Cheers,
> Harm