From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/35342 Path: news.gmane.org!not-for-mail From: Henning Hraban Ramm Newsgroups: gmane.comp.tex.context Subject: Re: lilypond Date: Fri, 6 Jul 2007 22:25:05 +0200 Message-ID: <7F1631B9-8C3B-430D-A1C9-2B4EA842CFA2@fiee.net> References: <468A8E78.23950.111C4FD@wwl.musensturm.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: multipart/mixed; boundary=Apple-Mail-2--712124146 X-Trace: sea.gmane.org 1183753543 726 80.91.229.12 (6 Jul 2007 20:25:43 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 6 Jul 2007 20:25:43 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Jul 06 22:25:40 2007 connect(): Connection refused Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1I6uN0-0000Ag-V4 for gctc-ntg-context-518@m.gmane.org; Fri, 06 Jul 2007 22:25:39 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 19390202F7; Fri, 6 Jul 2007 22:25:38 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 20006-01; Fri, 6 Jul 2007 22:25:22 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 500BF202DC; Fri, 6 Jul 2007 22:25:20 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 9D3C4202DC for ; Fri, 6 Jul 2007 22:25:17 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 17119-05 for ; Fri, 6 Jul 2007 22:25:10 +0200 (CEST) Original-Received: from lvps87-230-27-118.dedicated.hosteurope.de (lvps87-230-27-118.dedicated.hosteurope.de [87.230.27.118]) by ronja.ntg.nl (Postfix) with ESMTP id 7F0D8202DA for ; Fri, 6 Jul 2007 22:25:09 +0200 (CEST) Original-Received: (qmail 25845 invoked from network); 6 Jul 2007 22:25:08 +0200 Original-Received: from 33.202.203.62.cust.bluewin.ch (HELO ?10.128.9.3?) (62.203.202.33) by lvps87-230-27-118.dedicated.hosteurope.de with SMTP; 6 Jul 2007 22:25:08 +0200 In-Reply-To: <468A8E78.23950.111C4FD@wwl.musensturm.de> X-Mailer: Apple Mail (2.752.2) X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:35342 Archived-At: --Apple-Mail-2--712124146 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Am 2007-07-03 um 17:59 schrieb Wolfgang Werners-Lucchini: > I tryed the first wiki-example: > -------------------------------- > There are some notes \lilypond{ \relative{bes a c b} } embedded in > this line. > -------------------------------- > > With version 2.11.27 the lilypond option -b eps is unknown. > With version 2.10.25 the above example is a 3-page output: > (1) There are some notes > (2) lilypond-output > (3) embedded in this line > > Should I downgrad with lilypond? > Or what else I am doing wrong? Sorry, the publicly available LilyPond module is outdated. Try the attached one. I delayed the publishing of my latest version because Ruby texexec had a bug that prevented lilypond from being called, I guess that's gone, but I had no time to check yet. And I didn't adapt the module to LilyPond 2.11, too. (2.10.2x should work.) I don't know if inline LilyPond worked at any time, though; I never needed it. Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://wiki.contextgarden.net https://www.cacert.org (I'm an assurer) --Apple-Mail-2--712124146 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-mac-type=54455854; x-unix-mode=0600; x-mac-creator=54655873; name=t-lilypond.tex Content-Disposition: attachment; filename=t-lilypond.tex %D \module %D [ file=t-lilypond, %D version=2007.05.23, %D title=\CONTEXT\ User Modules, %D subtitle=LilyPond Connections (Music Typesetting), %D author={Christopher Creutzig \& Henning Hraban Ramm}, %D date=\currentdate, %D copyright=Christopher Creutzig] %C %C This module is in the public domain. %M \usemodule[lilypond] %D This module serves to include LilyPond music directly in the %D \CONTEXT\ source, just as \METAPOST\ code can be. %D It should work from LilyPond version 2.8, but you should always use %D the latest stable version of LilyPond (this is tested with 2.10.23). %D Before starting with the implementation, one or two examples are in order. %D %D \startbuffer[sample] %D % Telemann, TWV 40:11 %D \startlilypond %D \relative c' { %D \set Staff.instrumentName = flute %D \key fis \minor %D \time 3/4 %D \partial 4 %D %D r8 fis'8 | fis4. cis8 a cis | fis, a cis fis a fis | %D b, d fis b d b | eis,, gis cis eis gis b, | %D a fis' gis, fis' cis eis | fis,4 r8 %D a' gis fis | e gis, a e' fis cis | %D d fis, gis b e d | cis4 \trill r8 %D cis b a | b dis e gis cis, b | %D a e' dis fis b, a | gis4 \trill r8 %D } %D \stoplilypond %D \stopbuffer %D %D The input %D %D \typebuffer[sample] %D %D is typeset as %D %D \getbuffer[sample] %D %D \type{\startlilypond} accepts options, as in\crlf %D \type{\startlilypond[staffsize=24, linewidth=14cm, indent=5cm, time=no,clef=no]}: %D %D \nobreak %D \startlilypond[staffsize=24,linewidth=14cm,indent=5cm,time=no,clef=no] %D %\version "2.10.23" % not necessary, the module adds a version statement %D \relative c' { %D %\set Staff.instrumentName = flute %D \key fis \minor %D \time 3/4 %D \partial 4 %D r8 fis'8 | fis4. cis8 a cis | fis, a cis fis a fis | %D b, d fis b d b | eis,, gis cis eis gis b, | %D a fis' gis, fis' cis eis | fis,4 r8 %D a' gis fis | e gis, a e' fis cis | %D d fis, gis b e d | cis4 \trill r8 %D cis b a | b dis e gis cis, b | %D a e' dis fis b, a | gis4 \trill r8 %D } %D \stoplilypond %D %D It is also possible to mix text and music: %D \lower 8.2pt\hbox{\lilypond[fragment=true,staffsize=16,time=no]{g'}} is a g. %D %D {\bfa Complete list of options:} %D %D \starttabulate[|l|l|l|] %D \NC option\NC default\NC comment\NC\NR %D \HL %D \NC staffsize\NC 20\NC in pt \NC\NR %D \NC indent\NC 0pt\NC first line indent \NC\NR %D \NC time\NC yes\NC count time? (i.e. show time signature, set bars, split line) \NC\NR %D \NC clef\NC yes\NC show clef? \NC\NR %D \NC linewidth\NC \\localhsize\NC \NC\NR %D \NC betweensystemspace\NC 54pt\NC space between systems \NC\NR %D \NC height\NC \\textheight\NC \NR %D \NC align\NC ?\NC default depends on fragment=... \NC\NR %D \NC fragment\NC no\NC \NC\NR %D \NC barnumbers\NC no\NC show numbers of measures? \NC\NR %D \NC showempty\NC no\NC drop empty staves? \NC\NR %D \NC seriffont\NC "Century Schoolbook L"\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 "Courier" \NC normally not used \NC\NR %D \stoptabulate %D %D TODO: The \type{\lower} in the example above should not be necessary. %D %D TODO: Proper support for multipage results. %D %D TODO: lilypond ---> \CONTEXT. %D %D \page %D Now for the implementation. As usual, we use a prefix for buffers, %D \type{\getparameters} etc.: \writestatus{loading}{LilyPond module} \startmodule[lilypond] \unprotect \def\??lily{lilypond-} %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 /catcode`/<=/@@begingroup /catcode`/>=/@@endgroup /catcode`/{=/@@other /catcode`/}=/@@other /catcode`/%=/@@other /catcode`/-=/@@letter /gdef/lily!fragmentprefix< /string^^J /string^^J {/string^^J % ly snippet contents follows:/string^^J > /gdef/lily!fragmentsuffix /gdef/lily!prefix /gdef/lily!hash<#> /egroup \newdimen\lily!linewidth \newdimen\lily!vsize \newdimen\lily!indent \newdimen\lily!betweensystemspace \newif\iflily!align \newif\iflily!clef \newif\iflily!time \newif\iflily!barnumbers \newif\iflily!showempty \newcounter\lily!figures %D Again, as usual, there is a \type{\setuplilypond} command %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\dosetuplilypond[#1]{% \stop% restore \catcode`\# \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="Century Schoolbook L", % LilyPond default font sansfont="LMSans10", monofont="Bitstream Vera Sans Mono", ] %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 \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{% \dosingleempty\dostartlilypond% } \def\dostartlilypond[#1]{% \bgroup% \obeylines% \catcode`\#=\@@other% \dodostartlilypond[{#1}]% } \def\doprocesslilypond#1{% \edef\LPFN{#1}% \writestatus{DEBUG-w18}{\LPFN}% \installprogram{texmfstart --ifchanged=\LPFN.tmp --exec bin:lilypond -b eps -dno-gs-load-fonts -dinclude-eps-fonts \LPFN.tmp}% \doif\jobsuffix{pdf}{% \installprogram{texmfstart --ifchanged=\LPFN.eps pstopdf \LPFN.eps}% }% } \long\def\dodostartlilypond[#1]#2\stoplilypond{% \egroup% from \dostartlilypond \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 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 \def\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 Generating a PDF directly always creates a whole page, so we generate EPS first. %D %D If \type{\ifeof18} creates an error for you, your pdfe\TeX\ is too old. %D just change it to \type{\iftrue} then. %D (\type{\ifeof18} checks whether \type{\write18} is disabled.) %\def\LP{echo LILYPOND \lily!filename.tmp} %\def\PDF{echo PStoPDF \lily!filename.eps} \edef\LP{texmfstart --ifchanged=\lily!filename .tmp --exec bin:lilypond -b eps -dno-gs-load-fonts -dinclude-eps-fonts \lily!filename .tmp} \edef\PDF{texmfstart --ifchanged=\lily!filename .eps pstopdf \lily!filename .eps} %\doprocesslilypond{\lily!filename} \ifeof18 \writestatus{DEBUG-w18}{\LP}% \expanded{\installprogram{\LP}}% \doif\jobsuffix{pdf}{% \installprogram{\PDF}% }% \else \writestatus{DEBUG-EXE}{\LP}% \executesystemcommand{\LP}% \doif\jobsuffix{pdf}{% \executesystemcommand{\PDF}% }% \fi %\stopmode% only first run \doifelse\jobsuffix{pdf} {\def\lily!img{\lily!filename .pdf}}% {\def\lily!img{\lily!filename .eps}}% %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 %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% }% %D For short snippets, we define an inline alternative to %D our start/stop pair: \def\lilypond{\dosingleempty\dolilypond} \def\dolilypond[#1]#2{\startlilypond[#1]#2\stoplilypond} \stopmodule \protect %D End of file --Apple-Mail-2--712124146 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-2--712124146 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --Apple-Mail-2--712124146--