Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ly/gridly/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
GridLY - Changelog
==================

* 0.5.1

- Add support for lyrics in `opening` and `closing`. See issue #113

* 0.5.0

- Add bar number handling. See issue #101
Expand Down
2 changes: 1 addition & 1 deletion ly/gridly/__init__.ily
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

%%% Initialization of the GridLY library

#(define gridly-version "0.5.0")
#(define gridly-version "0.5.1")

%%% The association list holding all the music.
#(if (not (defined? 'music-grid))
Expand Down
22 changes: 19 additions & 3 deletions ly/gridly/__main__.ily
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@
#:getter cell:lyrics)
(opening #:init-keyword #:opening
#:getter cell:opening)
(opening-lyrics #:init-keyword #:opening-lyrics
#:getter cell:opening-lyrics)
(closing #:init-keyword #:closing
#:getter cell:closing)
(closing-lyrics #:init-keyword #:closing-lyrics
#:getter cell:closing-lyrics)
(barNumber #:init-keyword #:barNumber
#:getter cell:barNumber)
(transposeKey #:init-keyword #:transposeKey
Expand Down Expand Up @@ -206,7 +210,9 @@ gridPutMusic =
#:music music
#:lyrics (props-get 'lyrics #f)
#:opening (props-get 'opening #{ #})
#:opening-lyrics (props-get 'opening-lyrics #f)
#:closing (props-get 'closing #{ #})
#:closing-lyrics (props-get 'closing-lyrics #f)
#:barNumber (props-get 'barNumber #f)
#:transposeKey (props-get 'transposeKey #f))))
(hash-set! music-grid key value)))
Expand Down Expand Up @@ -259,8 +265,10 @@ gridSetSegmentTemplate =
#:lyrics #{ #}
#:opening (cell:opening
(get-music-cell "<template>" i))
#:opening-lyrics #{ #}
#:closing (cell:closing
(get-music-cell "<template>" i))
#:closing-lyrics #{ #}
#:music (cell:music
(get-music-cell "<template>" i))
#:barNumber (cell:barNumber
Expand Down Expand Up @@ -326,12 +334,20 @@ gridGetLyrics =
#(define-music-function
(parser location part) (string?)
(let* ((cells (get-cell-range part #{ \getOption gridly.segment-range #}))
(lyrics (map cell:lyrics cells)))
(lyrics (map cell:lyrics cells))
(opening-lyrics (let ((maybe-lyrics (cell:opening-lyrics (car cells))))
(if maybe-lyrics
(list maybe-lyrics)
'())))
(closing-lyrics (let ((maybe-lyrics (cell:closing-lyrics (car (last-pair cells)))))
(if maybe-lyrics
(list maybe-lyrics)
'()))))
(if (member #f lyrics)
(ly:error "A segment is missing lyrics!")
(make-music
'SequentialMusic
'elements lyrics))))
'elements (append opening-lyrics lyrics closing-lyrics)))))

#(define (format-cell-file-name parser part segment)
(let* ((max-segment-str-len (string-length
Expand Down Expand Up @@ -364,7 +380,7 @@ gridCompileCell =
(lyrics (let ((maybe-lyrics (cell:lyrics
(get-music-cell part segment))))
(if maybe-lyrics
#{ \new Lyrics \lyricsto $name $maybe-lyrics #}
#{ \new Lyrics \lyricsto $name { \gridGetLyrics $part } #}
#{ #})))
(book
#{
Expand Down
52 changes: 52 additions & 0 deletions ly/gridly/usage-examples/opening-lyrics.ly
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
\version "2.18.2"

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%% Gridly example: opening lyrics
%%% ==============================
%%%
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% The usual includes and module loading
\include "openlilylib"
\loadModule "gridly"

%%% Initialize the grid: three segments for a single part
\gridInit 2 #'("voice")

%%% Fill the grid with music. In the `with` clause you can specify the
%%% opening, the closing and their lyrics
\gridPutMusic "voice" 1
\with {
closing = \relative c' { c }
lyrics = \lyricmode { This is a test }
}
\relative c' {
\key c \major
c e g c, ~ |
}

\gridPutMusic "voice" 2
\with {
opening = \relative c' { \partial 4 c4 ~ }
opening-lyrics = \lyricmode { test }
lyrics = \lyricmode { a simple test! }
}
\relative c' {
c d b c |
}

\gridCompileCell "voice" 1
\gridCompileCell "voice" 2

\gridSetRange #'all

\score {
<<
\new Voice = "test" { \gridGetMusic "voice" }
\new Lyrics \lyricsto "test" { \gridGetLyrics "voice" }
>>

\layout {}
}