summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-05-29 23:06:16 +0000
committerKarl Berry <karl@freefriends.org>2009-05-29 23:06:16 +0000
commit6672ce1582c8de8e3fbe4485d03d98bbf4526cd9 (patch)
treeb8cc586e47e06151fd1173994412c0d2178a1a94 /Master
parent058a16cce36235aaa6132a773fe0386bc72e18fa (diff)
context-lilypond update (28may09)
git-svn-id: svn://tug.org/texlive/trunk@13519 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/tex/context/third/lilypond/t-lilypond.tex436
-rw-r--r--Master/tlpkg/tlpsrc/xmltex.tlpsrc6
2 files changed, 243 insertions, 199 deletions
diff --git a/Master/texmf-dist/tex/context/third/lilypond/t-lilypond.tex b/Master/texmf-dist/tex/context/third/lilypond/t-lilypond.tex
index b0895ec2f0f..2f4d7b936b5 100644
--- a/Master/texmf-dist/tex/context/third/lilypond/t-lilypond.tex
+++ b/Master/texmf-dist/tex/context/third/lilypond/t-lilypond.tex
@@ -1,18 +1,18 @@
%D \module
%D [ file=t-lilypond,
-%D version=2009.05.15,
+%D version=2009.05.27,
%D title=\CONTEXT\ User Modules,
%D subtitle=LilyPond Connections (Music Typesetting),
-%D author={Christopher Creutzig, Henning Hraban Ramm, Mojca Miklavec},
+%D author={Christopher Creutzig, Henning Hraban Ramm, Mojca Miklavec, Wolfgang Schuster},
%D date=\currentdate,
-%D copyright=Christopher Creutzig]
+%D copyright=the authors]
%C
%C This module is licensed under the GNU GPL.
%D This module serves to include LilyPond music directly in the
%D \CONTEXT\ source, just as \METAPOST\ code can be.
%D
-%D It is supposed to work only with LilyPond's stable version 2.12.
+%D It is supposed to work only with LilyPond's stable version 2.12 and \CONTEXT\ MkIV i.\,e. \LUATEX.
%D
%D {\bfa Complete list of options:}
%D
@@ -33,11 +33,17 @@
%D \NC seriffont\NC "TeX Gyre Schola"\NC font for e.g. lyrics \NC\NR
%D \NC sansfont\NC "LMSans10"\NC font for e.g. chords \NC\NR
%D \NC monofont\NC "LMTypewriter10" \NC normally not used \NC\NR
+%D \NC tmpdir\NC ./lilytemp \NC directory for temporary files \NC\NR
+%D \NC imgdir\NC ./lilypdfs \NC directory for image files (note PDFs) \NC\NR
%D \stoptabulate
%D
-%D TODO: Proper support for multipage results.
+%D {\bfa Todo list}
%D
-%D TODO: LilyPond ---> \CONTEXT.
+%D \startitemize
+%D \item Proper support for multipage results.
+%D \item Set LilyPond page size to remaining page space.
+%D \item Place instrument names in margin.
+%D \stopitemize
%D
%D {\bfa Commented Source}
%D
@@ -48,13 +54,14 @@
\startmodule[lilypond]
\unprotect
-\def\??lily{lilypond-}
+
+\definesystemvariable {lily}
%D Define the text snippets to be placed around fragments.
%D Since LilyPond uses similar syntax to TeX, we must do some catcode fiddling.
-\def\lily!slash{/}
\bgroup
+
\catcode`\/=\@@escape
/catcode`/\=/@@other
/catcode`/#=/@@other
@@ -64,75 +71,78 @@
/catcode`/}=/@@other
/catcode`/%=/@@other
/catcode`/-=/@@letter
-/gdef/lily!fragmentprefix<
-/string^^J
-/string^^J
-{/string^^J
-% ly snippet contents follows:/string^^J
->
-
-/gdef/lily!fragmentsuffix</string^^J
-% end ly snippet/string^^J
-}/string^^J
->
-
-/gdef/lily!prefix</string^^J
-/string^^J
-#(ly:set-option (quote no-point-and-click))/string^^J
-#(ly:set-option (quote delete-intermediate-files))/string^^J
-/string^^J
-\version "2.12.0"/string^^J
-#(define version-seen? #t)/string^^J
-\layout {/string^^J
-/iflily!showempty/else
-% drop empty staves/string^^J
- \context { \RemoveEmptyStaffContext } % MUST come first/string^^J
- \context { \Score \override VerticalAxisGroup #'remove-first = ##t }/string^^J
-/fi
-/string^^J
-/iflily!time/else
-% switch off time signature (i.e. only one line, no bars)/string^^J
- ragged-last = ##t/string^^J
- \context { \Score timing = ##f }/string^^J
- \context { \Staff \remove "Time_signature_engraver" }/string^^J
-/string^^J/fi
-/iflily!barnumbers/else
-% switch off bar numbers/string^^J
- \context { \Score \remove "Bar_number_engraver" }/string^^J
-/fi
-/string^^J
-/iflily!clef/else
-% switch off clef sign/string^^J
- \context { \Staff \remove "Clef_engraver" }/string^^J
-/fi
-/string^^J
- #(define fonts
- (make-pango-font-tree
- /lilypond-seriffont/space
- /lilypond-sansfont/space
- /lilypond-monofont/space
- (/lily!slash/space/lilypond-staffsize/space 20)))/string^^J
-/string^^J
-}/string^^J
-\paper {/string^^J
- #(define dump-extents #t)/string^^J
- ragged-right = /iflily!align ##f/else ##t/fi/string^^J
- indent = /withoutpt/the/lily!indent\pt/string^^J
- line-width = /withoutpt/the/lily!linewidth\pt/string^^J
- vsize = /withoutpt/the/lily!vsize\pt/string^^J
- printpagenumber = ##f/string^^J
- oddFooterMarkup=##f/string^^J
- oddHeaderMarkup=##f/string^^J
- bookTitleMarkup = ##f/string^^J
- scoreTitleMarkup = ##f/string^^J
- ragged-bottom=##t/string^^J
- ragged-last-bottom=##t/string^^J
- between-system-padding = #0/string^^J
- between-system-space = /withoutpt/the/lily!betweensystemspace\pt/string^^J
-}/string^^J
->
-
-/gdef/lily!hash<#>
+
+/gdef/lily!fragmentprefix
+ </string^^J
+ /string^^J
+ {/string^^J
+ % ly snippet contents follows:/string^^J
+ >
+
+/gdef/lily!fragmentsuffix
+ </string^^J
+ % end ly snippet/string^^J
+ }/string^^J
+ >
+
+/gdef/lily!prefix
+ </string^^J
+ /string^^J
+ #(ly:set-option (quote no-point-and-click))/string^^J
+ #(ly:set-option (quote delete-intermediate-files))/string^^J
+ /string^^J
+ \version "2.12.0"/string^^J
+ #(define version-seen? #t)/string^^J
+ \layout {/string^^J
+ /iflily!showempty/else
+ % drop empty staves/string^^J
+ \context { \RemoveEmptyStaffContext } % MUST come first/string^^J
+ \context { \Score \override VerticalAxisGroup #'remove-first = ##t }/string^^J
+ /fi
+ /string^^J
+ /unless/iflily!time
+ % switch off time signature (i.e. only one line, no bars)/string^^J
+ ragged-last = ##t/string^^J
+ \context { \Score timing = ##f }/string^^J
+ \context { \Staff \remove "Time_signature_engraver" }/string^^J
+ /string^^J
+ /fi
+ /unless/iflily!barnumbers
+ % switch off bar numbers/string^^J
+ \context { \Score \remove "Bar_number_engraver" }/string^^J
+ /fi
+ /string^^J
+ /unless/iflily!clef
+ % switch off clef sign/string^^J
+ \context { \Staff \remove "Clef_engraver" }/string^^J
+ /fi
+ /string^^J
+ #(define fonts
+ (make-pango-font-tree
+ /@@lilyseriffont/space
+ /@@lilysansfont/space
+ /@@lilymonofont/space
+ (/letterslash/space/@@lilystaffsize/space 20)))/string^^J
+ /string^^J
+ }/string^^J
+ \paper {/string^^J
+ #(define dump-extents #t)/string^^J
+ ragged-right = /iflily!align ##f/else ##t/fi/string^^J
+ indent = /withoutpt/the/lily!indent\pt/string^^J
+ line-width = /withoutpt/the/lily!linewidth\pt/string^^J
+ vsize = /withoutpt/the/lily!vsize\pt/string^^J
+ printpagenumber = ##f/string^^J
+ oddFooterMarkup=##f/string^^J
+ oddHeaderMarkup=##f/string^^J
+ bookTitleMarkup = ##f/string^^J
+ scoreTitleMarkup = ##f/string^^J
+ ragged-bottom=##t/string^^J
+ ragged-last-bottom=##t/string^^J
+ between-system-padding = #0/string^^J
+ between-system-space = /withoutpt/the/lily!betweensystemspace\pt/string^^J
+ }/string^^J
+ >
+
/egroup
\newdimen\lily!linewidth
@@ -151,168 +161,169 @@
%D that accepts the same parameters as \type{\lilypond} and
%D \type{\startlilypond} do in their optional argument.
-\def\setuplilypond{%
- \start\catcode`\#=\@@other%
- \dosingleempty\dosetuplilypond%
-}
+\def\setuplilypond
+ {\bgroup
+ \catcode`\#=\@@other
+ \dosingleempty\dosetuplilypond}
-\def\dosetuplilypond[#1]{%
- \stop% restore \catcode`\#
- \getparameters[\??lily][#1]%
-}
+\def\dosetuplilypond[#1]%
+ {\egroup
+ \getparameters[\??lily][#1]}
%D We set the following defaults:
+
\setuplilypond
[staffsize=20,
- indent=0pt,
- betweensystemspace=54pt,
- time=\v!yes,
- clef=\v!yes,
- align=?, % default depends on fragment=...
- fragment=\v!no,
- barnumbers=\v!no,
- showshowemptyempty=\v!no,
- seriffont="TeX Gyre Schola", % LilyPond default font
- sansfont="LMSans10",
- monofont="LMTypewriter10",
- ]
-
+ indent=0pt,
+ betweensystemspace=54pt,
+ time=\v!yes,
+ clef=\v!yes,
+ align=?, % default depends on fragment=...
+ fragment=\v!no,
+ barnumbers=\v!no,
+ showempty=\v!no,
+ seriffont="TeX Gyre Schola", % LilyPond default font
+ sansfont="LMSans10",
+ monofont="LMTypewriter10",
+ tmpdir={./lilytemp},
+ imgdir={./lilypdfs}]
+%D
%D If you want to know which fonts of your system LilyPond can see
%D with which names, try \type{lilypond -dshow-available-fonts any}.
%D (The 3rd parameter is necessary, but can be anything.)
%D There are a lot of restrictions, e.g. no fonts from the \TeX\ tree (don't know why),
%D only one face per font file etc.
-
+%D
%D \type{\startlilypond} is a multistage implementation, because
%D end-of-line characters must be treated specially in the
%D \type{\startlilypond}\textellipsis\type{\stoplilypond} range.
-\def\startlilypond{%
- \bgroup%
- \catcode`\#=\@@other%
- \dosingleempty\dostartlilypond%
-}
+%D
-\def\dostartlilypond[#1]{%
- \obeylines%
- \dodostartlilypond[{#1}]%
-}
+\def\tmpdir{\@@lilytmpdir} % for intermediate files
+\def\imgdir{\@@lilyimgdir} % for music PDFs
-\long\def\dodostartlilypond[#1]#2\stoplilypond{%
- \egroup% from \startlilypond
- \bgroup%
-%D The default of the \type{linewidth} parameter is the local \type{\hsize}.
- \setlocalhsize
- \getparameters[\??lily][linewidth=\the\localhsize,height=\the\textheight,#1]%
- \lily!linewidth\dimexpr\getvalue{\??lily linewidth}\relax
- \lily!vsize\dimexpr\getvalue{\??lily height}\relax
- \lily!indent\dimexpr\getvalue{\??lily indent}\relax
- \lily!betweensystemspace\dimexpr\getvalue{\??lily betweensystemspace}\relax
-%D The default of \type{align} depends on whether we typeset a fragment:
- \@EAEAEA\doifelse\getvalue{\??lily align}{\v!yes}%
- \lily!aligntrue\lily!alignfalse
- \@EAEAEA\doif\getvalue{\??lily fragment}{\v!no}{%
- \@EAEAEA\doif\getvalue{\??lily align}?
- \lily!aligntrue
- }%
- \@EAEAEA\doifelse\getvalue{\??lily time}\v!yes
- \lily!timetrue\lily!timefalse
- \@EAEAEA\doifelse\getvalue{\??lily barnumbers}\v!yes
- \lily!barnumberstrue\lily!barnumbersfalse
- \@EAEAEA\doifelse\getvalue{\??lily showempty}\v!yes
- \lily!showemptytrue\lily!showemptyfalse
- \@EAEAEA\doifelse\getvalue{\??lily clef}\v!yes
- \lily!cleftrue\lily!cleffalse
+%D
+%D Check if temporary and image directories exist and create them if not:
+%D
+\startluacode
+ if not lfs.isdir("\tmpdir") then
+ logs.report("LilyPond Warn ", "Temporary directory not found, trying to make '\tmpdir'")
+ lfs.mkdir("\tmpdir")
+ end
+ if not lfs.isdir("\imgdir") then
+ logs.report("LilyPond Warn ", "Image directory not found, trying to make '\imgdir'")
+ lfs.mkdir("\imgdir")
+ end
+\stopluacode
+
+
+\def\startlilypond
+ {\bgroup
+ \catcode`\#=\@@other
+ \dosingleempty\dostartlilypond}
+
+\def\dostartlilypond[#1]%
+ {\obeylines
+ \dodostartlilypond[#1]}
+
+\long\def\dodostartlilypond[#1]#2\stoplilypond
+ {\egroup
+ \bgroup
+ %D The default of the \type{linewidth} parameter is the local \type{\hsize}.
+ \setlocalhsize
+ \getparameters[\??lily][linewidth=\the\localhsize,height=\the\textheight,#1]%
+ \lily!linewidth\@@lilylinewidth
+ \lily!vsize\@@lilyheight
+ \lily!indent\@@lilyindent
+ \lily!betweensystemspace\@@lilybetweensystemspace
+ %D The default of \type{align} depends on whether we typeset a fragment:
+ \doifelse\@@lilyalign\v!yes\lily!aligntrue\lily!alignfalse
+ \doif\@@lilyfragment\v!no{\doif\@@lilyalign{?}\lily!aligntrue}%
+ \doifelse\@@lilytime\v!yes\lily!timetrue\lily!timefalse
+ \doifelse\@@lilybarnumbers\v!yes\lily!barnumberstrue\lily!barnumbersfalse
+ \doifelse\@@lilyshowempty\v!yes\lily!showemptytrue\lily!showemptyfalse
+ \doifelse\@@lilyclef\v!yes\lily!cleftrue\lily!cleffalse
+%D
%D We are using a counter to keep the different LilyPond pieces
%D separate. This allows to typeset them only once, during the
%D first run.
%D
%D TODO: This won't work any longer once we pass the remaining
%D vertical space to LilyPond.
- %\global\advance\lily!figures\plusone
- \doglobal\increment\lily!figures
- \edef\lily!filename{\bufferprefix lilypond-\lily!figures}%\the
- %\writestatus{buffering}{\lily!filename}
- %\startmode[*\v!first]%
- \def\obeyedlines{\string^^J}%
- \convertargument#2\to\ascii
- \expanded{%
- \setbuffer[lilypond-\lily!figures]%\the
- \lily!prefix
- \lily!hash(set-global-staff-size \getvalue{\??lily staffsize})\string^^J%
- \ifundefined{\??lily fragment}\else\lily!fragmentprefix\fi
- %% TODO: Option "packed"
- \ascii%
- \ifundefined{\??lily fragment}\else\lily!fragmentsuffix\fi
- }% expanded
- \endbuffer%
+%D
+ \doglobal\increment\lily!figures
+ \edef\lily!filename{\bufferprefix lilypond-\lily!figures}%
+ \edef\lily!tmpfilename{\tmpdir/\bufferprefix lilypond-\lily!figures}%
+ \edef\lily!img{\imgdir/\lily!filename.pdf}
+ \def\obeyedlines{\string^^J}%
+ \convertargument#2\to\ascii
+ \startexpanded
+ \noexpand\setbuffer[lilypond-\lily!figures]%
+ \lily!prefix
+ \letterhash(set-global-staff-size \getvalue{\??lily staffsize})\string^^J%
+ \ifdefined\@@lilyfragment\lily!fragmentprefix\fi
+ %% TODO: Option "packed"
+ \ascii
+ \ifdefined\@@lilyfragment\lily!fragmentsuffix\fi
+ \noexpand\endbuffer
+ \stopexpanded
%D
%D Generating a PDF directly always creates a whole page, so we generate EPS first.
-
- %\def\LP{texmfstart --ifchanged="\lily!filename.tmp" --exec bin:lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts -ddelete-intermediate-files "\lily!filename.tmp"}
- \def\LP{mtxrun --ifchanged="\lily!filename.tmp" --exec bin:lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts -ddelete-intermediate-files "\lily!filename.tmp"}
- %\def\LP{lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts -ddelete-intermediate-files "\lily!filename.tmp"}
-
+%D
+ \def\LP{mtxrun --ifchanged="\lily!tmpfilename.tmp" --exec bin:lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts -ddelete-intermediate-files -o"\lily!tmpfilename" "\lily!tmpfilename.tmp"}
%D
%D It would be nice, if \type{-ddelete-intermediate-files} would delete all useless intermediate files.
-%D More possible options in \type{lily.scm}.
- \def\PDF{mtxrun --ifchanged="\lily!filename.eps" pstopdf "\lily!filename.eps"}
-
-%D The following line is needed for Lua\TeX, where buffers are kept in memory
-%D in contrast to other (older) flavours of \TeX\ where they're written to a
+%D
+%D Remember: More possible options in \type{lily.scm}.
+%D
+ \def\PDF{mtxrun --ifchanged="\lily!tmpfilename.eps" pstopdf "\lily!tmpfilename.eps"}
+%D
+%D In Lua\TeX buffers are kept in memory
+%D in contrast to older flavours of \TeX\ where they're written to a
%D file automatically. We have to require writing to a file explicitely
%D with \type{\savebuffer}.
%D
-%D There were rumors that \LUATEX\ would drop \type{\savebuffer}, so we would need to re-define it:
-%D \starttyping
-%D \def\savebuffer{\dosingleempty\dosavebuffer}
-%D \def\dosavebuffer[#1]{\ctxlua{buffers.save("#1")}}
-%D \stoptyping
-
-
- \ifx\directlua\undefined \else \savebuffer[lilypond-\lily!figures]\fi
-
+%D That applies \type{\bufferprefix} automatically, so we can't directly write to our temp directory.
+%D
+ \ctxlua{ buffers.save("lilypond-\lily!figures") }
+ \directlua{ os.rename('\lily!filename.tmp', '\tmpdir/\lily!filename.tmp') }
\writestatus{LilyPond}{\lily!filename}
- %\writestatus{LilyPond}{\LP}
- \executesystemcommand{\LP}%
- \doif\jobsuffix{pdf}{%
- \executesystemcommand{\PDF}%
- }%
- \doifelse\jobsuffix{pdf}
- {\def\lily!img{\lily!filename .pdf}}%
- {\def\lily!img{\lily!filename .eps}}%
-
+ \executesystemcommand{\LP} % compile LilyPond
+ \executesystemcommand{\PDF} % convert EPS to PDF
+ \directlua{ os.rename('\lily!tmpfilename.pdf', '\lily!img') }
+%D
%D TODO: Get the relevant dimension directly from LilyPond,
%D to place the instrument name into the left margin for
-%D short snippets as well.
+%D short snippets as well. (Is that possible at all?)
%D
%D If we are not in the middle of some text, we have to check
%D whether LilyPond created an image that is wider than requested:
%D It places the instrument names in the left margin.
%D
- \ifvmode
- \getfiguredimensions[\lily!filename.pdf]%
- \leavevmode%
- \newdimen\FigWidth
- \FigWidth=\figurewidth
- \ifdim\FigWidth>\localhsize
- \!!dimena=\localhsize
- \advance\!!dimena by-\FigWidth
- \noindent\hskip\!!dimena
- \fi
- \fi
- \externalfigure[\lily!img]%
- \egroup%
-}%
+ \ifvmode
+ \getfiguredimensions[\lily!img]%
+ \leavevmode
+ \!!dimenb\figurewidth
+ \ifdim\!!dimenb>\localhsize
+ \!!dimena=\localhsize
+ \advance\!!dimena-\!!dimenb
+ \noindent\hskip\!!dimena
+ \fi
+ \fi
+ \externalfigure[\lily!img]%
+ \egroup}
%D For short snippets, we define an inline alternative to
%D our start/stop pair:
-\def\lilypond{\dosingleempty\dolilypond}
+\def\lilypond {\dosingleempty\dolilypond}
\def\dolilypond[#1]#2{\startlilypond[#1]#2\stoplilypond}
\stopmodule
\protect \doifnotmode{demo}{\endinput}
+
+
%D End of file
\starttext
@@ -364,4 +375,39 @@ It is also possible to mix text and music:
TODO: The \type{\lower} in the example above should not be necessary.
-\stoptext \ No newline at end of file
+\subject{Starlight (round)}
+
+Here is a sample with lyrics:
+
+\startlilypond
+<<
+\context Staff = onlyone <<
+ \clef treble
+ \key a \major
+ \time 6/8
+ \context Voice = one {
+ \relative c'' {
+ a4.^\markup{1.} e' |
+ e8( d cis) b4. |
+ e4.^\markup{2.} d4 d8 |
+ cis( b) a b4 e,8 |
+ a4 a8 gis( a) b |
+ cis4 cis8 b( cis d) |
+ cis( d) e e4 e,8 |
+ fis4 fis8 gis4.
+ }
+ }
+>>
+\lyricsto one \new Lyrics {
+ \lyricmode {
+ Star -- light, star -- bright,
+ first star I see to -- night;
+ I wish I may, I wish I might
+ have the wish I wish to -- night.
+ }
+}
+>>
+
+\stoplilypond
+
+\stoptext
diff --git a/Master/tlpkg/tlpsrc/xmltex.tlpsrc b/Master/tlpkg/tlpsrc/xmltex.tlpsrc
index 095645da319..64619600d11 100644
--- a/Master/tlpkg/tlpsrc/xmltex.tlpsrc
+++ b/Master/tlpkg/tlpsrc/xmltex.tlpsrc
@@ -1,9 +1,7 @@
depend pdftex
depend tex
-execute AddFormat name=xmltex engine=pdftex patterns=language.dat \
- options="&latex xmltex.ini"
-execute AddFormat name=pdfxmltex engine=pdftex patterns=language.dat \
- options="&pdflatex pdfxmltex.ini"
+execute AddFormat name=xmltex engine=pdftex patterns=language.dat options="&latex xmltex.ini"
+execute AddFormat name=pdfxmltex engine=pdftex patterns=language.dat options="&pdflatex pdfxmltex.ini"
srcpattern +!d texmf-dist/source/xmltex/xmlplay
runpattern d texmf-dist/tex/xmltex/base
runpattern d texmf-dist/tex/xmltex/config