update to new lyluatex version

This commit is contained in:
Sebastian Hugentobler 2020-07-16 14:31:51 +02:00
parent 730d9fb22d
commit 2771f1c76f
62 changed files with 1704 additions and 771 deletions

3
.gitignore vendored
View File

@ -1,6 +1,7 @@
*~
out/
pdf/
build/
tmp/
midi/
music/
.DS_Store

8
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,8 @@
build:
image: thallian/latex-builder
script:
- make
artifacts:
paths:
- build/*
expire_in: 1 week

152
Makefile
View File

@ -1,101 +1,101 @@
SHELL = /bin/sh
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
WORKING_DIR := $(patsubst %/,%,$(dir $(mkfile_path)))
BOOKNAME=singalongs
SRC_DIR=src
BUILD_DIR=build
TMP_DIR=tmp
SONG_DIR=${SRC_DIR}/songs
BUILD_BOOK_DIR=${BUILD_DIR}/books
TMP_BOOK_DIR=${TMP_DIR}/books
BUILD_SONG_DIR=${BUILD_DIR}/songs
TMP_SONG_DIR=${TMP_DIR}/songs
BUILD_MIDI_DIR=${BUILD_DIR}/midi
TMP_MIDI_DIR=${TMP_DIR}/midi
BUILD_OPUS_DIR=${BUILD_DIR}/opus
# a list of all used commands (they have to be in your PATH)
LILYPOND = lilypond
LUALATEX = lualatex
MAKEINDEX = makeindex
TIMIDITY = timidity
OPUSENC = opusenc
PDF2PS = pdf2ps
PSBOOK = psbook
PSTOPS = pstops
PSNUP = psnup
PS2PDF = ps2pdf
SED = sed # do not use in-place editing for compatibility between different sed versions
RM = rm
MKDIR = mkdir
CD = cd
CP = cp
LY_FILES=$(wildcard ${SONG_DIR}/*.ly)
LY_PDFS=$(patsubst %.ly,${BUILD_SONG_DIR}/%.pdf,$(notdir ${LY_FILES}))
LY_TMP_PDFS=$(patsubst %.ly,${TMP_SONG_DIR}/%.pdf,$(notdir ${LY_FILES}))
LY_MIDIS=$(patsubst %.ly,${BUILD_MIDI_DIR}/%.midi,$(notdir ${LY_FILES}))
LY_TMP_MIDIS=$(patsubst %.ly,${TMP_MIDI_DIR}/%.midi,$(notdir ${LY_FILES}))
LY_OPUS=$(patsubst %.ly,${BUILD_OPUS_DIR}/%.opus,$(notdir ${LY_FILES}))
SRCDIR = src
OUTDIR = out
PDFDIR = pdf
MIDIDIR = midi
OPUSDIR = music
SCORESDIR = $(SRCDIR)/scores
LYRICSDIR = $(SRCDIR)/lyrics
.PHONY: book songs midi opus clean directories all
.DEFAULT_GOAL := all
OUTPUTFILE = $(OUTDIR)/singalongs.tex
TEXFILES = $(wildcard $(SRCDIR)/*.tex)
SCORES = $(wildcard $(SCORESDIR)/*.ly)
LYRICS = $(wildcard $(LYRICSDIR)/*.tex)
PDFS = $(patsubst %.ly,$(PDFDIR)/%.pdf,$(notdir $(SCORES)))
MIDIS = $(patsubst %.ly,$(MIDIDIR)/%.midi,$(notdir $(SCORES)))
OPUSFILES = $(patsubst %.ly,$(OPUSDIR)/%.opus,$(notdir $(SCORES)))
directories: ${BUILD_DIR} ${BUILD_BOOK_DIR} ${TMP_BOOK_DIR} ${BUILD_SONG_DIR} ${BUILD_MIDI_DIR} ${TMP_DIR} ${TMP_SONG_DIR} ${TMP_MIDI_DIR} ${BUILD_OPUS_DIR}
LILYPONDSUBST = $(foreach score,$(SCORES), \\\\chapter {$(shell grep title "$(score)" | awk -F '"|"' '{print $$2}')} \\\\includely[staffsize=18]{$(abspath $(score))} ~\\\\\\\\ ~\\\\\\\\ \\\\input{$(abspath $(LYRICSDIR)/$(notdir $(basename $(score)))).tex})
${BUILD_DIR}:
mkdir -p ${BUILD_DIR}
BOOKPDF = $(PDFDIR)/book.pdf
BOOKLETPDF = $(PDFDIR)/booklet.pdf
${BUILD_BOOK_DIR}:
mkdir -p ${BUILD_BOOK_DIR}
MIDITEMPO = 120
${BUILD_SONG_DIR}:
mkdir -p ${BUILD_SONG_DIR}
all: pdfs midis opus book booklet
${BUILD_MIDI_DIR}:
mkdir -p ${BUILD_MIDI_DIR}
pdfs: $(PDFS)
${TMP_DIR}:
mkdir -p ${TMP_DIR}
midis: pdfs $(MIDIS)
${TMP_BOOK_DIR}:
mkdir -p ${TMP_BOOK_DIR}
opus: midis $(OPUSFILES)
${TMP_SONG_DIR}:
mkdir -p ${TMP_SONG_DIR}
book: $(BOOKPDF)
${TMP_MIDI_DIR}:
mkdir -p ${TMP_MIDI_DIR}
booklet: $(BOOKLETPDF)
${BUILD_OPUS_DIR}:
mkdir -p ${BUILD_OPUS_DIR}
$(BOOKPDF): $(TEXFILES) $(SCORES) $(LYRICS) | $(PDFDIR) $(OUTDIR)
@$(CP) $(TEXFILES) $(OUTDIR)/
@$(CP) -r lib/* $(OUTDIR)/
@$(CP) -r $(SRCDIR)/images $(OUTDIR)/images
${TMP_SONG_DIR}/%.pdf: ${SONG_DIR}/%.ly ${SONG_DIR}/%.tex
cd ${SRC_DIR} && lualatex --jobname='$(notdir $(basename $@))' --output-directory=${WORKING_DIR}/${TMP_SONG_DIR} --shell-escape ${WORKING_DIR}/${SRC_DIR}/song.tex ${WORKING_DIR}/${SONG_DIR}/$(notdir $(basename $@)).ly ${WORKING_DIR}/${SONG_DIR}/$(notdir $(basename $@)).tex
rm -r ${SRC_DIR}/tmp-ly
@$(SED) "s;\musicbooklet;$(LILYPONDSUBST);g" $(SRCDIR)/singalongs.tex > $(OUTPUTFILE).00
@$(SED) 's/REVISION/$(shell git log -1 --format="%h")/g' $(OUTPUTFILE).00 > $(OUTPUTFILE)
${BUILD_MIDI_DIR}/%.midi: ${TMP_MIDI_DIR}/%-1.midi
cp $< $@
@$(CD) $(OUTDIR); \
$(LUALATEX) -shell-escape singalongs.tex; \
$(MAKEINDEX) singalongs.tex; \
$(LUALATEX) -shell-escape singalongs.tex
${TMP_MIDI_DIR}/%-1.midi: ${SONG_DIR}/%.ly
lilypond --output=${TMP_MIDI_DIR} ${WORKING_DIR}/$<
@$(CP) $(OUTDIR)/singalongs.pdf $(PDFDIR)/$(@F)
${BUILD_OPUS_DIR}/%.opus: ${BUILD_MIDI_DIR}/%.midi
timidity $< -Ow -o - | opusenc - $@
$(BOOKLETPDF): $(BOOKPDF)
$(PDF2PS) $(BOOKPDF) - | $(PSBOOK) | $(PSTOPS) -pa4 '1:0@1.0(-1.25cm,0cm)' | $(PSNUP) -2 | $(PS2PDF) - $(PDFDIR)/$(@F)
${TMP_BOOK_DIR}/%.pdf: ${SRC_DIR}/%.tex ${SRC_DIR}/images/title.png
latexmk -cd -lualatex -e '$$lualatex=q/lualatex %O -shell-escape %S/' -output-directory=${WORKING_DIR}/${TMP_BOOK_DIR} $<
rm -r ${SRC_DIR}/tmp-ly
$(PDFDIR)/%.pdf: $(SCORESDIR)/%.ly | $(PDFDIR) $(OUTDIR)
@$(SED) 's/%title/title/g' $< > $(OUTDIR)/$(notdir $<).00
@$(SED) 's/\header {/\paper{indent=0\\mm} \\header { tagline=""/g' $(OUTDIR)/$(notdir $<).00 > $(OUTDIR)/$(notdir $<)
@$(LILYPOND) --output=$(PDFDIR)/$(basename $(@F)) $(OUTDIR)/$(notdir $<)
${TMP_BOOK_DIR}/%-folio.pdf: ${TMP_BOOK_DIR}/%.pdf
cd ${TMP_BOOK_DIR} && \
../../bin/makebook -v -t folio -i $(notdir $<) -o $(notdir $@)
$(MIDIDIR)/%.midi: $(SCORESDIR)/%.ly | $(MIDIDIR) $(OUTDIR)
@$(SED) 's/\layout { }/\midi{ \\tempo 4 = $(MIDITEMPO) }/g' $< > $(OUTDIR)/$(notdir $<).00
@$(SED) 's/\header/\include "articulate.ly" \\header/g' $(OUTDIR)/$(notdir $<).00 > $(OUTDIR)/$(notdir $<).01
@$(SED) 's/<</\\articulate \\unfoldRepeats <</g' $(OUTDIR)/$(notdir $<).01 > $(OUTDIR)/$(notdir $<)
@$(LILYPOND) --output=$(MIDIDIR)/$(basename $(@F)) $(OUTDIR)/$(notdir $<)
#long edge binding
${TMP_BOOK_DIR}/%-quarto.pdf: ${TMP_BOOK_DIR}/%.pdf
cd ${TMP_BOOK_DIR} && \
../../bin/makebook -v -t quarto -i $(notdir $<) -o $(notdir $@)
$(OPUSDIR)/%.opus: $(MIDIDIR)/%.midi | $(OPUSDIR)
@$(TIMIDITY) $< -Ow -o - | $(OPUSENC) - $(OPUSDIR)/$(@F)
${TMP_BOOK_DIR}/%-sexto.pdf: ${TMP_BOOK_DIR}/%.pdf
cd ${TMP_BOOK_DIR} && \
../../bin/makebook -v -t sexto -i $(notdir $<) -o $(notdir $@)
$(PDFDIR):
@$(MKDIR) -p $(PDFDIR)
#short edge binding
${TMP_BOOK_DIR}/%-octavo.pdf: ${TMP_BOOK_DIR}/%.pdf
cd ${TMP_BOOK_DIR} && \
../../bin/makebook -v -t octavo -i $(notdir $<) -o $(notdir $@)
$(MIDIDIR):
@$(MKDIR) -p $(MIDIDIR)
${BUILD_DIR}/%.pdf: ${TMP_DIR}/%.pdf
cp $< $@
$(OPUSDIR):
@$(MKDIR) -p $(OPUSDIR)
book: directories ${BUILD_BOOK_DIR}/${BOOKNAME}.pdf ${BUILD_BOOK_DIR}/${BOOKNAME}-folio.pdf ${BUILD_BOOK_DIR}/${BOOKNAME}-quarto.pdf ${BUILD_BOOK_DIR}/${BOOKNAME}-sexto.pdf ${BUILD_BOOK_DIR}/${BOOKNAME}-octavo.pdf ${LY_FILES}
songs: directories ${LY_PDFS}
midi: directories ${LY_MIDIS}
opus: directories ${LY_OPUS}
all: book songs midi opus
$(OUTDIR):
@$(MKDIR) -p $(OUTDIR)
.PHONY: clean
clean:
@$(RM) -rf $(PDFDIR) $(MIDIDIR) $(OPUSDIR) $(OUTDIR)
rm -rf ${BUILD_DIR}
rm -rf ${TMP_DIR}

655
bin/makebook Executable file
View File

@ -0,0 +1,655 @@
#!/bin/sh
# +AMDG This document was begun just before Christmas,
# 2010, and it is humbly dedicated to St. Wulfric, patron of
# bookbinders, and to the Immaculate Heart of Mary for their
# prayers, and to the Sacred Heart of Jesus for His mercy.
#
#**********************************************************#
# makebook #
# written by Donald P. Goodman III #
# Copyright (C) 2011 #
# #
# Impose pdf pages for binding #
#**********************************************************#
#
# This program is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more
# details.
#
# For a full copy of the GNU General Public License, see
# <http://www.gnu.org/licenses/>.
#
#**********************************************************#
# begin the code #
#**********************************************************#
# make script more portable and secure
PATH=/bin:/usr/bin:/usr/local/bin ; export PATH
umask 033
# define our revision number variable for rcs
REVISION="2.1"
# define error codes
E_WRONG_ARGS=64 # too many or few args
E_BAD_SIG_TYPE=65 # invalid type of signature
E_BAD_UNIT=66 # unrecognized dimension unit used
E_BAD_FILENAME=67 # filename contains insecure chars,
# or doesn't exist
E_BAD_OPT=68 # bad command-line flag requested
E_NO_PROG=69 # missing a required program
# define usage variables
VERBOSE=0 # 0 if not verbose, 1 if -v
SIG_TYPE="folio" # type of section desired
PAGES_PER_SIG=4 # number of pages per signature
SECT_TYPE=1 # number of signatures per section
NUP="2x1" # default format of signatures
FRONT_FAVOR=0 # favor front for blanks; off by default
# define various variables to be zero by default
TGT_PAGE_WIDTH=0
TGT_PAGE_HEIGHT=0
HORIZ_DELTA=0
VERT_DELTA=0
HORIZ_OFFSET=0
VERT_OFFSET=0
SCALE=1
# make sure user has the right programs installed, and die
# horribly if not
command -v od >/dev/null 2>&1 ||
{ echo >&2 "makebook: error: requires od, but it's not installed";
exit $E_NO_PROG;
}
command -v pdflatex >/dev/null 2>&1 ||
{ echo >&2 "makebook: error: requires pdflatex, but it's not installed";
exit $E_NO_PROG;
}
command -v pdfinfo >/dev/null 2>&1 ||
{ echo >&2 "makebook: error: requires pdfinfo, but it's not installed";
exit $E_NO_PROG;
}
command -v pdftk >/dev/null 2>&1 ||
{ echo >&2 "makebook: error: requires pdftk, but it's not installed";
exit $E_NO_PROG;
}
command -v dc >/dev/null 2>&1 ||
{ echo >&2 "makebook: error: requires dc, but it's not installed";
exit $E_NO_PROG;
}
command -v bc >/dev/null 2>&1 ||
{ echo >&2 "makebook: error: requires bc, but it's not installed";
exit $E_NO_PROG;
}
# print the version information and exit successfully
versionfunc ()
{
echo "makebook v${REVISION}. Copyright (C) 2011, Donald P."
echo "Goodman III."
echo "This program comes with ABSOLUTELY NO WARRANTY."
echo "This is free software, and you are welcome to "
echo "redistribute it under certain conditions; see "
echo "the GNU GPL v3 for details."
exit 0
}
# print the online help and exit successfully
helpfunc ()
{
cat <<End-of-help
makebook v${REVISION}. Copyright (C) 2011, Donald P. Goodman III.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to
redistribute it under certain conditions; see
the GNU GPL v3 for details.
-V: Prints license and version information, then exits
successfully.
-h: Prints this help information, then exist successfully.
-v: Verbose output
-f: Favor front, rather than back, for blanks.
-t: Signature type
-n: Number of signatures per section.
-H: Height of the target page.
-w: Width of the target page.
-d: Horizontal delta.
-D: Vertical delta.
-m: Horizontal offset.
-M: Vertical offset.
-s: Scaling of source pages to target page.
-i: Input file.
-o: Output file.
Please see the man page for complete documentation.
End-of-help
exit 0;
}
# define a for dealing with units; convert to bp ()
unitarg ()
{
if [ ! `echo "$1" | grep '^[\+\|-]*[0-9\.][0-9\.]*\(in\|cm\|pt\|mm\|bp\|pc\|$\)'` ]
then
echo "ERROR: dimension \"$1\" not valid." >&2
exit $E_BAD_UNIT
fi
if [ `expr match "$1" '.*\(in\)'` ]
then
OPTARG=`echo "scale=0; ${1%in} * 72" | bc`
OPTARG=${OPTARG%.*}
elif [ `expr match "$1" '.*\(cm\)'` ]
then
OPTARG=`echo "scale=0; ${1%cm} * 28.3464567" | bc`
OPTARG=${OPTARG%.*}
elif [ `expr match "$1" '.*\(mm\)'` ]
then
OPTARG=`echo "scale=0; ${1%mm} * 2.83464567" | bc`
OPTARG=${OPTARG%.*}
elif [ `expr match "$1" '.*\(pt\)'` ]
then
OPTARG=`echo "scale=0; ${1%pt} / 1.00375" | bc`
OPTARG=${OPTARG%.*}
elif [ `expr match "$1" '.*\(pc\)'` ]
then
OPTARG=`echo "scale=0; (${1%pc} / 1.00375) * 12" | bc`
OPTARG=${OPTARG%.*}
elif [ `expr match "$1" '.*\(bp\)'` ]
then
OPTARG=${1%bp}
else
OPTARG=${1%.*}
fi
}
# define a for dealing with section types; convert ()
# to words; e.g., "4to" to "quarto"
typearg ()
{
if [ "$1" = "4to" ] || [ "$1" = "quarto" ]
then
PAGES_PER_SIG=8
NUP="2x2"
OPTARG="quarto"
elif [ "$1" = "2o" ] || [ "$1" = "folio" ]
then
PAGES_PER_SIG=4
NUP="2x1"
OPTARG="folio"
elif [ "$1" = "8vo" ] || [ "$1" = "octavo" ]
then
PAGES_PER_SIG=16
NUP="4x2"
OPTARG="octavo"
elif [ "$1" = "6to" ] || [ "$1" = "sexto" ]
then
PAGES_PER_SIG=12
NUP="2x3"
OPTARG="sexto"
elif [ "$1" = "12mo" ] || [ "$1" = "duodecimo" ]
then
PAGES_PER_SIG=24
NUP="4x3"
OPTARG="duodecimo"
else
echo "ERROR: signature type \"$1\" not recognized." >&2
exit $E_BAD_SIG_TYPE
fi
}
# clean up filename argument
filefunc ()
{
err_message="ERROR: bad characters in file name."
if [ `echo "$1" | grep '\?'` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
elif [ `echo "$1" | grep '\*'` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
elif [ `echo "$1" | grep '"'` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
elif [ `echo "$1" | grep ';'` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
elif [ `echo "$1" | grep '[\\]'` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
elif [ `echo "$1" | grep ' '` ]
then
echo "$err_message" >&2
exit $E_BAD_FILENAME
fi
OPTARG=`basename $1`
}
# now identify and parse the options
while getopts "Vhvfn:t:H:w:d:D:m:M:s:i:o:" Option
do
case $Option in
V ) versionfunc;;
h ) helpfunc;;
v ) VERBOSE=1;;
f ) FRONT_FAVOR=1;;
n ) SECT_TYPE=$OPTARG;;
t ) typearg "$OPTARG"; SIG_TYPE=$OPTARG;;
H ) unitarg "$OPTARG"; TGT_PAGE_HEIGHT=$OPTARG;;
w ) unitarg "$OPTARG"; TGT_PAGE_WIDTH=$OPTARG;;
d ) unitarg "$OPTARG"; HORIZ_DELTA=$OPTARG;;
D ) unitarg "$OPTARG"; VERT_DELTA=$OPTARG;;
m ) unitarg "$OPTARG"; HORIZ_OFFSET=$OPTARG;;
M ) unitarg "$OPTARG"; VERT_OFFSET=$OPTARG;;
s ) SCALE=$OPTARG;;
i ) filefunc "$OPTARG"; FILE_NAME=$OPTARG;;
o ) filefunc "$OPTARG"; OUTFILE_NAME=$OPTARG;;
* ) echo "ERROR: unknown flag \
\"$Option\"." >&2; exit $E_BAD_OPT;;
esac
done
# make random file name to use for input
NEW_FILE_NAME="tmp_`od -An -N4 -t uL /dev/urandom | tr -d '\ '`.pdf"
# if input file specified, use file; if not, read stdin
if [ "$FILE_NAME" ]
then
cp "$FILE_NAME" "$NEW_FILE_NAME"
else
FILE_NAME="book.pdf"
cat /dev/stdin > "$NEW_FILE_NAME"
fi
# declare holder variable for pdftk
tmp_name="tmp_`od -An -N4 -t uL /dev/urandom | tr -d '\ '`.pdf"
# if output file specified, use that; if not, name it; if
# "-", use stdout
[ "$OUTFILE_NAME" ] || OUTFILE_NAME="sigs_$FILE_NAME"
if [ "$OUTFILE_NAME" = "stdout" ]
then
VERBOSE=0
fi
# print our introduction message
if [ $VERBOSE -eq 1 ]
then
echo "makebook. Copyright (C) 2011, Donald P. Goodman III."
echo "This program comes with ABSOLUTELY NO WARRANTY."
echo "This is free software, and you are welcome to "
echo "redistribute it under certain conditions; see "
echo "the GNU GPL v3 for details."
echo "IMPOSING pdf pages onto \"$OUTFILE_NAME\"..."
fi
# get some information about our source document
NUM_PAGES=`pdfinfo "$NEW_FILE_NAME" | awk '/Pages:/ {print $2}'`;
SRC_PAGE_WIDTH=`pdfinfo "$NEW_FILE_NAME" | awk '/Page\ size:/ {print $3}'`;
SRC_PAGE_HEIGHT=`pdfinfo "$NEW_FILE_NAME" | awk '/Page\ size:/ {print $5}'`;
# find the number of pages we'll have per signature
PAGES_PER_SIG=$(dc -e "$PAGES_PER_SIG $SECT_TYPE * p")
# determine if extra pages will be necessary
NUM_BLANKS=`expr $NUM_PAGES % $PAGES_PER_SIG`
if [ $NUM_BLANKS -ne 0 ]
then
NUM_BLANKS=`expr $PAGES_PER_SIG - $NUM_BLANKS`
fi
tmp=`expr $NUM_PAGES + $NUM_BLANKS`
NUM_SIGS=`expr $tmp / $PAGES_PER_SIG`
# if extra pages are needed, generate blank page
if [ $NUM_BLANKS -gt 0 ] && [ ! -e "./blank.pdf" ]
then
echo "\documentclass{article}" > blank.tex
echo '\\thispagestyle{empty}' >> blank.tex
echo "\usepackage[paperwidth=${SRC_PAGE_WIDTH}bp,paperheight="${SRC_PAGE_HEIGHT}bp"]{geometry}" >> blank.tex
echo '\\begin{document}' >> blank.tex
echo "\quad \\\\end{document}" >> blank.tex
if [ $VERBOSE -eq 1 ]
then
echo "CREATING blank page to fill sections...";
fi
pdflatex blank.tex > /dev/null 2&>1
fi
# now insert blank pages as needed, preferring the back for
# odd numbers by default, front if stated
if [ $NUM_BLANKS -eq 1 ]
then
if [ $VERBOSE -eq 1 ]
then
echo "INSERTING one blank page..."
fi
if [ $FRONT_FAVOR -eq 0 ]
then
pdftk A="$NEW_FILE_NAME" B=blank.pdf cat A1-end \
B1 output "$tmp_name"
else
pdftk A="$NEW_FILE_NAME" B=blank.pdf cat B1 \
A1-end output "$tmp_name"
fi
mv "$tmp_name" "$NEW_FILE_NAME"
else
# tmp=`expr $NUM_BLANKS / 2`
# START_BLANKS=${tmp/.*}
START_BLANKS=`expr $NUM_BLANKS / 2`
END_BLANKS=`expr $NUM_BLANKS - $START_BLANKS`
if [ `expr $START_BLANKS % 2` -ne 0 ]; then : else
START_BLANKS=`expr $START_BLANKS - 1`
END_BLANKS=`expr $END_BLANKS + 1 `
fi
if [ $FRONT_FAVOR -eq 1 ]
then
tmp=$START_BLANKS
START_BLANKS=$END_BLANKS
END_BLANKS=$tmp
if [ `expr $START_BLANKS % 2` -ne 0 ]; then : else
START_BLANKS=`expr $START_BLANKS - 1`
END_BLANKS=`expr $END_BLANKS + 1 `
fi
fi
if [ $VERBOSE -eq 1 ]
then
echo "INSERTING $START_BLANKS blank pages at start..."
echo "INSERTING $END_BLANKS blank pages at end...";
fi
i=0
while [ $i -lt $START_BLANKS ]
do
pdftk A="$NEW_FILE_NAME" B=blank.pdf cat B1 A1-end output "$tmp_name"
mv "$tmp_name" "$NEW_FILE_NAME"
i=`expr $i + 1`
done
i=0
while [ $i -lt $END_BLANKS ]
do
pdftk A="$NEW_FILE_NAME" B=blank.pdf cat A1-end B1 output "$tmp_name"
mv "$tmp_name" "$NEW_FILE_NAME"
i=`expr $i + 1`
done
fi
# begin the imposing, announcing if appropriate
tmp=`expr $NUM_PAGES + $NUM_BLANKS`
if [ $VERBOSE -eq 1 ]
then
echo "IMPOSING $NUM_PAGES pages ($tmp with blanks) on
$(dc -e "$NUM_SIGS $SECT_TYPE * p") signature(s) gathered in
sections of $SECT_TYPE signature(s) each...";
fi
# arrange the pages for impression on signatures
i=1
j=1
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING pages...";
fi
while [ $j -le $NUM_SIGS ]
do
if [ "$SIG_TYPE" = "quarto" ]
then
# determine size of target page
if [ $TGT_PAGE_HEIGHT -eq 0 ]
then
TGT_PAGE_HEIGHT=$(dc -e "$SRC_PAGE_HEIGHT 2 * p")
fi
if [ $TGT_PAGE_WIDTH -eq 0 ]
then
TGT_PAGE_WIDTH=$(dc -e "$SRC_PAGE_WIDTH 2 * p")
fi
# do the rearranging
k=$i; n=1; total=$(dc -e "$SECT_TYPE 8 * p"); m=$total
while [ $n -le $SECT_TYPE ]
do
pdftk "$NEW_FILE_NAME" cat `expr $k + $m - 1` $k \
`expr $k + $m - 4`south `expr $k + 3`south \
`expr $k + 1` `expr $k + $m - 2` `expr $k + 2`south \
`expr $k + $m - 3`south output ${tmp_name%.pdf}_$n;
k=`expr $k + 4`; n=`expr $n + 1`; m=`expr $m - 8`
done
n=1
while [ `expr $n + 0` -le $SECT_TYPE ]
do
if [ ! -e "$tmp_name" ]
then
pdftk A=${tmp_name%.pdf}_$n cat A1-end \
output "$tmp_name"
else
pdftk A=$tmp_name B=${tmp_name%.pdf}_`expr $n` \
cat A1-end B1-end output ${tmp_name}_tmp
mv ${tmp_name}_tmp "$tmp_name"
fi
n=`expr $n + 1`
done
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING section number $j..."
fi
j=`expr $j + 1`;
i=`expr $i + $total`;
elif [ "$SIG_TYPE" = "folio" ]
then
# determine size of target page
if [ 1 -eq "$(echo "${TGT_PAGE_HEIGHT} == 0" | bc)" ]
then
TGT_PAGE_HEIGHT=$(dc -e "$SRC_PAGE_HEIGHT 1 * p")
fi
if [ 1 -eq "$(echo "${TGT_PAGE_WIDTH} == 0" | bc)" ]
then
TGT_PAGE_WIDTH=$(dc -e "$SRC_PAGE_WIDTH 2 * p")
fi
# do the rearranging
k=$i; n=1; total=$(dc -e "$SECT_TYPE 4 * p"); m=$total
while [ $n -le $SECT_TYPE ]
do
pdftk "$NEW_FILE_NAME" cat `expr $k + $m - 1` \
`expr $k` `expr $k + 1` `expr $k + $m - 2` \
output ${tmp_name%.pdf}_$n;
k=`expr $k + 2`; n=`expr $n + 1`; m=`expr $m - 4`
done
n=1
while [ `expr $n + 0` -le $SECT_TYPE ]
do
if [ ! -e "$tmp_name" ]
then
pdftk A=${tmp_name%.pdf}_$n cat A1-end \
output "$tmp_name"
else
pdftk A="$tmp_name" B=${tmp_name%.pdf}_`expr $n` \
cat A1-end B1-end output ${tmp_name}_tmp
mv ${tmp_name}_tmp "$tmp_name"
fi
n=`expr $n + 1`
done
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING section number $j..."
fi
j=`expr $j + 1`;
i=`expr $i + $total`;
elif [ "$SIG_TYPE" = "octavo" ]
then
# determine target page dimensions
if [ 1 -eq "$(echo "${TGT_PAGE_HEIGHT} == 0" | bc)" ]
then
TGT_PAGE_HEIGHT=$(dc -e "$SRC_PAGE_HEIGHT 2 * p")
fi
if [ 1 -eq "$(echo "${TGT_PAGE_WIDTH} == 0" | bc)" ]
then
TGT_PAGE_WIDTH=$(dc -e "$SRC_PAGE_WIDTH 4 * p")
fi
# do the rearranging
k=$i; n=1; total=$(dc -e "$SECT_TYPE 16 * p"); m=$total
while [ $n -le $SECT_TYPE ]
do
pdftk "$NEW_FILE_NAME" cat `expr $k + 3` \
`expr $k + $m - 4` `expr $k + $m - 1` $k \
`expr $k + 4`south `expr $k + $m - 5`south \
`expr $k + $m - 8`south `expr $k + 7`south \
`expr $k + 1` `expr $k + $m - 2` `expr $k + $m - 3` \
`expr $k + 2` `expr $k + 6`south `expr $k + $m - 7`south \
`expr $k + $m - 6`south `expr $k + 5`south \
output ${tmp_name%.pdf}_$n;
k=`expr $k + 8`; n=`expr $n + 1`; m=`expr $m - 16`
done
n=1
while [ `expr $n + 0` -le $SECT_TYPE ]
do
if [ ! -e "$tmp_name" ]
then
pdftk A=${tmp_name%.pdf}_$n cat A1-end \
output "$tmp_name"
else
pdftk A="$tmp_name" B=${tmp_name%.pdf}_`expr $n` \
cat A1-end B1-end output ${tmp_name}_tmp
mv ${tmp_name}_tmp "$tmp_name"
fi
n=`expr $n + 1`
done
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING section number $j..."
fi
j=`expr $j + 1`;
i=`expr $i + $total`;
elif [ "$SIG_TYPE" = "sexto" ]
then
# determine target page dimensions
if [ $TGT_PAGE_HEIGHT -eq 0 ]
then
TGT_PAGE_HEIGHT=$(dc -e "$SRC_PAGE_HEIGHT 3 * p")
fi
if [ $TGT_PAGE_WIDTH -eq 0 ]
then
TGT_PAGE_WIDTH=$(dc -e "$SRC_PAGE_WIDTH 2 * p")
fi
# do the rearranging
k=$i; n=1; total=$(dc -e "$SECT_TYPE 12 * p"); m=$total
while [ $n -le $SECT_TYPE ]
do
pdftk "$NEW_FILE_NAME" cat `expr $k + 5` \
`expr $k + 6` `expr $k + $m - 1` $k \
`expr $k + $m - 1 - 3`south `expr $k + 3`south \
`expr $k + 7` `expr $k + 4` \
`expr $k + 1` `expr $k + $m - 1 - 1` \
`expr $k + 2`south `expr $k + $m - 1 - 2`south \
output ${tmp_name%.pdf}_$n;
k=`expr $k + 6`; n=`expr $n + 1`; m=`expr $m - 12`
done
n=1
while [ `expr $n + 0` -le $SECT_TYPE ]
do
if [ ! -e "$tmp_name" ]
then
pdftk A=${tmp_name%.pdf}_$n cat A1-end \
output "$tmp_name"
else
pdftk A=$tmp_name B=${tmp_name%.pdf}_`expr $n` \
cat A1-end B1-end output ${tmp_name}_tmp
mv ${tmp_name}_tmp "$tmp_name"
fi
n=`expr $n + 1`
done
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING section number $j..."
fi
j=`expr $j + 1`;
i=`expr $i + $total`;
elif [ "$SIG_TYPE" = "duodecimo" ]
then
# determine target page dimensions
if [ $TGT_PAGE_HEIGHT -eq 0 ]
then
TGT_PAGE_HEIGHT=$(dc -e "$SRC_PAGE_HEIGHT 3 * p")
fi
if [ $TGT_PAGE_WIDTH -eq 0 ]
then
TGT_PAGE_WIDTH=$(dc -e "$SRC_PAGE_WIDTH 4 * p")
fi
# do the rearranging
k=$i; n=1; total=$(dc -e "$SECT_TYPE 24 * p"); m=$total
while [ $n -le $SECT_TYPE ]
do
pdftk "$NEW_FILE_NAME" cat `expr $k + 8` \
`expr $k + $m - 1 - 8` `expr $k + 12` \
`expr $k + 11` `expr $k + 4` \
`expr $k + $m - 1 - 3` `expr $k + $m - 1` \
$k `expr $k + 4`south `expr $k + $m - 1 - 4`south \
`expr $k + $m - 1 - 7`south `expr $k + 7`south \
`expr $k + 10` `expr $k + 13` `expr $k + 14` \
`expr $k + 9` `expr $k + 1` `expr $k + $m - 1 - 1` \
`expr $k + $m - 1 - 2` `expr $k + 2` \
`expr $k + 6`south `expr $k + $m - 1 - 6`south \
`expr $k + $m - 1 - 5`south `expr $k + 5`south \
output ${tmp_name%.pdf}_$n;
k=`expr $k + 12`; n=`expr $n + 1`; m=`expr $m - 24`
done
n=1
while [ `expr $n + 0` -le $SECT_TYPE ]
do
if [ ! -e "$tmp_name" ]
then
pdftk A=${tmp_name%.pdf}_$n cat A1-end \
output $tmp_name
else
pdftk A="$tmp_name" B=${tmp_name%.pdf}_`expr $n` \
cat A1-end B1-end output ${tmp_name}_tmp
mv ${tmp_name}_tmp "$tmp_name"
fi
n=`expr $n + 1`
done
if [ $VERBOSE -eq 1 ]
then
echo "REARRANGING section number $j..."
fi
j=`expr $j + 1`;
i=`expr $i + $total`;
fi
done
mv "$tmp_name" "$NEW_FILE_NAME"
rm ${tmp_name%.pdf}*
echo "\documentclass{article}
\usepackage{pdfpages}
\usepackage[paperwidth=${TGT_PAGE_WIDTH}bp,paperheight=${TGT_PAGE_HEIGHT}bp]{geometry}
\pagestyle{empty}" > ${OUTFILE_NAME%.pdf}.tex
echo '\\begin{document}' >> ${OUTFILE_NAME%.pdf}.tex
echo "\includepdf[nup=$NUP,pages=-,turn=false,columnstrict,
noautoscale,delta=${HORIZ_DELTA}bp ${VERT_DELTA}bp,
offset=${HORIZ_OFFSET}bp ${VERT_OFFSET}bp,scale=${SCALE}]
{./"$NEW_FILE_NAME"}" >> ${OUTFILE_NAME%.pdf}.tex
echo "\\\\end{document}" >> ${OUTFILE_NAME%.pdf}.tex
if [ $VERBOSE -eq 1 ]
then
echo "IMPOSING sections..."
fi
pdflatex ${OUTFILE_NAME%.pdf}.tex > /dev/null 2>&1
if [ $VERBOSE -eq 1 ]
then
echo "CLEANING up..."
fi
rm ${OUTFILE_NAME%.pdf}.tex ${OUTFILE_NAME%.pdf}.aux \
${OUTFILE_NAME%.pdf}.log "$NEW_FILE_NAME"
if [ -e "./blank.tex" ]; then
rm ./blank.tex
fi
if [ -e "./blank.aux" ]; then
rm ./blank.aux
fi
if [ -e "./blank.log" ]; then
rm ./blank.log
fi
if [ $VERBOSE -eq 1 ]
then
echo "`expr $NUM_PAGES + $NUM_BLANKS` pages imposed in
$(dc -e "$NUM_SIGS $SECT_TYPE * p") $SIG_TYPE signatures gathered
in sections of $SECT_TYPE signature(s) each and output to
${OUTFILE_NAME%.pdf}.pdf."
fi
if [ "$OUTFILE_NAME" = "stdout" ]
then
cat ${OUTFILE_NAME}.pdf
rm ${OUTFILE_NAME}.pdf
fi
exit 0

View File

@ -1,186 +0,0 @@
local err, warn, info, log = luatexbase.provides_module({
name = "lyluatex",
version = '0',
greinternalversion = internalversion,
date = "2015/07/14",
description = "Module lyluatex.",
author = "The Gregorio Project (see CONTRIBUTORS.md)",
copyright = "2008-2015 - The Gregorio Project",
license = "MIT",
})
local md5 = require 'md5'
LILYPOND = 'lilypond'
TMP = 'tmp_ly'
N = 0
function ly_definir_programme(lilypond)
if lilypond then LILYPOND = lilypond end
end
function contenuIntegral(contenu)
local content =""
for i, Line in ipairs(contenu:explode('\n')) do
if Line:find("^%s*[^%%]*\\include") then
local i = io.open(Line:gsub('%s*\\include%s*"(.*)"%s*$', "%1"), 'r')
if i then
content = content .. contenuIntegral(i:read('*a'))
else
content = content .. Line .. "\n"
end
else
content = content .. Line .. "\n"
end
end
return content
end
function direct_ly(ly, largeur, facteur)
N = N + 1
facteur = calcul_facteur(facteur)
ly = ly:gsub('\\par ', '\n')
local sortie = TMP..'/'..string.gsub(md5.sumhexa(contenuIntegral(ly))..'-'..facteur..'-'..largeur, '%.', '-')
if not lfs.isfile(sortie..'-systems.tex') then
compiler_ly(entete_lilypond(facteur, largeur - 10)..'\n'..ly, sortie)
end
retour_tex(sortie)
end
function inclure_ly(entree, currfiledir, largeur, facteur)
facteur = calcul_facteur(facteur)
nom = splitext(entree, 'ly')
entree = currfiledir..nom..'.ly'
if not lfs.isfile(entree) then entree = kpse.find_file(nom..'.ly') end
if not lfs.isfile(entree) then err("Le fichier %s.ly n'existe pas.", nom) end
local i = io.open(entree, 'r')
ly = i:read('*a')
i:close()
local sortie = TMP..'/' ..string.gsub(md5.sumhexa(contenuIntegral(ly))..'-'..facteur..'-'..largeur, '%.', '-')
if not lfs.isfile(sortie..'-systems.tex') then
compiler_ly(entete_lilypond(facteur, largeur - 10)..'\n'..ly, sortie, dirname(entree))
end
retour_tex(sortie)
end
function compiler_ly(ly, sortie, include)
mkdirs(dirname(sortie))
local commande = LILYPOND.." "..
"-dno-point-and-click "..
"-dbackend=eps "..
"-djob-count=2 "..
"-ddelete-intermediate-files "
if include then commande = commande.."-I "..lfs.currentdir()..'/'..include.." " end
commande = commande.."-o "..sortie.." -"
local p = io.popen(commande, 'w')
p:write(ly)
p:close()
end
function entete_lilypond(facteur, largeur)
return string.format(
[[%%En-tête
\version "2.18.2"
#(define default-toplevel-book-handler
print-book-with-defaults-as-systems )
#(define toplevel-book-handler
(lambda ( . rest)
(set! output-empty-score-list #f)
(apply print-book-with-defaults rest)))
#(define toplevel-music-handler
(lambda ( . rest)
(apply collect-music-for-book rest)))
#(define toplevel-score-handler
(lambda ( . rest)
(apply collect-scores-for-book rest)))
#(define toplevel-text-handler
(lambda ( . rest)
(apply collect-scores-for-book rest)))
#(set-global-staff-size %s)
%%Paramètres de la partition
\paper{
indent = 0\mm
line-width = %s\pt
}
%%Partition originale
]],
facteur,
largeur
)
end
function calcul_facteur(facteur)
if facteur == 0 then facteur = fontinfo(font.current()).size/39321.6 end
return facteur
end
function retour_tex(sortie)
local i = io.open(sortie..'-systems.tex', 'r')
contenu = i:read("*all")
i:close()
texoutput, _ = string.gsub(
contenu,
[[includegraphics{]], [[includegraphics{]]..dirname(sortie)
)
tex.print(([[\noindent]]..texoutput):explode('\n'))
end
function dirname(str)
if str:match(".-/.-") then
local name = string.gsub(str, "(.*/)(.*)", "%1")
return name
else
return ''
end
end
function splitext(str, ext)
if str:match(".-%..-") then
local name = string.gsub(str, "(.*)(%." .. ext .. ")", "%1")
return name
else
return str
end
end
function mkdirs(str)
path = '.'
for dir in string.gmatch(str, '([^%/]+)') do
path = path .. '/' .. dir
lfs.mkdir(path)
end
end
local fontdata = fonts.hashes.identifiers
function fontinfo(id)
local f = fontdata[id]
if f then
return f
end
return font.fonts[id]
end
mkdirs(TMP)

View File

@ -1,69 +0,0 @@
\ProvidesPackage{lyluatex}
% Dépendances
\RequirePackage{kvoptions}
\RequirePackage{graphicx}
\RequirePackage{keycommand}
\RequirePackage{environ}
\RequirePackage{currfile}
% Options
\DeclareStringOption[lilypond]{program}[lilypond]
\ProcessKeyvalOptions*
% Script lua
\directlua{dofile(kpse.find_file("lyluatex.lua"))}
\directlua{ly_definir_programme('\lyluatex@program')}
% Une tricherie un peu sale pour récupérer la largeur de ligne
\let\bs\textbackslash
{\catcode`p=12 \catcode`t=12 \gdef\un#1pt{#1}}
\newcommand*{\largeur}{\expandafter\un\the\linewidth}
% Taille des partitions
% Si la valeur est 0, elle sera automatiquement calculée
% à partir de la taille de police.
\def\staffsize{0}
\let\localstaffsize\staffsize
% Commandes principales
% Inclusion d'un fichier ly
\newkeycommand*\includely[staffsize=\staffsize][autres][1]{%
\directlua{%
inclure_ly(
"\luatexluaescapestring{#1}",
"\luatexluaescapestring{\currfiledir}",
\luatexluaescapestring{\largeur},
\luatexluaescapestring{\commandkey{staffsize}}
)%
}%
}
% Inclusion d'un fragment intégré au document (environnement de base)
\NewEnviron{compilerly}{%
\directlua{%
direct_ly(
"\luatexluaescapestring{\unexpanded\expandafter{\BODY}}",
\luatexluaescapestring{\largeur},
\luatexluaescapestring{\localstaffsize}
)%
}%
}
% Commande et environnement avec paramètres
\newkeycommand{\lily}[staffsize=\staffsize][autres][1]{%
\def\localstaffsize{\commandkey{staffsize}}%
\begin{compilerly}%
#1
\end{compilerly}%
}
\newkeyenvironment{ly}[staffsize=\staffsize][autres]{%
\def\localstaffsize{\commandkey{staffsize}}%
\compilerly%
}{
\endcompilerly%
}
% Commandes pour la compatibilité avec lilypond-book
\let\lilypondfile\includely
\let\lilypond\ly
\let\endlilypond\endly

View File

@ -1,37 +0,0 @@
\version "2.16.2"
\header {
%title = "All for Me Grog"
composer = "Stephen Hatfield"
}
global = {
\time 4/4
\key g \major
}
chordNames = \chordmode {
\global
s8 g1 c2 g1. d1 g1 c2 g1 d2 d2:7 g4.
}
melody = \relative d' {
\global
\partial 8 d8 |
g4 b8. a16 g4. fis8 |
e fis g e d2 |
d'4 d8. d16 d4 c8 b |
b a4.( a4) b8 c |
d(e) d b g4 g8 fis |
e a g e d4 g8 a |
b d c b b a g fis |
a2 g4( g8) \bar "|."
}
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout { }
}

View File

@ -1,45 +0,0 @@
\version "2.16.0"
\header {
%title = "The Black Velvet Band"
composer = "Traditional"
}
global = {
\time 3/4
\key g \major
}
chordNames = \chordmode {
\global
s4 d1.*3 a1.:7 d1*9/4 a d
}
melody = \relative g'' {
\global
\partial 4 d4 |
d2 d4 |
b c4. d8 |
c4 b2( |
b) a4 |
g a b |
g fis e |
d2.( |
d4) d' c |
b2 b4 |
d, e fis |
g2( a4) |
b2 g4 |
a b c |
fis, g a |
g2.( |
g2) s4 \bar "|."
}
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout { }
}

View File

@ -1,43 +0,0 @@
\version "2.16.0"
\header {
%title = "Bürgerlied"
composer = "Adalbert Harnisch"
}
global = {
\time 5/4
\key g \major
}
chordNames = \chordmode {
\global
s4 g1*3/4 e2:m g1*3/4 c2:7 a2:m d1*3/4:7 g1*3/4 c2:7 a2:m d1*3/4:7 g2 d4 g2 g d4 g2
}
melody = \relative d' {
\global
\partial 4 d8 d |
g4. g8 g a b b g a |
b4 d d8 c c b a g |
a b c b a4. r8 d c |
\repeat volta 2
{
b4 d e8 d c b a g |
a4 c d8 c b a g g |
}
\alternative
{
{ g4 b a8 a g4 d'8 c }
{ g4 b a8 a g4 s4 \bar "|." }
}
}
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout { }
}

View File

@ -1,44 +0,0 @@
\version "2.16.0"
\header {
%title = "Drunken Sailor"
composer = "Traditional"
}
global = {
\time 2/4
\key d \major
}
chordNames = \chordmode {
\global
a1:m g a:m g2 a:m a1:m g a:m g2 a:m
}
melody = \relative b' {
\global
b8 b16 b b8 b16 b |
b8 e, g b |
a a16 a a8 a16 a |
a8 d, fis a |
b b16 b b8 b16 b |
b8 cis d e |
d b a fis |
e4 e \bar ":|:"
b' b |
b8 e, g b |
a4 a |
a8 d, fis a |
b4 b |
b8 cis d e |
d b a fis |
e4 e \bar ":|"
}
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout { }
}

View File

@ -1,35 +0,0 @@
\version "2.16.0"
\header {
%title = "I'm a Rover Seldom Sober"
composer = "Traditional"
}
global = {
\time 4/4
\key g \major
}
chordNames = \chordmode {
\global
s4 g2 c g1*5/4 d1*3/4 g1*2 d4 g2
}
melody = \relative g' {
\global
\partial 4 g8. g16 |
g4 d8. d16 e8. e16 e4 |
d g8. g16 g4 b8. b16 |
b8. b16 a4 r8 d8 d8. c16 |
b4 d8. d16 a8. fis16 g4 d |
g8. a16 b4 b8. b16 a8. |
a16 g4 r4 \bar "|."
}
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout { }
}

View File

@ -1,33 +0,0 @@
\version "2.16.0"
\header {
%title = "The Kerry Recruit"
composer = "Traditional"
}
global = {
\time 6/8
\key g \major
}
chordNames = \chordmode {
\global
s8 g1*6/8 d:7 d c1*3/8 g
}
melody = \relative b' {
\global
\partial 8 b8 |
a8 g g g4 b8 |
b a a a4 d8 |
e d d b4 a8 |
a g g g4 \bar "|."
}
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout { }
}

View File

@ -1,45 +0,0 @@
\version "2.16.0"
\header {
%title = "Muirsheen Durkin"
composer = "Traditional"
}
global = {
\time 4/4
\key d \major
}
chordNames = \chordmode {
\global
s4 g1 d1*2 g d g d g d g1
}
melody = \relative d' {
\global
\partial 4 d8. e16 |
fis4 fis e d |
e a a b |
cis a g e |
e d2 d8. e16 |
fis4 fis e d |
e a2 b4 |
cis8 cis a4 b cis |
d2. a4 |
d d e d |
cis a a b |
cis a g e |
e d2 d8. e16 |
fis2 e4 d |
e a a b |
cis a g( e) |
d2. s4 \bar "|."
}
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout { }
}

View File

@ -1,33 +0,0 @@
\version "2.16.0"
\header {
%title = "The Rising of the Moon"
composer = "John Keegan Casey"
}
global = {
\time 4/4
\key g \major
}
chordNames = \chordmode {
\global
s4 g1 d c2 g d g
}
melody = \relative d' {
\global
\partial 4 g8 a |
b8. b16 b8 b b d4 b8 |
b a a b a4. d8 |
e8. c16 g'8 fis e d b g |
a8. a16 g8 fis g4 r4 \bar "|."
}
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout { }
}

View File

@ -1,5 +1,3 @@
\geometry{a4paper,left=20mm,right=20mm, top=3cm, bottom=3cm}
\setlength{\columnseprule}{0.2pt}
\hypersetup
@ -16,9 +14,5 @@
pdfcreator={Sebastian Hugentobler}, % creator of the document
pdfproducer={Sebastian Hugentobler}, % producer of the document
pdfnewwindow=true, % links in new window
colorlinks=true, % false: boxed links; true: colored links
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
colorlinks=false, % false: boxed links; true: colored links
}

View File

@ -1,22 +1,41 @@
% !Mode:: "TeX:UTF-8"
\documentclass[12pt, a4paper, openany]{scrbook}
\documentclass[11pt, openany, twoside]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{geometry}
\usepackage[a4paper]{geometry}
\usepackage{tgschola}
\usepackage{tocloft}
\usepackage[unicode]{hyperref}
\usepackage{multicol}
\usepackage{songs}
\usepackage{lyluatex}
\usepackage{graphicx}
\makeatletter
\newcommand{\unchapter}[1]{%
\begingroup
\let\@makechapterhead\@gobble % make \@makechapterhead do nothing
\chapter{#1}
\endgroup
}
\makeatother
\directlua {
local f = assert(io.popen('git rev-parse --short HEAD', 'r'))
local s = assert(f:read('*a'))
f:close()
tex.sprint("\string\\newcommand {\string\\revision}{" .. s .. "}")
}
\newcommand {\revision}{ REVISION }
\input{settings.tex}
\input{headfoot.tex}
\begin{document}
\widowpenalties 1 10000
\raggedbottom
\pagenumbering{roman}
\input{title.tex}
@ -39,10 +58,16 @@
\tableofcontents
\clearpage
\newpage
\pagenumbering{arabic}
\musicbooklet
\lysetoption{staffsize}{22}
\lysetoption{quote}{true}
\lysetoption{indent}{false}
\lysetoption{insert}{inline}
\lysetoption{pass-fonts}{true}
\songs
\end{document}

31
src/song.tex Normal file
View File

@ -0,0 +1,31 @@
% !Mode:: "TeX:UTF-8"
\documentclass[11pt, openany, oneside]{scrbook}
\usepackage{fontspec}
\usepackage[a4paper]{geometry}
\usepackage{lmodern}
\usepackage{tgschola}
\usepackage[unicode]{hyperref}
\usepackage{multicol}
\usepackage{lyluatex}
\begin{document}
\pagenumbering{gobble}
\lysetoption{staffsize}{22}
\lysetoption{quote}{true}
\lysetoption{indent}{false}
\lysetoption{insert}{inline}
\lysetoption{pass-fonts}{true}
\directlua{
tex.sprint("\string\\lilypondfile{" .. arg[5] .. "}")
}
~\\
\directlua{
tex.sprint("\string\\input{" .. arg[6] .. "}")
}
\end{document}

36
src/songs.lua Normal file
View File

@ -0,0 +1,36 @@
require "lfs"
local open = io.open
local function read_file(path)
local file = open(path, "rb") -- r read mode and b binary mode
if not file then return nil end
local content = file:read "*a" -- *a or *all reads the whole file
file:close()
return content
end
function string.ends(String,End)
return End=='' or string.sub(String,-string.len(End))==End
end
function find_songs(dir)
local files = {}
for file in lfs.dir(dir) do
table.insert(files, file)
end
table.sort(files)
for i = 1, #files do
local file = files[i]
if string.ends(file, ".ly") then
local ly_content = read_file(dir .. '/' .. file)
local ly_title = string.match(ly_content, 'title = "(.-)"')
tex.sprint('\\unchapter{' .. ly_title .. '}')
tex.sprint('\\lilypondfile{' .. dir .. '/' .. file .. '}')
tex.sprint('~\\\\')
tex.sprint('~\\\\')
tex.sprint('\\input{' .. dir .. '/' .. file:gsub("%.ly", ".tex") .. '}')
end
end
end

18
src/songs.sty Normal file
View File

@ -0,0 +1,18 @@
\ProvidesPackage{songs}
\RequirePackage{luatexbase}
\RequirePackage{luaotfload}
\RequirePackage{kvoptions}
\RequirePackage{keycommand}
\RequirePackage{currfile}
\directlua{dofile(kpse.find_file("songs.lua"))}
\def\songpath{"./songs"}
% Commandes principales
% Inclusion d'un fichier ly
\newkeycommand*\songs[songpath=\songpath]{%
\directlua{%
find_songs(\songpath)%
}%
}

57
src/songs/AllForMeGrog.ly Normal file
View File

@ -0,0 +1,57 @@
\version "2.18.2"
\include "articulate.ly"
\header {
title = "All for Me Grog"
composer = "Stephen Hatfield"
}
global = {
\time 4/4
\key g \major
}
chordNames = \chordmode {
\global
s8 g1 c2 g1. d1 g1 c2 g1 d2 d2:7 g4.
}
melody = \relative d' {
\global
\partial 8 d8 |
g4 b8. a16 g4. fis8 |
e fis g e d2 |
d'4 d8. d16 d4 c8 b |
b a4.( a4) b8 c |
d(e) d b g4 g8 fis |
e a g e d4 g8 a |
b d c b b a g fis |
a2 g4( g8) \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "Auld Lang Syne"
title = "Auld Lang Syne"
composer = "Robert Burns"
}
@ -36,6 +37,7 @@ melody = \relative a' {
d2. s4 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -43,3 +45,21 @@ melody = \relative a' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -0,0 +1,65 @@
\version "2.18.2"
\include "articulate.ly"
\header {
title = "The Black Velvet Band"
composer = "Traditional"
}
global = {
\time 3/4
\key g \major
}
chordNames = \chordmode {
\global
s4 d1.*3 a1.:7 d1*9/4 a d
}
melody = \relative g'' {
\global
\partial 4 d4 |
d2 d4 |
b c4. d8 |
c4 b2( |
b) a4 |
g a b |
g fis e |
d2.( |
d4) d' c |
b2 b4 |
d, e fis |
g2( a4) |
b2 g4 |
a b c |
fis, g a |
g2.( |
g2) s4 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

64
src/songs/Buergerlied.ly Normal file
View File

@ -0,0 +1,64 @@
\version "2.18.2"
\include "articulate.ly"
\header {
title = "Bürgerlied"
composer = "Adalbert Harnisch"
}
global = {
\time 5/4
\key g \major
}
chordNames = \chordmode {
\global
s4 g1*3/4 e2:m g1*3/4 c2:7 a2:m d1*3/4:7 g1*3/4 c2:7 a2:m d1*3/4:7 g2 d4 g2 g d4 g2
}
melody = \relative d' {
\global
\partial 4 d8 d |
g4. g8 g a b b g a |
b4 d d8 c c b a g |
a b c b a4. r8 d c |
\repeat volta 2
{
b4 d e8 d c b a g |
a4 c d8 c b a g g |
}
\alternative
{
{ g4 b a8 a g4 d'8 c }
{ g4 b a8 a g4 s4 \bar "|." }
}
}
\book {
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -0,0 +1,64 @@
\version "2.18.2"
\include "articulate.ly"
\header {
title = "Drunken Sailor"
composer = "Traditional"
}
global = {
\time 2/4
\key d \major
}
chordNames = \chordmode {
\global
a1:m g a:m g2 a:m a1:m g a:m g2 a:m
}
melody = \relative b' {
\global
b8 b16 b b8 b16 b |
b8 e, g b |
a a16 a a8 a16 a |
a8 d, fis a |
b b16 b b8 b16 b |
b8 cis d e |
d b a fis |
e4 e \bar ":|:"
b' b |
b8 e, g b |
a4 a |
a8 d, fis a |
b4 b |
b8 cis d e |
d b a fis |
e4 e \bar ":|"
}
\book {
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -47,11 +47,11 @@ Put him in the bed with the captain's daughter. \\
Way-hey up she rises \\
Way-hey up she rises \\
Way-hey up she rises \\
Earl-eye in the morning! \\
Early in the morning! \\
~\\
That's what we do with a drunken sailor \\
That's what we do with a drunken sailor \\
That's what we do with a drunken sailor \\
Earl-eye in the morning! \\
Early in the morning! \\
\end{center}
\end{multicols*}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "Tim Finnegan's Wake"
title = "Finnegan's Wake"
composer = "Traditional"
}
@ -44,6 +45,7 @@ melody = \relative a' {
e16 e fis8 g \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -51,3 +53,21 @@ melody = \relative a' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "The Foggy Dew"
title = "The Foggy Dew"
composer = "Charles ONeill"
}
@ -44,6 +45,7 @@ melody = \relative g' {
e2 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -51,3 +53,21 @@ melody = \relative g' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -0,0 +1,55 @@
\version "2.18.2"
\include "articulate.ly"
\header {
title = "I'm a Rover Seldom Sober"
composer = "Traditional"
}
global = {
\time 4/4
\key g \major
}
chordNames = \chordmode {
\global
s4 g2 c g1*5/4 d1*3/4 g1*2 d4 g2
}
melody = \relative g' {
\global
\partial 4 g8. g16 |
g4 d8. d16 e8. e16 e4 |
d g8. g16 g4 b8. b16 |
b8. b16 a4 r8 d8 d8. c16 |
b4 d8. d16 a8. fis16 g4 d |
g8. a16 b4 b8. b16 a8. |
a16 g4 r4 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "The Irish Rover"
title = "The Irish Rover"
composer = "Traditional"
}
@ -40,6 +41,7 @@ melody = \relative d'' {
g2. s4 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -47,3 +49,21 @@ melody = \relative d'' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "Johnny I hardly Knew Ye"
title = "Johnny I hardly Knew Ye"
composer = "Traditional"
}
@ -36,6 +37,7 @@ melody = \relative c' {
a4.( a4) r8 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -43,3 +45,21 @@ melody = \relative c' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

52
src/songs/KerryRecruit.ly Normal file
View File

@ -0,0 +1,52 @@
\version "2.18.2"
\include "articulate.ly"
\header {
title = "The Kerry Recruit"
composer = "Traditional"
}
global = {
\time 6/8
\key g \major
}
chordNames = \chordmode {
\global
s8 g1*6/8 d:7 d c1*3/8 g
}
melody = \relative b' {
\global
\partial 8 b8 |
a8 g g g4 b8 |
b a a a4 d8 |
e d d b4 a8 |
a g g g4 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "MacPherson's Farewell"
title = "MacPherson's Farewell"
composer = "Robert Burns"
}
@ -36,6 +37,7 @@ melody = \relative g' {
g2. s4 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -43,3 +45,21 @@ melody = \relative g' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "Molly Malone"
title = "Molly Malone"
composer = "Traditional"
}
@ -42,6 +43,7 @@ melody = \relative g' {
}
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -49,3 +51,21 @@ melody = \relative g' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -0,0 +1,65 @@
\version "2.18.2"
\include "articulate.ly"
\header {
title = "Muirsheen Durkin"
composer = "Traditional"
}
global = {
\time 4/4
\key d \major
}
chordNames = \chordmode {
\global
s4 g1 d1*2 g d g d g d g1
}
melody = \relative d' {
\global
\partial 4 d8. e16 |
fis4 fis e d |
e a a b |
cis a g e |
e d2 d8. e16 |
fis4 fis e d |
e a2 b4 |
cis8 cis a4 b cis |
d2. a4 |
d d e d |
cis a a b |
cis a g e |
e d2 d8. e16 |
fis2 e4 d |
e a a b |
cis a g( e) |
d2. s4 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "A Nation Once Again"
title = "A Nation Once Again"
composer = "Thomas Osborne Davis"
}
@ -44,6 +45,7 @@ melody = \relative a' {
d2. s4 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -51,3 +53,21 @@ melody = \relative a' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "The Parting Glass"
title = "The Parting Glass"
composer = "Traditional"
}
@ -36,6 +37,7 @@ melody = \relative b' {
g4 e e s \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -43,3 +45,21 @@ melody = \relative b' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -0,0 +1,53 @@
\version "2.18.2"
\include "articulate.ly"
\header {
title = "The Rising of the Moon"
composer = "John Keegan Casey"
}
global = {
\time 4/4
\key g \major
}
chordNames = \chordmode {
\global
s4 g1 d c2 g d g
}
melody = \relative d' {
\global
\partial 4 g8 a |
b8. b16 b8 b b d4 b8 |
b a a b a4. d8 |
e8. c16 g'8 fis e d b g |
a8. a16 g8 fis g4 r4 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
\new Staff { \melody }
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.2"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "Spancil Hill"
title = "Spancil Hill"
composer = "Michael Considine"
}
@ -65,6 +66,7 @@ melody = \relative e'' {
a2) s4 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -72,3 +74,21 @@ melody = \relative e'' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "The Star of the County Down"
title = "The Star of the County Down"
composer = "Cathal Mac Garvey"
}
@ -40,6 +41,7 @@ melody = \relative c' {
}
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -47,3 +49,21 @@ melody = \relative c' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "Whiskey in the Jar"
title = "Whiskey in the Jar"
composer = "Traditional"
}
@ -45,6 +46,7 @@ melody = \relative fis' {
d2. s4 \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -52,3 +54,21 @@ melody = \relative fis' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -1,7 +1,8 @@
\version "2.16.0"
\version "2.18.2"
\include "articulate.ly"
\header {
%title = "The Wild Rover"
title = "The Wild Rover"
composer = "Traditional"
}
@ -41,6 +42,7 @@ melody = \relative g' {
g2. \bar "|."
}
\book {
\score {
<<
\new ChordNames \chordNames
@ -48,3 +50,21 @@ melody = \relative g' {
>>
\layout {}
}
}
\book {
\score {
\unfoldRepeats \articulate
<<
\new Voice = "chords" {
\chordNames
}
\new Voice = "melody" {
\melody
}
>>
\midi {
\tempo 4 = 130
}
}
}

View File

@ -10,12 +10,12 @@
\begin{minipage}{0.5\textwidth}
\begin{flushleft} \large
\emph{Project Website:} \\
\href{https://code.vanwa.ch/sing-alongs}{code.vanwa.ch/sing-alongs} \\
\href{https://code.vanwa.ch/sebastian/sing-alongs}{code.vanwa.ch/sebastian/sing-alongs} \\
\end{flushleft}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large
\emph{Git Revision:} \\
\emph{Revision:} \\
\texttt{\revision} \\
\end{flushright}
\end{minipage}