[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can Lilypond be tweaked to make a really kid friendly notation like
From: |
Aaron Hill |
Subject: |
Re: Can Lilypond be tweaked to make a really kid friendly notation like this? |
Date: |
Tue, 10 Sep 2019 19:59:14 -0700 |
User-agent: |
Roundcube Webmail/1.3.8 |
On 2019-09-10 5:30 pm, Warren Wilkinson wrote:
Here is the sort of output I want to generate. The staff lines and
spaces
have been replaced by solid bands of color. The text is placed on the
line
itself and the text colors are based on the note.
My question is, can Lilypond be coerced into doing this? I'm a
professional
Lisp Programmer by trade, so I don't mind getting my hands too dirty.
It
would be nice if the coloring choices were automatic, but manual is
fine
too. Or would it be easier to just do this in Gimp?
(Image also available here:
https://www.bcclimate.ca/canlilyponddothis.png)
[image: canlilyponddothis.png]
Broadly, I would say, "yes." The background would be an override of the
StaffSymbol stencil, replacing the normal lines with stripes of color.
If the notes were simply hidden, you could then change the vertical
positioning of the lyric syllables to overlap with the staff aligning
where the notes would be.
Here is a very rough sketch of the approach:
%%%%
\version "2.19.83"
theNotes = \fixed c' { c8 c g g a a g4 }
theWords = \lyricmode { Twin -- kle, twin -- kle lit -- tle star }
custom-staff-symbol = #(grob-transformer 'stencil (lambda (grob orig)
(let* ((lc (ly:grob-property grob 'line-count))
(ss (ly:grob-property grob 'staff-space))
(xex (ly:stencil-extent orig X)))
(grob-interpret-markup grob #{
\markup \overlay {
$@(map (lambda (n)
(let* ((y1 (* (- n 0.5) (/ ss 2)))
(y2 (+ y1 (/ ss 2))))
#{ \markup
\with-color $(if (odd? n) yellow green)
\filled-box $xex $(cons y1 y2) #0 #} ))
(iota 8 -4)) } #} ))))
align-lyrics-to-notes = #(grob-transformer 'stencil (lambda (grob orig)
(let* ((nc (ly:grob-parent grob X))
(nh (first (ly:grob-array->list (ly:grob-object nc
'note-heads))))
(y (ly:grob-property nh 'Y-offset))
(ss (ly:staff-symbol-staff-space nh)))
(ly:stencil-translate orig (cons 0 (- y (/ ss 4)))))))
<<
\new Staff \with {
\omit Clef \omit TimeSignature
\omit BarLine \omit LedgerLineSpanner
middleCPosition = #-4
\override StaffSymbol.line-count = #1
\override StaffSymbol.staff-space = #4
\override StaffSymbol.stencil = #custom-staff-symbol
} \new Voice = "melody" \with {
\omit Stem \omit Beam \omit NoteHead
} { \theNotes }
\new Lyrics \with {
\override VerticalAxisGroup.nonstaff-relatedstaff-spacing =
#'((basic-distance . 0) (minimum-distance . 0)
(padding . -100) (stretchability . 0))
\override LyricText.stencil = #align-lyrics-to-notes
\omit LyricHyphen
} \lyricsto "melody" { \theWords } >>
%%%%
Far from what you want, but it should be a basic proof-of-concept.
-- Aaron Hill
kid-friendly.cropped.png
Description: PNG image