"Quote" Chord Track in another Staff

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

"Quote" Chord Track in another Staff

sir.teddy.the.first

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

Reply | Threaded
Open this post in threaded view
|

Re: "Quote" Chord Track in another Staff

Thomas Morley-2
Am Sa., 8. Feb. 2020 um 12:42 Uhr schrieb <[hidden email]>:

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

Reply | Threaded
Open this post in threaded view
|

AW: "Quote" Chord Track in another Staff

sir.teddy.the.first
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.

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

quoteChord = #(define-music-function
    (parser location music)
    (ly:music?)
    #{
      \context ChordNames = "chrds-2"
        \quoteDuring "chrds" {
          \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'
  \new ChordNames = "chrds-2"
  \new Staff = "2" \otherNotes
  >>
}
%%%%%%%%%%%%%%%%%%%


> -----Ursprüngliche Nachricht-----
> Von: Thomas Morley <[hidden email]>
> Gesendet: Samstag, 8. Februar 2020 13:02
> An: [hidden email]
> Cc: lilypond-user <[hidden email]>
> Betreff: Re: "Quote" Chord Track in another Staff
>
> Am Sa., 8. Feb. 2020 um 12:42 Uhr schrieb <[hidden email]>:
> >
> > 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


Reply | Threaded
Open this post in threaded view
|

Re: "Quote" Chord Track in another Staff

Thomas Morley-2
Am Sa., 8. Feb. 2020 um 13:23 Uhr schrieb <[hidden email]>:
>
> 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

Reply | Threaded
Open this post in threaded view
|

Re: "Quote" Chord Track in another Staff

David Kastrup
Thomas Morley <[hidden email]> 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".

Reply | Threaded
Open this post in threaded view
|

AW: "Quote" Chord Track in another Staff

sir.teddy.the.first
In reply to this post by Thomas Morley-2
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 <[hidden email]>
> Gesendet: Samstag, 8. Februar 2020 13:42
> An: [hidden email]
> Cc: lilypond-user <[hidden email]>
> Betreff: Re: "Quote" Chord Track in another Staff
>
> Am Sa., 8. Feb. 2020 um 13:23 Uhr schrieb <[hidden email]>:
> >
> > 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


Reply | Threaded
Open this post in threaded view
|

Re: "Quote" Chord Track in another Staff

Thomas Morley-2
Am Sa., 8. Feb. 2020 um 14:18 Uhr schrieb <[hidden email]>:
>
> 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

Reply | Threaded
Open this post in threaded view
|

AW: "Quote" Chord Track in another Staff

sir.teddy.the.first
Yes, thank you.
I tried to do it that way but I always forget the "\etc" so I got an error message.

> -----Ursprüngliche Nachricht-----
> Von: Thomas Morley <[hidden email]>
> Gesendet: Samstag, 8. Februar 2020 14:30
> An: [hidden email]
> Cc: lilypond-user <[hidden email]>
> Betreff: Re: "Quote" Chord Track in another Staff
>
> Am Sa., 8. Feb. 2020 um 14:18 Uhr schrieb <[hidden email]>:
> >
> > 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