Automatic lyric colouring

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

Automatic lyric colouring

jmuzic
I'm trying to put together an engraver for educational purposes, with noteheads coloured according to a particular scheme, and lyrics following this colouring. 

I've used the snippet for notehead colouring successfully (http://lsr.di.unimi.it/LSR/Snippet?id=572), using "\override NoteHead.color = #color-notehead", but have no idea how to get the lyrics to follow the same colour scheme without changing each word individually. I took a punt but using "override LyricText.color = #color-notehead" didn't work. 

Anyone got any clues to whether my idea is possible and if so how? 

Thanks

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Automatic lyric colouring

Andrew Bernard
Hi Jack,

What do you mean exactly? The snippet colours noteheads according to their individual pitch. What if your word spans multiple pitches, what colour do you make it? This sounds somewhat illogical, or at the least confusing to read for a musician. Can you explain more?

Andrew


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Automatic lyric colouring

jmuzic
Take this song for example:


I would want all the d notes one colour, and their lyrics the same colour, and all the b notes and their lyrics a different colour.

This is for very young children learning the basics of what pitch means. They use coloured instruments such as bells, chime bars and boomwhackers. Melisma would have to be a special case.

On 27 November 2016 at 01:50, Andrew Bernard <[hidden email]> wrote:
Hi Jack,

What do you mean exactly? The snippet colours noteheads according to their individual pitch. What if your word spans multiple pitches, what colour do you make it? This sounds somewhat illogical, or at the least confusing to read for a musician. Can you explain more?

Andrew



_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Automatic lyric colouring

Andrew Bernard
Hi Jack,

So, in such simple music probably no melisma. I don't work with lyrics but you would have to write a Scheme function for the lyrics that computes the pitch of the associated note and figures out the corresponding colour. Is it worth the complexity for such simple works?

However, others may already have frameworks for such a function. We will see!

Andrew



_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Automatic lyric colouring

jmuzic
I worried that it might involve Scheme. I should certainly investigate it but I'm already extremely out of my depth! The material is simple but as I'm planning on compiling between 100-200 songs using up to 5 notes (for Kodaly/Orff-style music programmes), if the lyrics idea could work, I'd like to be able to do it.

Thanks for your input!

On 27 November 2016 at 02:11, Andrew Bernard <[hidden email]> wrote:
Hi Jack,

So, in such simple music probably no melisma. I don't work with lyrics but you would have to write a Scheme function for the lyrics that computes the pitch of the associated note and figures out the corresponding colour. Is it worth the complexity for such simple works?

However, others may already have frameworks for such a function. We will see!

Andrew




_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Automatic lyric colouring

Urs Liska
I *think* what is necessary here is an "engraver". This will process the stuff in a second run-through and can determine what happens in other contexts at the same time.

Probably too complicated if you're not already familiar with Scheme, but worth the effort for your use case, I think. There may be people on this list who can help with that.
Could become a useful snippet for LSR or openLilyLib.

Urs

Am 27. November 2016 03:20:10 MEZ, schrieb Jack Mackenzie <[hidden email]>:
I worried that it might involve Scheme. I should certainly investigate it but I'm already extremely out of my depth! The material is simple but as I'm planning on compiling between 100-200 songs using up to 5 notes (for Kodaly/Orff-style music programmes), if the lyrics idea could work, I'd like to be able to do it.

Thanks for your input!

On 27 November 2016 at 02:11, Andrew Bernard <[hidden email]> wrote:
Hi Jack,

So, in such simple music probably no melisma. I don't work with lyrics but you would have to write a Scheme function for the lyrics that computes the pitch of the associated note and figures out the corresponding colour. Is it worth the complexity for such simple works?

However, others may already have frameworks for such a function. We will see!

Andrew





lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Automatic lyric colouring

Joseph Chrestien

Just to pipe in, although no idea: very interesting question! Looking forward to an answer!
Jo'




On Sun, Nov 27, 2016 at 12:01 PM +0100, "Urs Liska" <[hidden email]> wrote:

I *think* what is necessary here is an "engraver". This will process the stuff in a second run-through and can determine what happens in other contexts at the same time.

Probably too complicated if you're not already familiar with Scheme, but worth the effort for your use case, I think. There may be people on this list who can help with that.
Could become a useful snippet for LSR or openLilyLib.

Urs

Am 27. November 2016 03:20:10 MEZ, schrieb Jack Mackenzie <[hidden email]>:
I worried that it might involve Scheme. I should certainly investigate it but I'm already extremely out of my depth! The material is simple but as I'm planning on compiling between 100-200 songs using up to 5 notes (for Kodaly/Orff-style music programmes), if the lyrics idea could work, I'd like to be able to do it.

Thanks for your input!

On 27 November 2016 at 02:11, Andrew Bernard <[hidden email]> wrote:
Hi Jack,

So, in such simple music probably no melisma. I don't work with lyrics but you would have to write a Scheme function for the lyrics that computes the pitch of the associated note and figures out the corresponding colour. Is it worth the complexity for such simple works?

However, others may already have frameworks for such a function. We will see!

Andrew





lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Automatic lyric colouring

Urs Liska
In reply to this post by Urs Liska



Am 27.11.2016 um 12:00 schrieb Urs Liska:
I *think* what is necessary here is an "engraver". This will process the stuff in a second run-through and can determine what happens in other contexts at the same time.

Probably too complicated if you're not already familiar with Scheme, but worth the effort for your use case, I think. There may be people on this list who can help with that.
Could become a useful snippet for LSR or openLilyLib.

One more thought: if that engraver runs over the lyrics (and not the music) there shouldn't be a real issue with melismas. If there's a lyric syllable there should be an associated note, and that can be looked into.

Urs


Urs

Am 27. November 2016 03:20:10 MEZ, schrieb Jack Mackenzie [hidden email]:
I worried that it might involve Scheme. I should certainly investigate it but I'm already extremely out of my depth! The material is simple but as I'm planning on compiling between 100-200 songs using up to 5 notes (for Kodaly/Orff-style music programmes), if the lyrics idea could work, I'd like to be able to do it.

Thanks for your input!

On 27 November 2016 at 02:11, Andrew Bernard <[hidden email]> wrote:
Hi Jack,

So, in such simple music probably no melisma. I don't work with lyrics but you would have to write a Scheme function for the lyrics that computes the pitch of the associated note and figures out the corresponding colour. Is it worth the complexity for such simple works?

However, others may already have frameworks for such a function. We will see!

Andrew




lilypond-user mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/lilypond-user
-- Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Automatic lyric colouring

Thomas Morley-2
In reply to this post by jmuzic
2016-11-27 2:40 GMT+01:00 Jack Mackenzie <[hidden email]>:

> I'm trying to put together an engraver for educational purposes, with
> noteheads coloured according to a particular scheme, and lyrics following
> this colouring.
>
> I've used the snippet for notehead colouring successfully
> (http://lsr.di.unimi.it/LSR/Snippet?id=572), using "\override NoteHead.color
> = #color-notehead", but have no idea how to get the lyrics to follow the
> same colour scheme without changing each word individually. I took a punt
> but using "override LyricText.color = #color-notehead" didn't work.
>
> Anyone got any clues to whether my idea is possible and if so how?
>
> Thanks


Hi Jack,

how about below?
Not an engraver, seems to work, tho'.

\version "2.18.2"

%Association list of pitches to colors.
#(define color-mapping
   (list
    (cons #{ c'   #} (x11-color 'red))
    (cons #{ cis' #} (x11-color 'green))
    (cons #{ des' #} (x11-color 'green))
    (cons #{ d'   #} (x11-color 'blue))
    (cons #{ dis' #} (x11-color 'cyan))
    (cons #{ e'   #} (x11-color 'red))
    (cons #{ eis' #} (x11-color 'green))
    (cons #{ fes' #} (x11-color 'red))
    (cons #{ f'   #} (x11-color 'green))
    (cons #{ fis' #} (x11-color 'blue))
    (cons #{ ges' #} (x11-color 'blue))
    (cons #{ gis' #} (x11-color 'red))
    (cons #{ aes' #} (x11-color 'red))
    (cons #{ a'   #} (x11-color 'green))
    (cons #{ ais' #} (x11-color 'blue))
    (cons #{ bes' #} (x11-color 'blue))
    (cons #{ bis' #} (x11-color 'red))))

%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
   (and
    (= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
    (= (ly:pitch-notename p1) (ly:pitch-notename p2))))

#(define (pitch-to-color pitch)
   (let ((color (assoc pitch color-mapping pitch-equals?)))
     (if color
         (cdr color)
         '())))

#(define (color-notehead grob)
  (let* ((pitch-color
           (pitch-to-color
             (ly:event-property (event-cause grob) 'pitch)))
         (pap-col-elts
           (ly:grob-object
             (ly:grob-parent
               (ly:grob-parent grob X)
               X)
             'elements))
         (elts-list
           (if (ly:grob-array? pap-col-elts)
               (ly:grob-array->list pap-col-elts)
               '()))
         (lyr-text
           (filter
             (lambda (g)
               (grob::has-interface g 'lyric-syllable-interface))
             elts-list)))
     (for-each
       (lambda (lyr)
         (ly:grob-set-property! lyr 'color pitch-color))
       lyr-text)
     (ly:grob-set-property! grob 'color pitch-color)))

\score {
  <<
    \new Voice = "voice"
      \relative c' {
      \override NoteHead.after-line-breaking = #color-notehead
      c8 b d dis ees f( g) aes
    }
    \new Lyrics \lyricsto "voice" { c b d dis ees f aes }
  >>
}


Cheers,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Automatic lyric colouring

jmuzic
Wonderful! Works perfectly. Thank you very much. 

On 27 November 2016 at 13:26, Thomas Morley <[hidden email]> wrote:
2016-11-27 2:40 GMT+01:00 Jack Mackenzie <[hidden email]>:
> I'm trying to put together an engraver for educational purposes, with
> noteheads coloured according to a particular scheme, and lyrics following
> this colouring.
>
> I've used the snippet for notehead colouring successfully
> (http://lsr.di.unimi.it/LSR/Snippet?id=572), using "\override NoteHead.color
> = #color-notehead", but have no idea how to get the lyrics to follow the
> same colour scheme without changing each word individually. I took a punt
> but using "override LyricText.color = #color-notehead" didn't work.
>
> Anyone got any clues to whether my idea is possible and if so how?
>
> Thanks


Hi Jack,

how about below?
Not an engraver, seems to work, tho'.

\version "2.18.2"

%Association list of pitches to colors.
#(define color-mapping
   (list
    (cons #{ c'   #} (x11-color 'red))
    (cons #{ cis' #} (x11-color 'green))
    (cons #{ des' #} (x11-color 'green))
    (cons #{ d'   #} (x11-color 'blue))
    (cons #{ dis' #} (x11-color 'cyan))
    (cons #{ e'   #} (x11-color 'red))
    (cons #{ eis' #} (x11-color 'green))
    (cons #{ fes' #} (x11-color 'red))
    (cons #{ f'   #} (x11-color 'green))
    (cons #{ fis' #} (x11-color 'blue))
    (cons #{ ges' #} (x11-color 'blue))
    (cons #{ gis' #} (x11-color 'red))
    (cons #{ aes' #} (x11-color 'red))
    (cons #{ a'   #} (x11-color 'green))
    (cons #{ ais' #} (x11-color 'blue))
    (cons #{ bes' #} (x11-color 'blue))
    (cons #{ bis' #} (x11-color 'red))))

%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
   (and
    (= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
    (= (ly:pitch-notename p1) (ly:pitch-notename p2))))

#(define (pitch-to-color pitch)
   (let ((color (assoc pitch color-mapping pitch-equals?)))
     (if color
         (cdr color)
         '())))

#(define (color-notehead grob)
  (let* ((pitch-color
           (pitch-to-color
             (ly:event-property (event-cause grob) 'pitch)))
         (pap-col-elts
           (ly:grob-object
             (ly:grob-parent
               (ly:grob-parent grob X)
               X)
             'elements))
         (elts-list
           (if (ly:grob-array? pap-col-elts)
               (ly:grob-array->list pap-col-elts)
               '()))
         (lyr-text
           (filter
             (lambda (g)
               (grob::has-interface g 'lyric-syllable-interface))
             elts-list)))
     (for-each
       (lambda (lyr)
         (ly:grob-set-property! lyr 'color pitch-color))
       lyr-text)
     (ly:grob-set-property! grob 'color pitch-color)))

\score {
  <<
    \new Voice = "voice"
      \relative c' {
      \override NoteHead.after-line-breaking = #color-notehead
      c8 b d dis ees f( g) aes
    }
    \new Lyrics \lyricsto "voice" { c b d dis ees f aes }
  >>
}


Cheers,
  Harm


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Automatic lyric colouring

jmuzic
I've been using this for a while now and sometimes the lyrics are randomly coloured black instead of being associated with the note colour. I've tried to find a pattern to it but there doesn't seem to be one. Anyone have any ideas?

On 27 November 2016 at 16:42, Jack Mackenzie <[hidden email]> wrote:
Wonderful! Works perfectly. Thank you very much. 

On 27 November 2016 at 13:26, Thomas Morley <[hidden email]> wrote:
2016-11-27 2:40 GMT+01:00 Jack Mackenzie <[hidden email]>:
> I'm trying to put together an engraver for educational purposes, with
> noteheads coloured according to a particular scheme, and lyrics following
> this colouring.
>
> I've used the snippet for notehead colouring successfully
> (http://lsr.di.unimi.it/LSR/Snippet?id=572), using "\override NoteHead.color
> = #color-notehead", but have no idea how to get the lyrics to follow the
> same colour scheme without changing each word individually. I took a punt
> but using "override LyricText.color = #color-notehead" didn't work.
>
> Anyone got any clues to whether my idea is possible and if so how?
>
> Thanks


Hi Jack,

how about below?
Not an engraver, seems to work, tho'.

\version "2.18.2"

%Association list of pitches to colors.
#(define color-mapping
   (list
    (cons #{ c'   #} (x11-color 'red))
    (cons #{ cis' #} (x11-color 'green))
    (cons #{ des' #} (x11-color 'green))
    (cons #{ d'   #} (x11-color 'blue))
    (cons #{ dis' #} (x11-color 'cyan))
    (cons #{ e'   #} (x11-color 'red))
    (cons #{ eis' #} (x11-color 'green))
    (cons #{ fes' #} (x11-color 'red))
    (cons #{ f'   #} (x11-color 'green))
    (cons #{ fis' #} (x11-color 'blue))
    (cons #{ ges' #} (x11-color 'blue))
    (cons #{ gis' #} (x11-color 'red))
    (cons #{ aes' #} (x11-color 'red))
    (cons #{ a'   #} (x11-color 'green))
    (cons #{ ais' #} (x11-color 'blue))
    (cons #{ bes' #} (x11-color 'blue))
    (cons #{ bis' #} (x11-color 'red))))

%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
   (and
    (= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
    (= (ly:pitch-notename p1) (ly:pitch-notename p2))))

#(define (pitch-to-color pitch)
   (let ((color (assoc pitch color-mapping pitch-equals?)))
     (if color
         (cdr color)
         '())))

#(define (color-notehead grob)
  (let* ((pitch-color
           (pitch-to-color
             (ly:event-property (event-cause grob) 'pitch)))
         (pap-col-elts
           (ly:grob-object
             (ly:grob-parent
               (ly:grob-parent grob X)
               X)
             'elements))
         (elts-list
           (if (ly:grob-array? pap-col-elts)
               (ly:grob-array->list pap-col-elts)
               '()))
         (lyr-text
           (filter
             (lambda (g)
               (grob::has-interface g 'lyric-syllable-interface))
             elts-list)))
     (for-each
       (lambda (lyr)
         (ly:grob-set-property! lyr 'color pitch-color))
       lyr-text)
     (ly:grob-set-property! grob 'color pitch-color)))

\score {
  <<
    \new Voice = "voice"
      \relative c' {
      \override NoteHead.after-line-breaking = #color-notehead
      c8 b d dis ees f( g) aes
    }
    \new Lyrics \lyricsto "voice" { c b d dis ees f aes }
  >>
}


Cheers,
  Harm



_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Automatic lyric colouring

Simon Albrecht-2
On 11.12.2016 17:39, Jack Mackenzie wrote:
> Anyone have any ideas?

Certainly not without an example.
Best, Simon

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user