Re: "Quote" Chord Track in another Staff

2020-02-08 Thread Thomas Morley
Am Sa., 8. Feb. 2020 um 14:18 Uhr schrieb :
>
> If I've understood everything you said correctly, I should have now made all 
> the necessary changes:

Well, not all changes were _necessary_, p.e. using 'parser location'
in music-functions still works. Superfluous, though.

>
> %
> \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 }
> }
> #}
> )

You could do
quoteChordSecond = \quoteChord "second" \etc

>
> 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' {

Then here:
  c1 d e f g a \quoteChordSecond { b } 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.

Cheers,
  Harm



Re: "Quote" Chord Track in another Staff

2020-02-08 Thread David Kastrup
Thomas Morley  writes:

> 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 }
>> }
>> #}
>> )

# is pass-through, $ creates a copy.  Music that is used exactly once is
fine to pass through.

-- 
David Kastrup
My replies have a tendency to cause friction.  To help mitigating
damage, feel free to forward problematic posts to me adding a subject
like "timeout 1d" (for a suggested timeout of 1 day) or "offensive".



Re: "Quote" Chord Track in another Staff

2020-02-08 Thread Thomas Morley
Am Sa., 8. Feb. 2020 um 13:23 Uhr schrieb :
>
> 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



Re: "Quote" Chord Track in another Staff

2020-02-08 Thread Thomas Morley
Am Sa., 8. Feb. 2020 um 12:42 Uhr schrieb :
>
> Hi all,
>
> please consider the following snippet:
>
>
>
> %
>
> \version "2.19.83"
>
>
>
> notes = \relative c' {
>
>   \repeat unfold 8 {
>
> c4 d e f |
>
>   }
>
> }
>
>
>
> otherNotes = \relative c' {
>
>   c1 d e f g^\markup "C" a^\markup "D" b c
>
> }
>
>
>
> chordTrack = \chordmode {
>
>   \repeat unfold 2 {
>
> c1 d e f |
>
>   }
>
> }
>
>
>
> \score {
>
>   <<
>
>   \new ChordNames \chordTrack
>
>   \new Staff \notes
>
>   \new Staff \otherNotes
>
>   >>
>
> }
>
> %
>
>
>
> I’ve got the normal chords at the top and I would like to have parts of that 
> chord-track again over the second staff (simulated with the two 
> markup-commands).
>
> Of course I could just use a second variable containing only the chords I 
> want and leaving the rest blank, but I’m curious if there is a way to re-use 
> the first chords.
>
> How can this be done in a more “elegant” way?
>
>
>
> Thanks in advance

Hi,

you could try (ee inline comments):

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
  %% refer to the preexisting and named ChordNames-context, to put in the quotes
  \context ChordNames = "chrds-2"
\quoteDuring "chrds" {
  %% while putting quotes into the relevant ChordNames-context, refer to
  %% the preexisting and named Staff-context to continue entering "normal"
  %% stuff
  \context Staff = "2" { g1 a }
}
  b c
}

\score {
  <<
  \new ChordNames \chordTrack
  \new Staff \notes
  %% initiate a ChordNames-context which may be filled form 'otherNotes'
  \new ChordNames = "chrds-2"
  \new Staff = "2" \otherNotes
  >>
}

Not sure, if someone would call it "elegent" ...


Cheers,
  Harm