Skip to content

Commit 75adb41

Browse files
committed
Merge remote-tracking branch 'origin/gridly/opening-lyrics'
2 parents ac60496 + 5c609a4 commit 75adb41

File tree

4 files changed

+76
-4
lines changed

4 files changed

+76
-4
lines changed

ly/gridly/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
GridLY - Changelog
22
==================
33

4+
* 0.5.1
5+
6+
- Add support for lyrics in `opening` and `closing`. See issue #113
7+
48
* 0.5.0
59

610
- Add bar number handling. See issue #101

ly/gridly/__init__.ily

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
%%% Initialization of the GridLY library
2121

22-
#(define gridly-version "0.5.0")
22+
#(define gridly-version "0.5.1")
2323

2424
%%% The association list holding all the music.
2525
#(if (not (defined? 'music-grid))

ly/gridly/__main__.ily

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@
3939
#:getter cell:lyrics)
4040
(opening #:init-keyword #:opening
4141
#:getter cell:opening)
42+
(opening-lyrics #:init-keyword #:opening-lyrics
43+
#:getter cell:opening-lyrics)
4244
(closing #:init-keyword #:closing
4345
#:getter cell:closing)
46+
(closing-lyrics #:init-keyword #:closing-lyrics
47+
#:getter cell:closing-lyrics)
4448
(barNumber #:init-keyword #:barNumber
4549
#:getter cell:barNumber)
4650
(transposeKey #:init-keyword #:transposeKey
@@ -206,7 +210,9 @@ gridPutMusic =
206210
#:music music
207211
#:lyrics (props-get 'lyrics #f)
208212
#:opening (props-get 'opening #{ #})
213+
#:opening-lyrics (props-get 'opening-lyrics #f)
209214
#:closing (props-get 'closing #{ #})
215+
#:closing-lyrics (props-get 'closing-lyrics #f)
210216
#:barNumber (props-get 'barNumber #f)
211217
#:transposeKey (props-get 'transposeKey #f))))
212218
(hash-set! music-grid key value)))
@@ -259,8 +265,10 @@ gridSetSegmentTemplate =
259265
#:lyrics #{ #}
260266
#:opening (cell:opening
261267
(get-music-cell "<template>" i))
268+
#:opening-lyrics #{ #}
262269
#:closing (cell:closing
263270
(get-music-cell "<template>" i))
271+
#:closing-lyrics #{ #}
264272
#:music (cell:music
265273
(get-music-cell "<template>" i))
266274
#:barNumber (cell:barNumber
@@ -326,12 +334,20 @@ gridGetLyrics =
326334
#(define-music-function
327335
(parser location part) (string?)
328336
(let* ((cells (get-cell-range part #{ \getOption gridly.segment-range #}))
329-
(lyrics (map cell:lyrics cells)))
337+
(lyrics (map cell:lyrics cells))
338+
(opening-lyrics (let ((maybe-lyrics (cell:opening-lyrics (car cells))))
339+
(if maybe-lyrics
340+
(list maybe-lyrics)
341+
'())))
342+
(closing-lyrics (let ((maybe-lyrics (cell:closing-lyrics (car (last-pair cells)))))
343+
(if maybe-lyrics
344+
(list maybe-lyrics)
345+
'()))))
330346
(if (member #f lyrics)
331347
(ly:error "A segment is missing lyrics!")
332348
(make-music
333349
'SequentialMusic
334-
'elements lyrics))))
350+
'elements (append opening-lyrics lyrics closing-lyrics)))))
335351

336352
#(define (format-cell-file-name parser part segment)
337353
(let* ((max-segment-str-len (string-length
@@ -364,7 +380,7 @@ gridCompileCell =
364380
(lyrics (let ((maybe-lyrics (cell:lyrics
365381
(get-music-cell part segment))))
366382
(if maybe-lyrics
367-
#{ \new Lyrics \lyricsto $name $maybe-lyrics #}
383+
#{ \new Lyrics \lyricsto $name { \gridGetLyrics $part } #}
368384
#{ #})))
369385
(book
370386
#{
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
\version "2.18.2"
2+
3+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4+
%%%
5+
%%% Gridly example: opening lyrics
6+
%%% ==============================
7+
%%%
8+
%%%
9+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10+
11+
%%% The usual includes and module loading
12+
\include "openlilylib"
13+
\loadModule "gridly"
14+
15+
%%% Initialize the grid: three segments for a single part
16+
\gridInit 2 #'("voice")
17+
18+
%%% Fill the grid with music. In the `with` clause you can specify the
19+
%%% opening, the closing and their lyrics
20+
\gridPutMusic "voice" 1
21+
\with {
22+
closing = \relative c' { c }
23+
lyrics = \lyricmode { This is a test }
24+
}
25+
\relative c' {
26+
\key c \major
27+
c e g c, ~ |
28+
}
29+
30+
\gridPutMusic "voice" 2
31+
\with {
32+
opening = \relative c' { \partial 4 c4 ~ }
33+
opening-lyrics = \lyricmode { test }
34+
lyrics = \lyricmode { a simple test! }
35+
}
36+
\relative c' {
37+
c d b c |
38+
}
39+
40+
\gridCompileCell "voice" 1
41+
\gridCompileCell "voice" 2
42+
43+
\gridSetRange #'all
44+
45+
\score {
46+
<<
47+
\new Voice = "test" { \gridGetMusic "voice" }
48+
\new Lyrics \lyricsto "test" { \gridGetLyrics "voice" }
49+
>>
50+
51+
\layout {}
52+
}

0 commit comments

Comments
 (0)