From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/50992 Path: news.gmane.org!not-for-mail From: Henning Hraban Ramm Newsgroups: gmane.comp.tex.context Subject: Re: Cannot run Lilypond Date: Wed, 3 Jun 2009 13:37:58 +0200 Message-ID: <032C9E9E-32B2-4B72-986F-5CFD77AACFB7@fiee.net> References: <4A25444D.7090104@gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v935.3) Content-Type: multipart/mixed; boundary=Apple-Mail-8--566094034 X-Trace: ger.gmane.org 1244029128 27758 80.91.229.12 (3 Jun 2009 11:38:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 3 Jun 2009 11:38:48 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Jun 03 13:38:45 2009 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 1MBons-0001Ay-Hp for gctc-ntg-context-518@m.gmane.org; Wed, 03 Jun 2009 13:38:44 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 59DB11FDE2; Wed, 3 Jun 2009 13:38:42 +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 08262-02; Wed, 3 Jun 2009 13:38:11 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id CBD381FD7B; Wed, 3 Jun 2009 13:38:10 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 60DB11FD7B for ; Wed, 3 Jun 2009 13:38:09 +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 08026-03-2 for ; Wed, 3 Jun 2009 13:38:00 +0200 (CEST) Original-Received: from filter2-nij.mf.surf.net (filter2-nij.mf.surf.net [195.169.124.153]) by ronja.ntg.nl (Postfix) with ESMTP id C79581FD72 for ; Wed, 3 Jun 2009 13:38:00 +0200 (CEST) Original-Received: from turan.fiee.net (lvps87-230-77-106.dedicated.hosteurope.de [87.230.77.106]) by filter2-nij.mf.surf.net (8.13.8/8.13.8/Debian-3) with ESMTP id n53Bbxvn012380 for ; Wed, 3 Jun 2009 13:38:00 +0200 Original-Received: from turan.fiee.net (lvps87-230-77-106.dedicated.hosteurope.de [127.0.0.1]) by turan.fiee.net (Postfix) with ESMTP id 0310B18E08028 for ; Wed, 3 Jun 2009 13:37:58 +0200 (CEST) Received-SPF: neutral (lvps87-230-77-106.dedicated.hosteurope.de: 79.207.35.185 is neither permitted nor denied by domain of fiee.net) client-ip=79.207.35.185; envelope-from=hraban@fiee.net; helo=[192.168.23.150]; Original-Received: from [192.168.23.150] (p4FCF23B9.dip0.t-ipconnect.de [79.207.35.185]) by turan.fiee.net (Postfix) with ESMTP for ; Wed, 3 Jun 2009 13:37:58 +0200 (CEST) In-Reply-To: <4A25444D.7090104@gmail.com> X-Mailer: Apple Mail (2.935.3) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=87.230.77.106; country=DE; region=07; city=Host; latitude=51.6500; longitude=6.1833; http://maps.google.com/maps?q=51.6500,6.1833&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 236597662 - f66b8447e7dd - 20090603 X-Scanned-By: CanIt (www . roaringpenguin . com) on 195.169.124.153 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.11 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:50992 Archived-At: --Apple-Mail-8--566094034 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Am 2009-06-02 um 17:25 schrieb Vyatcheslav Yatskovsky: > I can run Lilypond from command line from any location. > > Also, I can run pstopdf, but the fact is that i didn't install > GhostScript. But I'm not sure if it works, bacause when I run it it > says nothing and exits. pstopdf is part of the ConTeXt distribution and should give you something like: hraban$ pstopdf PsToPdf | version 2.0.1 - 2002-2006 - PRAGMA ADE/POD PsToPdf | --convert convert ps into pdf PsToPdf | --request handles exa request file PsToPdf | --watch watch folders for conversions (untested) > When I compile my Lily example, lily1-lilypond-1.tmp is created in > both document dir and lilytemp subfolder. But lilypdfs remains empty. Don't you get anything else, esp. EPS files? Then LilyPond isn't run. I don't know how to check for that OS-independently in my module. Please try the attached latest version. Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://wiki.contextgarden.net https://www.cacert.org (I'm an assurer) --Apple-Mail-8--566094034 Content-Disposition: attachment; filename=t-lilypond.tex Content-Type: application/x-tex; x-unix-mode=0600; x-mac-type=54455854; name="t-lilypond.tex" Content-Transfer-Encoding: 7bit %D \module %D [ file=t-lilypond, %D version=2009.06.03, %D title=\CONTEXT\ User Modules, %D subtitle=LilyPond Bridge (Music Typesetting), %D author={Christopher Creutzig, Henning Hraban Ramm, Mojca Miklavec, Wolfgang Schuster}, %D maintainer={Henning Hraban Ramm, hraban@fiee.net}, %D date=\currentdate, %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 and \CONTEXT\ MkIV i.\,e. \LUATEX. %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 14\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 whole staff line or only snippet? \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 "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 {\bfa Todo list} %D %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 \item Work with existing PDFs on systems where LilyPond isn't installed. %D \stopitemize %D %D {\bfa Commented Source} %D %D As usual, we use a prefix for buffers, \type{\getparameters} etc.: \writestatus{loading}{LilyPond module} \startmodule[lilypond] \unprotect \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. \bgroup \catcode`\/=\@@escape /catcode`/\=/@@other /catcode`/#=/@@other /catcode`/<=/@@begingroup /catcode`/>=/@@endgroup /catcode`/{=/@@other /catcode`/}=/@@other /catcode`/%=/@@other /catcode`/-=/@@letter /gdef/lily!fragmentprefix /gdef/lily!fragmentsuffix /gdef/lily!prefix /egroup \newdimen\lily!linewidth \newdimen\lily!vsize \newdimen\lily!indent \newdimen\lily!betweensystemspace \newif\iflily!showempty \newif\iflily!align \newif\iflily!clef \newif\iflily!time \newif\iflily!barnumbers \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 {\bgroup \catcode`\#=\@@other \dosingleempty\dosetuplilypond} \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, 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. %D \def\tmpdir{\@@lilytmpdir} % for intermediate files \def\imgdir{\@@lilyimgdir} % for music PDFs %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. %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 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 That applies \type{\bufferprefix} automatically, so we can't directly write to our temp directory. %D %D At least on Windows, Lua's os.rename won't overwrite existing files, so we need to remove them before. %D %D \writestatus{LilyPond}{\lily!filename} \startluacode buffers.save('lilypond-\lily!figures') if not lfs.isfile('\lily!filename.tmp') then logs.report("LilyPond ERROR", "File '\lily!filename.tmp' was not written!") else if lfs.isfile('\tmpdir/\lily!filename.tmp') then os.remove('\tmpdir/\lily!filename.tmp') end os.rename('\lily!filename.tmp', '\tmpdir/\lily!filename.tmp') end %D %D Generating a PDF directly always creates a whole page, so we generate EPS first. %D %D It would be nice, if \type{-ddelete-intermediate-files} would delete all useless intermediate files. %D It would be even better, if mtxrun wouldn't declare non-existing files as \quotation{unchanged}. %D %D Remember: More possible options in \type{lily.scm}. %D os.execute('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"') os.execute('mtxrun --ifchanged="\lily!tmpfilename.eps" --exec bin:pstopdf "\lily!tmpfilename.eps"') if lfs.isfile('\lily!img') and lfs.isfile('\lily!tmpfilename.pdf') then os.remove('\lily!img') end os.rename('\lily!tmpfilename.pdf', '\lily!img') \stopluacode %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. (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!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\dolilypond[#1]#2{\startlilypond[#1]#2\stoplilypond} \stopmodule \protect \doifnotmode{demo}{\endinput} %D End of file \starttext \startbuffer[sample] \subject{Telemann, TWV 40:11} \startlilypond \relative c' { \set Staff.instrumentName = flute \key fis \minor \time 3/4 \partial 4 r8 fis'8 | fis4. cis8 a cis | fis, a cis fis a fis | b, d fis b d b | eis,, gis cis eis gis b, | a fis' gis, fis' cis eis | fis,4 r8 a' gis fis | e gis, a e' fis cis | d fis, gis b e d | cis4 \trill r8 cis b a | b dis e gis cis, b | a e' dis fis b, a | gis4 \trill r8 } \stoplilypond \stopbuffer The input \typebuffer[sample] is typeset as \getbuffer[sample] \type{\startlilypond} accepts options, as in\crlf \type{\startlilypond[staffsize=24, linewidth=14cm, indent=5cm, time=no, clef=no]}: \nobreak \startlilypond[staffsize=18,linewidth=14cm,indent=5cm,time=no,clef=no] \relative c' { \key fis \minor \time 3/4 \partial 4 r8 fis'8 | fis4. cis8 a cis | fis, a cis fis a fis | b, d fis b d b | eis,, gis cis eis gis b, | a fis' gis, fis' cis eis | fis,4 r8 a' gis fis | e gis, a e' fis cis | d fis, gis b e d | cis4 \trill r8 cis b a | b dis e gis cis, b | a e' dis fis b, a | gis4 \trill r8 } \stoplilypond It is also possible to mix text and music: \lower 8.2pt\hbox{\lilypond[fragment=true,staffsize=16,time=no,clef=no]{g'}} is a g. TODO: The \type{\lower} in the example above should not be necessary. \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 --Apple-Mail-8--566094034 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-8--566094034--