Skip to content

Commit 558afa4

Browse files
committedFeb 17, 2024·
feat: first version of lyscaffold
Signed-off-by: Davide Madrisan <d.madrisan@proton.me>
1 parent ed314b5 commit 558afa4

18 files changed

+504
-260
lines changed
 

‎Makefile.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
AM_MAKEFLAGS = --no-print-directory
1919

20-
SUBDIRS = src \
21-
template
20+
SUBDIRS = lyinit \
21+
src
2222

2323
check-local: all

‎configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ test -n "$critic_missing" && AC_MSG_ERROR([
6969

7070
AC_CONFIG_FILES([\
7171
Makefile \
72+
lyinit/Makefile \
7273
src/Makefile \
7374
src/alfredo-casella/Makefile \
7475
src/alfredo-casella/deux-contrastes-op.31/Makefile \
@@ -141,7 +142,6 @@ AC_CONFIG_FILES([\
141142
src/robert-schumann/Makefile \
142143
src/rued-langgaard/Makefile \
143144
src/rued-langgaard/insektarium-BVN134/Makefile \
144-
template/Makefile
145145
])
146146

147147
AC_OUTPUT

‎template/Makefile.am ‎lyinit/Makefile.am

+13-5
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,18 @@
1717

1818
AM_MAKEFLAGS = --no-print-directory
1919

20-
EXTRA_DIST = covercolor.ly.in \
21-
global.ly \
22-
logo.ly \
23-
template.ly \
24-
translate.sh
20+
EXTRA_DIST = lyscaffold.sh \
21+
addons/translate.sh \
22+
data/jsbach \
23+
templates/covercolor.ly \
24+
templates/covercolor.ly.in \
25+
templates/global.ly \
26+
templates/header.ily \
27+
templates/logo.ly \
28+
templates/makefile-clean \
29+
templates/makefile-clean-parts \
30+
templates/makefile-head \
31+
templates/mainfile.ly \
32+
templates/part-four-voices.ly
2533

2634
check-local: all
File renamed without changes.

‎lyinit/data/jsbach

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
composer_firstname='Johann Sebastian'
2+
composer_lastname="Bach"
3+
instruments="For Piano or Harpsichord"
4+
header_composer="Johann Sebastian Bach (1685-1750)"
5+
header_style="Baroque"
6+
mutopiacomposer="BachJS"
7+
mutopiainstrument="Harpsichord, Piano"

‎lyinit/lyscaffold.sh

+214
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
#!/usr/bin/env bash
2+
# A simple scaffolding script for Lilypond partitions.
3+
# Copyright (c) 2024 Davide Madrisan <d.madrisan@proton.me>
4+
5+
PROGNAME="${0##*/}"
6+
PROGPATH="${0%/*}"
7+
REVISION=1
8+
9+
die () { echo -e "$PROGNAME: error: $1" 1>&2; exit 1; }
10+
11+
usage () {
12+
cat <<__EOF
13+
Usage: $PROGNAME -t <targetdir> [-p]
14+
$PROGNAME --help
15+
$PROGNAME --version
16+
17+
Where:
18+
-c|--composer : the data file for the composer
19+
-d|--targetdir : the directory where to create the partition
20+
-n|--pdfname : the name of the file containing the partition
21+
-o|--opus : opus of the composition
22+
-p|--parts : the partition is splitted into several files
23+
-s|--source : the source of the partition
24+
-t|--title : title of the composition
25+
-y|--year : the date of the composition
26+
|--part4 : 4-voice part to be added to ./parts folder
27+
28+
Example:
29+
$0 -c $PROGPATH/data/jsbach \\
30+
--targetdir src/johann-sebastian-bach/partitas/BWV825 \\
31+
--opus 'BWV 825' \\
32+
--parts \\
33+
--title 'Partita I' \\
34+
--pdfname JS-Bach-BWV830-Partita-1.pdf \\
35+
--source 'Muzgiz, Moscow' \\
36+
--year "between 1725 and 1726" \\
37+
--part4 bach-partita-1-1-praeludium.ly \\
38+
--part4 bach-partita-1-2-allemande.ly \\
39+
--part4 bach-partita-1-3-corrente.ly \\
40+
--part4 bach-partita-1-4-sarabande.ly \\
41+
--part4 bach-partita-1-5-menuet-1.ly \\
42+
--part4 bach-partita-1-5-menuet-2.ly \\
43+
--part4 bach-partita-1-6-giga.ly
44+
45+
__EOF
46+
}
47+
48+
help () {
49+
cat <<__EOF
50+
$PROGNAME v$REVISION - a simple scaffolding script for Lilypond partitions
51+
Copyright (C) 2024 Davide Madrisan <d.madrisan@proton.me>
52+
53+
__EOF
54+
55+
usage
56+
}
57+
58+
lilypond_version () {
59+
( set -- $(lilypond --version 2>/dev/null | head -n 1); echo "$3"; )
60+
}
61+
62+
ly_opus="Unset --opus"
63+
ly_title="Unset --title"
64+
65+
ly_parts="false"
66+
67+
ly_sed () {
68+
[ -n "$1" -a ! -r "$1" ] && die "ly_sed: cannot read input file: $1"
69+
(
70+
. "$ly_data"
71+
# footer = "Mutopia-2023/04/15"
72+
header_footer="$(date +'%Y/%m/%d')"
73+
# lastupdated = "2023 April 15"
74+
header_lastupdate="$(date +'%Y %B %d')"
75+
76+
sed "s^@composer_firstname@^${composer_firstname}^g;
77+
s^@composer_lastname@^${composer_lastname}^g;
78+
s^@COMPOSER_LASTNAME@^${composer_lastname^^}^g;
79+
s^@header_composer@^${header_composer}^;
80+
s^@header_date@^${header_date}^;
81+
s^@header_footer@^${header_footer}^;
82+
s^@header_lastupdate@^${header_lastupdate}^;
83+
s^@header_style@^${header_style}^;
84+
s^@instruments@^${instruments}^;
85+
s^@mutopiacomposer@^${mutopiacomposer}^;
86+
s^@mutopiainstrument@^${mutopiainstrument}^;
87+
s^@opus@^${ly_opus}^g;
88+
s^@source@^${ly_source}^g;
89+
s^@title@^${ly_title}^g;
90+
" < "${1:-/dev/stdin}"
91+
)
92+
}
93+
94+
ly_parts4_files=()
95+
96+
while test -n "$1"; do
97+
case "$1" in
98+
--help|-h) help; exit 0 ;;
99+
--version|-V)
100+
echo "$PROGNAME v$REVISION"
101+
exit 0 ;;
102+
--composer|-c)
103+
ly_data="$2"; shift ;;
104+
--opus|-o)
105+
ly_opus="$2"; shift ;;
106+
--parts|-p)
107+
ly_parts="true" ;;
108+
--part4)
109+
ly_parts4_files+=("$2"); shift ;;
110+
--pdfname|-n)
111+
ly_pdfname="$2"; shift ;;
112+
--source|-s)
113+
ly_source="$2"; shift ;;
114+
--targetdir|-d)
115+
ly_targetdir="$2"; shift ;;
116+
--title|-t)
117+
ly_title="$2"; shift ;;
118+
--year|-y)
119+
ly_date="$2"; shift ;;
120+
--*|-*) die "unknown argument: $1" ;;
121+
*) die "unknown option: $1" ;;
122+
esac
123+
shift
124+
done
125+
126+
[ "$ly_data" ] || die "you must set a --composer"
127+
[ "$ly_date" ] || die "you must set a --year"
128+
[ "$ly_pdfname" ] || die "you must set a --pdfname"
129+
[ "$ly_source" ] || die "you must set a --source"
130+
[ "$ly_targetdir" ] || die "you must set a --targetdir"
131+
132+
[ -r "$ly_data" ] || die "file not found: $ly_data"
133+
134+
# remove the .pdf suffix if any
135+
ly_mainfile="${ly_pdfname%\.pdf}"
136+
137+
LY_STATIC_FILES="\
138+
covercolor.ly
139+
covercolor.ly.in
140+
global.ly
141+
logo.ly"
142+
143+
ly_version="$(lilypond_version)"
144+
[ "$ly_version" ] || die "cannot get the Lilyond version"
145+
echo "found Lilypond version $ly_version"
146+
147+
echo "creating the target folder '$ly_targetdir' ..."
148+
mkdir -p "$ly_targetdir"
149+
[ "$ly_parts" = "true" ] && mkdir -p "$ly_targetdir/parts"
150+
151+
echo "copying common files ..."
152+
for f in $LY_STATIC_FILES; do
153+
cp -v $PROGPATH/templates/$f "$ly_targetdir"
154+
done
155+
156+
echo "creating '$ly_targetdir/header.ily' ..."
157+
(
158+
ly_sed < $PROGPATH/templates/header.ily
159+
) > "$ly_targetdir/header.ily"
160+
161+
echo "creating '$ly_targetdir/${ly_mainfile}.ly'"
162+
(
163+
echo "\\version \"$ly_version\""
164+
echo
165+
ly_sed < $PROGPATH/templates/mainfile.ly
166+
) > "$ly_targetdir/${ly_mainfile}.ly"
167+
168+
echo "creating the makefile '$ly_targetdir/Makefile.am' ..."
169+
(
170+
cat $PROGPATH/templates/makefile-head
171+
echo
172+
echo "EXTRA_DIST = ${ly_mainfile}.ly \\"
173+
174+
set -- $LY_COMMON_FILES
175+
while test -n "$1"; do
176+
[ "$f" = "covercolor.ly" ] && { shift; continue; }
177+
echo -en "\t $1"
178+
[ "$2" ] && echo " \\" || echo ""
179+
shift
180+
done
181+
182+
echo
183+
echo "all: \$(BUILT_SOURCES) $ly_mainfile"
184+
185+
echo
186+
if [ "$ly_parts" = "true" ]; then
187+
cat $PROGPATH/templates/makefile-clean-parts
188+
else
189+
cat $PROGPATH/templates/makefile-clean
190+
fi
191+
) > "$ly_targetdir/Makefile.am"
192+
193+
for p in ${ly_parts4_files[@]}; do
194+
if [ -s "$ly_targetdir/parts/$p" ]; then
195+
echo "WARNING: skip non empty file: $ly_targetdir/parts/$p"
196+
else
197+
echo "creating $ly_targetdir/parts/$p ..."
198+
( ly_sed < $PROGPATH/templates/part-four-voices.ly ) \
199+
> "$ly_targetdir/parts/$p"
200+
fi
201+
echo "updating $ly_targetdir/${ly_mainfile}.ly"
202+
echo "\\include \"./parts/$p\"" >> $ly_targetdir/${ly_mainfile}.ly
203+
done
204+
205+
echo "
206+
+ new project structure"
207+
tree "$ly_targetdir"
208+
209+
echo "
210+
WARNING: make sure to update
211+
* configure.ac
212+
* the files Makefile.am in $ly_targetdir
213+
* 'date' and 'source' in $ly_targetdir/header.ily
214+
"
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎lyinit/templates/header.ily

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
\header {
2+
composer = "@header_composer@"
3+
date = "@header_date@"
4+
5+
footer = "Mutopia-@header_footer@"
6+
7+
lastupdated = "@header_lastupdate@"
8+
license = "Creative Commons Attribution-ShareAlike 4.0"
9+
maintainerEmail = "d.madrisan@proton.me"
10+
maintainerWeb = "https://github.com/madrisan/open-scores"
11+
12+
% Extra Mutopia Information
13+
mutopiacomposer = "@mutopiacomposer@"
14+
mutopiacopyright = "Creative Commons Attribution-ShareAlike 4.0"
15+
mutopiainstrument = "@mutopiainstrument@"
16+
mutopiamaintainer = "Davide Madrisan"
17+
mutopiaopus = "@opus@"
18+
mutopiatitle = "@title@"
19+
20+
opus = "@opus@"
21+
title = "@title@"
22+
source = "@source@"
23+
style = "@header_style@"
24+
25+
copyright = \markup {
26+
\override #'(font-name . "DejaVu Sans, Bold")
27+
\override #'(baseline-skip . 0)
28+
\right-column {
29+
\with-url #"http://www.MutopiaProject.org" {
30+
\abs-fontsize #9 "Mutopia "
31+
\concat {
32+
\abs-fontsize #12
33+
\with-color \coverColor "ǀ"
34+
\abs-fontsize #9 "Project "
35+
}
36+
}
37+
}
38+
\override #'(font-name . "DejaVu Sans, Bold")
39+
\override #'(baseline-skip . 0 )
40+
\center-column {
41+
\abs-fontsize #11.9
42+
\with-color #grey
43+
\bold { "ǀ" "ǀ" }
44+
}
45+
\override #'(font-name . "DejaVu Sans,sans-serif")
46+
\override #'(baseline-skip . 0)
47+
\column {
48+
\abs-fontsize #8
49+
\concat {
50+
"Typeset using " \with-url #"http://www.lilypond.org" "LilyPond " ©" 2022-2024 ""by " \maintainer "" \footer
51+
}
52+
\concat {
53+
\concat {
54+
\abs-fontsize #8 {
55+
\with-url #"http://creativecommons.org/licenses/by-sa/40/"
56+
"Creative Commons Attribution ShareAlike 4.0 International License"
57+
" — free to distribute, modify, and perform"
58+
}
59+
}
60+
\abs-fontsize #13 \with-color \coverColor "ǀ"
61+
}
62+
}
63+
}
64+
tagline = ##f
65+
}
File renamed without changes.

‎lyinit/templates/mainfile.ly

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#(ly:set-option 'relative-includes #t)
2+
3+
\include "./covercolor.ly"
4+
5+
\header {
6+
tagline = ##f
7+
}
8+
9+
\paper {
10+
#(set-paper-size "a4")
11+
annotate-spacing = ##f
12+
binding-offset = 0\mm
13+
bottom-margin = 5\mm
14+
first-page-number = 0
15+
indent = 0.0
16+
inner-margin = 10\mm
17+
% last-bottom-spacing.padding = #2
18+
left-margin = 10\mm
19+
line-width = 18.4\cm
20+
markup-system-spacing =
21+
#'((basic-distance . 2)
22+
(minimum-distance . 1)
23+
(padding . 2)
24+
(stretchability . 24))
25+
outer-margin = 20\mm
26+
print-all-headers = ##t
27+
ragged-last-bottom = ##f
28+
ragged-bottom = ##f
29+
right-margin = 10\mm
30+
system-system-spacing =
31+
#'((basic-distance . 2)
32+
(minimum-distance . 1)
33+
(padding . 2)
34+
(stretchability . 24))
35+
top-margin = 10\mm
36+
top-markup-spacing.basic-distance = 0
37+
top-system-spacing.basic-distance = 1
38+
}
39+
40+
\bookpart {
41+
\header {
42+
maintainer = "Davide Madrisan"
43+
maintainerEmail = "d.madrisan@proton.me"
44+
}
45+
46+
\include "./header.ily"
47+
\header {
48+
title = ##f
49+
composer = ##f
50+
}
51+
52+
\markup {
53+
\with-dimensions #'(0 . 0) #'(0 . 0)
54+
\with-color \coverColor
55+
\filled-box #'(-200 . 200) #'(-200 . 200) #0
56+
}
57+
\markup {
58+
\fill-line {
59+
\center-column {
60+
\null\null\null\null
61+
\null\null\null\null
62+
\line { \abs-fontsize #30 \bold "@composer_firstname@" }
63+
\null
64+
\line { \abs-fontsize #80 \bold "@composer_lastname@" }
65+
\null
66+
\fill-line { \draw-hline }
67+
\null\null\null
68+
\line { \abs-fontsize #40 \bold "@title@" }
69+
\null\null
70+
\line { \abs-fontsize #20 "@opus@" }
71+
\null\null\null
72+
\null\null\null
73+
\fill-line { \abs-fontsize #20 "For Piano or Harpsichord" }
74+
\null\null\null
75+
\null\null\null
76+
}
77+
}
78+
}
79+
80+
\include "./logo.ly"
81+
82+
\markup {
83+
\fill-line {
84+
\center-column {
85+
\null\null\null\null
86+
\fill-line {
87+
\abs-fontsize #10 "Based on: @source@"
88+
}
89+
\null\null
90+
}
91+
}
92+
}
93+
}
94+

‎lyinit/templates/makefile-clean

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
clean-local:
2+
-rm -f $(BUILT_SOURCES)
3+
-rm -f *.midi
4+
-rm -f *.pdf

‎lyinit/templates/makefile-clean-parts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
clean-local:
2+
-rm -f $(BUILT_SOURCES)
3+
-rm -f *.midi parts/*.midi
4+
-rm -f *.pdf parts/*.pdf

‎lyinit/templates/makefile-head

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## the Free Software Foundation, either version 3 of the License, or
2+
## (at your option) any later version.
3+
##
4+
## This program is distributed in the hope that it will be useful,
5+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
6+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7+
## GNU General Public License for more details.
8+
##
9+
## You should have received a copy of the GNU General Public License
10+
## along with this program. If not, see <http://www.gnu.org/licenses/>.
11+
12+
SUFFIXES = .in
13+
.in:; @echo "Generating $@...";\
14+
sed "s,@rgb_color@,$(RGB_COLOR),g;" \
15+
$< > $@
16+
17+
%: %.ly
18+
$(LILYPOND) --pdf --output $@ $<
19+
20+
BUILT_SOURCES = covercolor.ly

‎lyinit/templates/part-four-voices.ly

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
Global = {
2+
\key c \major
3+
\time 4/4
4+
\include "../global.ly"
5+
}
6+
7+
staffLower = { \change Staff = "lower" }
8+
staffUpper = { \change Staff = "upper" }
9+
10+
Soprano = \context Voice = "one" \relative c' {
11+
\voiceOne
12+
\stemNeutral
13+
\override MultiMeasureRest.staff-position = #0
14+
\override Rest.staff-position = #0
15+
%1
16+
| R1
17+
\fine
18+
}
19+
20+
Alto = \context Voice = "two" \relative c' {
21+
\voiceTwo
22+
\stemDown
23+
\override Rest.staff-position = #0
24+
%1
25+
}
26+
27+
Tenor = \context Voice = "three" \relative c {
28+
\voiceThree
29+
\stemUp
30+
\override Rest.staff-position = #0
31+
%1
32+
}
33+
34+
Bass = \context Voice = "four" \relative c {
35+
\voiceFour
36+
\stemDown\tieNeutral
37+
\override MultiMeasureRest.staff-position = #0
38+
\override Rest.staff-position = #0
39+
%1
40+
| R1
41+
\fine
42+
}
43+
44+
\score {
45+
\new PianoStaff
46+
<<
47+
\accidentalStyle Score.piano
48+
\context Staff = "upper" <<
49+
\set Staff.midiInstrument = #"acoustic grand"
50+
\Global
51+
\clef treble
52+
\Soprano
53+
\Alto
54+
>>
55+
\context Staff = "lower" <<
56+
\set Staff.midiInstrument = #"acoustic grand"
57+
\Global
58+
\clef bass
59+
\Tenor
60+
\Bass
61+
>>
62+
>>
63+
\header {
64+
composer = ##f # "@composer_firstname@ @composer_lastnam@"
65+
opus = ##f # "@opus@"
66+
title = \markup { "MISSING TITLE" }
67+
subtitle = ##f
68+
}
69+
\layout {
70+
\context {
71+
\PianoStaff
72+
\override Parentheses.font-size = #-2
73+
\override TextScript.font-shape = #'italic
74+
\override TextScript.font-size = #-1
75+
}
76+
}
77+
\midi {
78+
\tempo 4 = 100
79+
}
80+
}

‎template/header.ily

Whitespace-only changes.

‎template/template.ly

-252
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.