Dear devs,

Please have a look at the attached, an updated patch to provide lilypond-book support: Inclusion of lilypond code directly in LyX. This is done with a module with OutputFormat keyword and (at the moment) a simple inset. The preview mechanism is extended to allow for musical snippets to be previewable. An example file is included.

Since I am not a lilypond user, further development on this module will rely on having this in the beta, if possible, and having users and devs provide early feedback.

On the todo list are xhtml output and docbook support.

Thanks,
Cheers,
Julien
Index: src/graphics/PreviewLoader.cpp
===================================================================
--- src/graphics/PreviewLoader.cpp      (revision 35466)
+++ src/graphics/PreviewLoader.cpp      (working copy)
@@ -388,12 +388,12 @@
 PreviewLoader::Impl::Impl(PreviewLoader & p, Buffer const & b)
        : parent_(p), buffer_(b)
 {
-       if (!pconverter_){
-               if (b.params().encoding().package() == Encoding::japanese)
-                       pconverter_ = setConverter("lyxpreview-platex");
-               else
-                       pconverter_ = setConverter("lyxpreview");
-       }
+       if (b.bufferFormat() == "lilypond-book")
+               pconverter_ = setConverter("lyxpreview-lytex");
+       else if (b.params().encoding().package() == Encoding::japanese)
+               pconverter_ = setConverter("lyxpreview-platex");
+       else
+               pconverter_ = setConverter("lyxpreview");
 }
 
 
Index: lib/scripts/lyxpreview-lytex2bitmap.py
===================================================================
--- lib/scripts/lyxpreview-lytex2bitmap.py      (revision 35036)
+++ lib/scripts/lyxpreview-lytex2bitmap.py      (working copy)
@@ -1,7 +1,7 @@
 #! /usr/bin/env python
 # -*- coding: utf-8 -*-
 
-# file lyxpreview2bitmap.py
+# file lyxpreview-lytex2bitmap.py
 # This file is part of LyX, the document processor.
 # Licence details can be found in the file COPYING.
 
@@ -28,7 +28,7 @@
 # CTAN/support/preview-latex/
 
 # Example usage:
-# lyxpreview2bitmap.py png 0lyxpreview.tex 128 000000 faf0e6
+# lyxpreview-lytex2bitmap.py png 0lyxpreview.tex 128 000000 faf0e6
 
 # This script takes six arguments:
 # FORMAT:   The desired output format. Either 'png' or 'ppm'.
@@ -46,7 +46,7 @@
 # * a file BASE.metrics, containing info needed by LyX to position
 #   the images correctly on the screen.
 
-import glob, os, re, string, sys
+import glob, os, re, shutil, string, sys
 
 from legacy_lyxpreview2ppm import legacy_conversion, \
      legacy_conversion_step2
@@ -177,6 +177,20 @@
     else:
         latex = find_exe_or_terminate(["latex", "pplatex", "platex", 
"latex2e"], path)
 
+    lilypond_book = find_exe_or_terminate(["lilypond-book"], path)
+
+    # Make a copy of the latex file
+    lytex_file = latex_file_re.sub(".lytex", latex_file)
+    shutil.copyfile(latex_file, lytex_file)
+
+    # Preprocess the latex file through lilypond-book.
+    lytex_call = '%s --latex-program=%s "%s"' % (lilypond_book, latex, 
lytex_file)
+    lytex_status, lytex_stdout = run_command(lytex_call)
+    if lytex_status != None:
+        warning("%s failed to compile %s" \
+              % (os.path.basename(lilypond_book), lytex_file))
+        warning(lytex_stdout)
+
     # This can go once dvipng becomes widespread.
     dvipng = find_exe(["dvipng"], path)
     if dvipng == None:
@@ -201,6 +215,7 @@
     if latex_status != None:
         warning("%s failed to compile %s" \
               % (os.path.basename(latex), latex_file))
+        warning(latex_stdout)
 
     if latex == "xelatex":
         warning("Using XeTeX")
Index: lib/layouts/lilypond.module
===================================================================
--- lib/layouts/lilypond.module (revision 0)
+++ lib/layouts/lilypond.module (revision 0)
@@ -0,0 +1,32 @@
+#\DeclareLyXModule[lilypond-book->latex]{LilyPond Book}
+#DescriptionBegin
+#This module adds an inset to enter LilyPond code directly into LyX.
+#It will be processed in the output. See the lilypond.lyx example file.
+#DescriptionEnd
+
+# Author: Julien Rioux <jri...@physics.utoronto.ca>
+
+Format                 27
+OutputFormat           lilypond-book
+
+InsetLayout LilyPond
+       LabelString           LilyPond
+       LaTeXType             Environment
+       LaTeXName             lilypond
+       LyXType               Custom
+       Decoration            Classic
+       Font
+         Color               latex
+         Family              typewriter
+       EndFont
+       LabelFont
+         Color               latex
+         Size                Small
+       EndFont
+       MultiPar              true
+       CustomPars            false
+       ForcePlain            true
+       FreeSpacing           true
+       PassThru              true
+       ForceLTR              true
+End

Property changes on: lib/layouts/lilypond.module
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Index: lib/configure.py
===================================================================
--- lib/configure.py    (revision 35466)
+++ lib/configure.py    (working copy)
@@ -505,6 +505,7 @@
 \Format literate   nw      NoWeb                  N  ""        "%%"    
"document"
 \Format sweave     Rnw    "Sweave"                S  "" "%%"    "document"
 \Format lilypond   ly     "LilyPond music"        "" ""        "%%"    "vector"
+\Format lilypond-book    lytex "LilyPond book (LaTeX)"   "" "" "%%"    
"document"
 \Format latex      tex    "LaTeX (plain)"         L  ""        "%%"    
"document"
 \Format pdflatex   tex    "LaTeX (pdflatex)"      "" ""        "%%"    
"document"
 \Format xetex      tex    "LaTeX (XeTeX)"         "" ""        "%%"    
"document"
@@ -572,6 +573,7 @@
 \Format jlyx       cjklyx "CJK LyX 1.4.x (euc-jp)" "" ""       ""      
"document"
 \Format klyx       cjklyx "CJK LyX 1.4.x (euc-kr)" "" ""       ""      
"document"
 \Format lyxpreview lyxpreview "LyX Preview"       "" ""        ""      ""
+\Format lyxpreview-lytex  lyxpreview-lytex  "LyX Preview (LilyPond book)" "" 
""        ""      ""
 \Format lyxpreview-platex lyxpreview-platex "LyX Preview (pLaTeX)"       "" "" 
""      ""
 \Format pdftex     pdftex_t PDFTEX                "" ""        ""      ""
 \Format program    ""      Program                "" ""        ""      ""
@@ -807,7 +809,7 @@
                 addToRC(r'''\converter lilypond   eps        "lilypond 
-dbackend=eps --ps $$i" ""
 \converter lilypond   png        "lilypond -dbackend=eps --png $$i"    ""''')
                 addToRC(r'\converter lilypond   pdf        "lilypond 
-dbackend=eps --pdf $$i"  ""')
-                print '+  found LilyPond version %s.' % version_number
+                logger.info('+  found LilyPond version %s.' % version_number)
             elif int(version[0]) > 2 or (len(version) > 1 and int(version[0]) 
== 2 and int(version[1]) >= 6):
                 addToRC(r'''\converter lilypond   eps        "lilypond -b eps 
--ps $$i"        ""
 \converter lilypond   png        "lilypond -b eps --png $$i"   ""''')
@@ -819,6 +821,38 @@
         else:
             logger.info('+  found LilyPond, but could not extract version 
number.')
     #
+    path, lilypond_book = checkProg('a LilyPond book (LaTeX) -> LaTeX 
converter', ['lilypond-book'])
+    if (lilypond_book != ''):
+        version_string = cmdOutput("lilypond-book --version")
+        match = re.match('^(\S+)$', version_string)
+        if match:
+            version_number = match.groups()[0]
+            version = version_number.split('.')
+            if int(version[0]) > 2 or (len(version) > 1 and int(version[0]) == 
2 and int(version[1]) >= 1):
+                addToRC(r'\converter lyxpreview-lytex ppm "python -tt 
$$s/scripts/lyxpreview-lytex2bitmap.py" ""')
+                if dvipng == "dvipng":
+                    addToRC(r'\converter lyxpreview-lytex png "python -tt 
$$s/scripts/lyxpreview-lytex2bitmap.py" ""')
+                else:
+                    addToRC(r'\converter lyxpreview-lytex png "" ""')
+            if int(version[0]) > 2 or (len(version) > 1 and int(version[0]) == 
2 and int(version[1]) >= 11):
+                # Note: The --lily-output-dir flag is required because 
lilypond-book
+                #       does not process input again unless the input has 
changed,
+                #       even if the output format being requested is 
different. So
+                #       once a .eps file exists, lilypond-book won't create a 
.pdf
+                #       even when requested with --pdf. This is a problem if a 
user
+                #       clicks View PDF after having done a View DVI. To 
circumvent
+                #       this, use different output folders for eps and pdf 
outputs.
+                addToRC(r'\converter lilypond-book latex    "lilypond-book 
--lily-output-dir=ly-eps $$i"                                ""')
+                addToRC(r'\converter lilypond-book pdflatex "lilypond-book 
--pdf --latex-program=pdflatex --lily-output-dir=ly-pdf $$i" ""')
+                logger.info('+  found LilyPond-book version %s.' % 
version_number)
+            elif int(version[0]) > 2 or (len(version) > 1 and int(version[0]) 
== 2 and int(version[1]) >= 1):
+                addToRC(r'\converter lilypond-book latex  "lilypond-book $$i"  
                              ""')
+                logger.info('+  found LilyPond-book version %s.' % 
version_number)
+            else:
+                logger.info('+  found LilyPond-book, but version %s is too 
old.' % version_number)
+        else:
+            logger.info('+  found LilyPond-book, but could not extract version 
number.')
+    #
     checkProg('a Noteedit -> LilyPond converter', ['noteedit --export-lilypond 
$$i'],
         rc_entry = [ r'\converter noteedit   lilypond   "%%"   ""', ''])
     #
Index: lib/Makefile.am
===================================================================
--- lib/Makefile.am     (revision 35466)
+++ lib/Makefile.am     (working copy)
@@ -256,6 +256,7 @@
        examples/iecc12.fen \
        examples/instant_preview.lyx \
        examples/landslide.lyx \
+       examples/lilypond.lyx \
        examples/linguistics.lyx \
        examples/listerrors.lyx \
        examples/modernCV.lyx \
@@ -1099,6 +1100,7 @@
        layouts/kluwer.layout \
        layouts/latex8.layout \
        layouts/letter.layout \
+       layouts/lilypond.module \
        layouts/linguistics.module \
        layouts/literate-article.layout \
        layouts/literate-book.layout \
@@ -1208,6 +1210,7 @@
        scripts/legacy_lyxpreview2ppm.py \
        scripts/listerrors \
        scripts/lyxpreview2bitmap.py \
+       scripts/lyxpreview-lytex2bitmap.py \
        scripts/lyxpreview-platex2bitmap.py \
        scripts/lyxpreview_tools.py \
        scripts/tex_copy.py
Index: lib/examples/lilypond.lyx
===================================================================
--- lib/examples/lilypond.lyx   (revision 0)
+++ lib/examples/lilypond.lyx   (revision 0)
@@ -0,0 +1,2020 @@
+#LyX 2.0.0svn created this file. For more info see http://www.lyx.org/
+\lyxformat 401
+\begin_document
+\begin_header
+\textclass article
+\begin_preamble
+\date{}
+\end_preamble
+\use_default_options true
+\begin_modules
+lilypond
+\end_modules
+\maintain_unincluded_children false
+\language english
+\inputencoding utf8
+\fontencoding global
+\font_roman default
+\font_sans default
+\font_typewriter default
+\font_default_family default
+\use_xetex false
+\font_sc false
+\font_osf false
+\font_sf_scale 100
+\font_tt_scale 100
+
+\graphics default
+\default_output_format default
+\output_sync 0
+\bibtex_command default
+\index_command default
+\paperfontsize 12
+\spacing single
+\use_hyperref false
+\papersize default
+\use_geometry true
+\use_amsmath 1
+\use_esint 1
+\use_mhchem 1
+\use_mathdots 1
+\cite_engine basic
+\use_bibtopic false
+\use_indices false
+\paperorientation portrait
+\suppress_date false
+\index Index
+\shortcut idx
+\color #008000
+\end_index
+\leftmargin 2cm
+\topmargin 2cm
+\rightmargin 2cm
+\bottommargin 2cm
+\secnumdepth 3
+\tocdepth 3
+\paragraph_separation skip
+\defskip smallskip
+\quotes_language english
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\tracking_changes false
+\output_changes false
+\html_math_output 0
+\html_be_strict true
+\end_header
+
+\begin_body
+
+\begin_layout Title
+LilyPond-book + LyX
+\end_layout
+
+\begin_layout Abstract
+This is an example file demonstrating the use of LilyPond music notation
+ with LyX.
+\end_layout
+
+\begin_layout Section
+Using LilyPond code within LyX
+\end_layout
+
+\begin_layout Standard
+Support for LilyPond constructs (LilyPond code) within LyX is enabled by
+ adding the LilyPond module to your document.
+ This is done from the menu Document \SpecialChar \menuseparator
+ Settings..., then selecting LilyPond
+ in the list of modules.
+ You can use any LaTeX-based LyX layout and use the regular preview and
+ export mechanism; LyX will take care of processing the LaTeX code through
+ LilyPond-book for you.
+ LilyPond-book can also handle DocBook documents but LilyPond-DocBook support
+ in LyX is missing at the moment.
+\end_layout
+
+\begin_layout Subsection
+Requirements
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+LaTeX
+\begin_inset space ~
+\end_inset
+
+support: LilyPond-book version 2.1
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+PDFLaTeX
+\begin_inset space ~
+\end_inset
+
+support: LilyPond-book version 2.11
+\end_layout
+
+\begin_layout Paragraph
+Notes:
+\end_layout
+
+\begin_layout Standard
+LilyPond-book supports LaTeX output since version 2.1.
+ PDFLaTeX requires LilyPond-book version 2.9 or older, but there are bugs
+ in those early versions.
+ We require version 2.11 and older because we use the -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+{}
+\end_layout
+
+\end_inset
+
+-lily-output-dir flag.
+\end_layout
+
+\begin_layout Subsection
+Integration
+\end_layout
+
+\begin_layout Standard
+The module provides a LilyPond inset which you insert from the menu Insert
+ \SpecialChar \menuseparator
+ Custom Insets.
+ This inset is for typing the LilyPond code which will be typeset into your
+ musical notes.
+ First, let's try a simple scale:
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex LilyPond
+status open
+
+\begin_layout Plain Layout
+
+
+\backslash
+relative c'' {
+\end_layout
+
+\begin_layout Plain Layout
+
+  g a b c
+\end_layout
+
+\begin_layout Plain Layout
+
+}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The previous LyX inset produces the following LaTeX-lookalike code:
+\end_layout
+
+\begin_layout LyX-Code
+
+\backslash
+begin{lilypond}
+\end_layout
+
+\begin_layout LyX-Code
+
+\backslash
+relative c'' {
+\end_layout
+
+\begin_layout LyX-Code
+  g a b c
+\end_layout
+
+\begin_layout LyX-Code
+}
+\end_layout
+
+\begin_layout LyX-Code
+
+\backslash
+end{lilypond}
+\end_layout
+
+\begin_layout Standard
+This code is not, in fact, processed by LaTeX, but is preprocessed by 
LilyPond-b
+ook, which creates the graphics files and include them in the LaTeX document
+ by replacing the above with 
+\family typewriter
+
+\backslash
+includegraphics{\SpecialChar \ldots{}
+}
+\family default
+.
+\end_layout
+
+\begin_layout Standard
+Thus, the conversion toolchain is as follow: LyX\SpecialChar \menuseparator
+LilyPond-book\SpecialChar \menuseparator
+LaTeX.
+ Every step of the toolchain obeys your spacing, so whether you put the
+ musical extract inline or in its own paragraph, centered or left-aligned,
+ etc., what you see in the LyX window should be respected in the final format.
+ An example of inline use may be to display a chord name, such as
+\begin_inset Flex LilyPond
+status open
+
+\begin_layout Plain Layout
+
+
+\backslash
+markup { 
+\backslash
+concat {B 
+\backslash
+super 
+\backslash
+flat } }
+\end_layout
+
+\end_inset
+
+, or perhaps a very short snippet.
+\end_layout
+
+\begin_layout Subsection
+Previews
+\end_layout
+
+\begin_layout Standard
+It is possible to have a direct feedback of what the music notation looks
+ like from within LyX.
+ To do this, wrap a LilyPond inset inside a Preview inset, which you find
+ from the menu Insert \SpecialChar \menuseparator
+ Preview.
+ This only affects the display within LyX, not the output:
+\end_layout
+
+\begin_layout Standard
+\begin_inset Preview
+
+\begin_layout Standard
+\begin_inset Flex LilyPond
+status open
+
+\begin_layout Plain Layout
+
+
+\backslash
+relative c'' {
+\end_layout
+
+\begin_layout Plain Layout
+
+  ais a g ges
+\end_layout
+
+\begin_layout Plain Layout
+
+}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Unfortunately, you might find that the preview isn't exactly instantaneous.
+ You need to move the cursor out of the Preview inset to start compilation,
+ and processing time can take a few seconds.
+\end_layout
+
+\begin_layout Subsection
+Gotchas
+\end_layout
+
+\begin_layout Standard
+LilyPond-book searches for a 
+\family typewriter
+
+\backslash
+score
+\family default
+ or 
+\family typewriter
+
+\backslash
+relative
+\family default
+ command when it decides if the code is only a fragment.
+ It is possible to include no LilyPond command at all, but in that case
+ {surrounding braces} are required.
+ Thus, in the following code,
+\end_layout
+
+\begin_layout LyX-Code
+
+\backslash
+begin{lilypond}
+\end_layout
+
+\begin_layout LyX-Code
+  ais' f'' g' e'' % no 
+\backslash
+score given
+\end_layout
+
+\begin_layout LyX-Code
+
+\backslash
+end{lilypond}
+\end_layout
+
+\begin_layout Standard
+LilyPond-book gets confused:
+\end_layout
+
+\begin_layout LyX-Code
+error: syntax error, unexpected NOTENAME_PITCH
+\end_layout
+
+\begin_layout LyX-Code
+ais' f'' g' e'' % no 
+\backslash
+score given
+\end_layout
+
+\begin_layout Standard
+With surrounding braces, all is well:
+\end_layout
+
+\begin_layout Standard
+\begin_inset Preview
+
+\begin_layout Standard
+\begin_inset Flex LilyPond
+status open
+
+\begin_layout Plain Layout
+
+{ais' f'' g' e''} % no 
+\backslash
+score given
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+LilyPond examples
+\end_layout
+
+\begin_layout Standard
+Example 
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sub:Editorial-headword"
+
+\end_inset
+
+ shows that any valid LilyPond construct can be handled, no matter how 
complicat
+ed.
+ Example 
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sub:Positioning-of-markup"
+
+\end_inset
+
+ shows how you can mix LilyPond code with tables to display the fingering
+ of guitar chords.
+ And Example 
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sub:Tablatures-template"
+
+\end_inset
+
+ shows yet another LilyPond output for guitarists.
+\end_layout
+
+\begin_layout Subsection
+Editorial headword
+\begin_inset CommandInset label
+LatexCommand label
+name "sub:Editorial-headword"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+NR 1.7 Editorial annotations Beethoven, Op.
+ 31, No.
+ 3 Piano sonata 18, Movt II, Scherzo Measures 9--14.
+\end_layout
+
+\begin_layout Standard
+\noindent
+\align center
+\begin_inset Preview
+
+\begin_layout Standard
+\begin_inset Flex LilyPond
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+new PianoStaff <<
+\end_layout
+
+\begin_layout Plain Layout
+
+  
+\end_layout
+
+\begin_layout Plain Layout
+
+  % RH Staff
+\end_layout
+
+\begin_layout Plain Layout
+
+  
+\backslash
+new Staff {
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+clef treble
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+key aes 
+\backslash
+major
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+time 2/4
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+set Staff.fingeringOrientations = #'(up)
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+set Score.currentBarNumber = #9
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+partial 8
+\end_layout
+
+\begin_layout Plain Layout
+
+    <aes''-4 c''>8
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    |
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+set doubleSlurs = ##t
+\end_layout
+
+\begin_layout Plain Layout
+
+    <bes''-5 des''-2>4(
+\end_layout
+
+\begin_layout Plain Layout
+
+    <aes''-4 c''>8
+\backslash
+staccato)
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+noBeam
+\end_layout
+
+\begin_layout Plain Layout
+
+    c''8-5
+\backslash
+staccato
+\backslash
+pp
+\end_layout
+
+\begin_layout Plain Layout
+
+    |
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+unset doubleSlurs
+\end_layout
+
+\begin_layout Plain Layout
+
+    bes'8..(
+\end_layout
+
+\begin_layout Plain Layout
+
+    aes'32
+\end_layout
+
+\begin_layout Plain Layout
+
+    g'8)
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    f'8
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    |
+\end_layout
+
+\begin_layout Plain Layout
+
+    e'4-2
+\end_layout
+
+\begin_layout Plain Layout
+
+    r8
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+once 
+\backslash
+override Script #'script-priority = #-100
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+afterGrace
+\end_layout
+
+\begin_layout Plain Layout
+
+    f'8(
+\backslash
+trill^
+\backslash
+markup { 
+\backslash
+finger "3-2" }
+\end_layout
+
+\begin_layout Plain Layout
+
+    { e'16[ f'16] }
+\end_layout
+
+\begin_layout Plain Layout
+
+    |
+\end_layout
+
+\begin_layout Plain Layout
+
+    g'8..-3
+\end_layout
+
+\begin_layout Plain Layout
+
+    f'32
+\end_layout
+
+\begin_layout Plain Layout
+
+    e'8-1)
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    d'8-2
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    |
+\end_layout
+
+\begin_layout Plain Layout
+
+    c'4
+\end_layout
+
+\begin_layout Plain Layout
+
+    r4
+\end_layout
+
+\begin_layout Plain Layout
+
+  }
+\end_layout
+
+\begin_layout Plain Layout
+
+  
+\end_layout
+
+\begin_layout Plain Layout
+
+  % LH Staff
+\end_layout
+
+\begin_layout Plain Layout
+
+  
+\backslash
+new Staff {
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+key aes 
+\backslash
+major
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+clef treble
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+override Fingering #'direction = #down
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+set Staff.fingeringOrientations = #'(down)
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+partial 8
+\end_layout
+
+\begin_layout Plain Layout
+
+    <aes' aes>8
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+set doubleSlurs = ##t
+\end_layout
+
+\begin_layout Plain Layout
+
+    <g'-2 ees'-3>4(
+\end_layout
+
+\begin_layout Plain Layout
+
+    <aes' aes>8)
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+noBeam
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+clef bass
+\end_layout
+
+\begin_layout Plain Layout
+
+    c'8-1
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    |
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+set doubleSlurs = ##f
+\end_layout
+
+\begin_layout Plain Layout
+
+    bes8..(
+\end_layout
+
+\begin_layout Plain Layout
+
+    aes32
+\end_layout
+
+\begin_layout Plain Layout
+
+    g8-1)
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    f8
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    |
+\end_layout
+
+\begin_layout Plain Layout
+
+    e4
+\end_layout
+
+\begin_layout Plain Layout
+
+    r8
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+afterGrace
+\end_layout
+
+\begin_layout Plain Layout
+
+    f8(
+\backslash
+trill_
+\backslash
+markup { 
+\backslash
+finger "2-1" }
+\end_layout
+
+\begin_layout Plain Layout
+
+    { e16[ f16] }
+\end_layout
+
+\begin_layout Plain Layout
+
+    |
+\end_layout
+
+\begin_layout Plain Layout
+
+    g8..-1
+\end_layout
+
+\begin_layout Plain Layout
+
+    f32
+\end_layout
+
+\begin_layout Plain Layout
+
+    e8)
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    d8
+\backslash
+staccato
+\end_layout
+
+\begin_layout Plain Layout
+
+    |
+\end_layout
+
+\begin_layout Plain Layout
+
+    c4
+\end_layout
+
+\begin_layout Plain Layout
+
+    r4
+\end_layout
+
+\begin_layout Plain Layout
+
+  }
+\end_layout
+
+\begin_layout Plain Layout
+
+>>
+\end_layout
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+[from 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://lsr.dsi.unimi.it/LSR/Item?id=627
+\end_layout
+
+\end_inset
+
+]
+\end_layout
+
+\begin_layout Subsection
+Positioning of markup elements
+\begin_inset CommandInset label
+LatexCommand label
+name "sub:Positioning-of-markup"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Tabular arrangement of elements
+\end_layout
+
+\begin_layout Standard
+\noindent
+\align center
+\begin_inset Tabular
+<lyxtabular version="3" rows="4" columns="3">
+<features tabularvalignment="middle">
+<column alignment="center" valignment="middle" width="20col%">
+<column alignment="center" valignment="middle" width="20col%">
+<column alignment="center" valignment="middle" width="20col%">
+<row>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+Ignatzek
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+Alternative
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+Diagram
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+C
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+C
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Preview
+
+\begin_layout Standard
+\begin_inset Flex LilyPond
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+markup { 
+\backslash
+fret-diagram #"6-x;5-3-3;4-2-2;3-o;2-1-1;1-o;" }
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+Cm
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Preview
+
+\begin_layout Standard
+\begin_inset Flex LilyPond
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+markup { 
+\backslash
+concat { C 
+\backslash
+super { 
+\backslash
+flat 5 } } }
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Preview
+
+\begin_layout Standard
+\begin_inset Flex LilyPond
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+markup { 
+\backslash
+fret-diagram #"6-x;5-1-1;4-3-3;3-3-4;2-2-2;1-1-1;c:5-1-1;" }
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+C+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Preview
+
+\begin_layout Standard
+\begin_inset Flex LilyPond
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+markup { 
+\backslash
+concat { C 
+\backslash
+super { 
+\backslash
+sharp 5 } } }
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Preview
+
+\begin_layout Standard
+\begin_inset Flex LilyPond
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+markup { 
+\backslash
+fret-diagram #"6-x;5-x;4-2-2;3-1-1;2-1-1;1-4-4;c:2-3-1;" }
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Musical notation with each element placed by hand
+\end_layout
+
+\begin_layout Standard
+\noindent
+\begin_inset Preview
+
+\begin_layout Standard
+\begin_inset Flex LilyPond
+status open
+
+\begin_layout Plain Layout
+
+%{
+\end_layout
+
+\begin_layout Plain Layout
+
+Snippet for overlay markup command - absolute positioning of items
+\end_layout
+
+\begin_layout Plain Layout
+
+Defines a new markup command 
+\backslash
+overlay which takes a list of markup elements and positions them all at
+ the same point.
+\end_layout
+
+\begin_layout Plain Layout
+
+        By translating each markup element, you can gain control of the
+ absolute position of each.
+\end_layout
+
+\begin_layout Plain Layout
+
+%}
+\end_layout
+
+\begin_layout Plain Layout
+
+#(define-public (stack-stencil-overlay stencils)
+\end_layout
+
+\begin_layout Plain Layout
+
+  "Recursive function to add stencils together"
+\end_layout
+
+\begin_layout Plain Layout
+
+  (if (and (pair? stencils)
+\end_layout
+
+\begin_layout Plain Layout
+
+           (ly:stencil? (car stencils)))
+\end_layout
+
+\begin_layout Plain Layout
+
+      
+\end_layout
+
+\begin_layout Plain Layout
+
+      (if (and (pair? (cdr stencils))
+\end_layout
+
+\begin_layout Plain Layout
+
+               (ly:stencil? (cadr stencils)))
+\end_layout
+
+\begin_layout Plain Layout
+
+          (let ((tail (stack-stencil-overlay (cdr stencils)))
+\end_layout
+
+\begin_layout Plain Layout
+
+                (head (car stencils)))
+\end_layout
+
+\begin_layout Plain Layout
+
+               (ly:stencil-add head tail))
+\end_layout
+
+\begin_layout Plain Layout
+
+          (car stencils))
+\end_layout
+
+\begin_layout Plain Layout
+
+      point-stencil))
+\end_layout
+
+\begin_layout Plain Layout
+
+#(define-markup-command (overlay layout props args)
+\end_layout
+
+\begin_layout Plain Layout
+
+  (markup-list?)
+\end_layout
+
+\begin_layout Plain Layout
+
+  "Overlay arguments one on top of the next"
+\end_layout
+
+\begin_layout Plain Layout
+
+  (let ((stencils (interpret-markup-list layout props args)))
+\end_layout
+
+\begin_layout Plain Layout
+
+       (stack-stencil-overlay
+\end_layout
+
+\begin_layout Plain Layout
+
+         (remove ly:stencil-empty? stencils))))
+\end_layout
+
+\begin_layout Plain Layout
+
+
+\backslash
+markup {
+\end_layout
+
+\begin_layout Plain Layout
+
+  
+\backslash
+overlay {
+\end_layout
+
+\begin_layout Plain Layout
+
+%    
+\backslash
+translate #'(0 .
+ 7)
+\end_layout
+
+\begin_layout Plain Layout
+
+%    
+\backslash
+justify-string #"Musical notation with each element placed by hand"
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(0 .
+ -3) 
+\backslash
+fontsize #2 "1"
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+postscript #"
+\end_layout
+
+\begin_layout Plain Layout
+
+      0.15 setlinewidth
+\end_layout
+
+\begin_layout Plain Layout
+
+      4  0 moveto 74  0 lineto stroke
+\end_layout
+
+\begin_layout Plain Layout
+
+      4 -1 moveto 74 -1 lineto stroke
+\end_layout
+
+\begin_layout Plain Layout
+
+      4 -2 moveto 74 -2 lineto stroke
+\end_layout
+
+\begin_layout Plain Layout
+
+      4 -3 moveto 74 -3 lineto stroke
+\end_layout
+
+\begin_layout Plain Layout
+
+      4 -4 moveto 74 -4 lineto stroke
+\end_layout
+
+\begin_layout Plain Layout
+
+      11.6 -5 moveto 13.6 -5 lineto stroke
+\end_layout
+
+\begin_layout Plain Layout
+
+      42.6 -5 moveto 44.6 -5 lineto stroke
+\end_layout
+
+\begin_layout Plain Layout
+
+      17.6 -5 moveto 0 0 2 -1 7 -1 9 0 rcurveto stroke
+\end_layout
+
+\begin_layout Plain Layout
+
+      48.6 -5 moveto 0 0 2 -1 7 -1 9 0 rcurveto stroke
+\end_layout
+
+\begin_layout Plain Layout
+
+      0.3 setlinewidth
+\end_layout
+
+\begin_layout Plain Layout
+
+      73.85 0 moveto 73.85 -4 lineto stroke
+\end_layout
+
+\begin_layout Plain Layout
+
+      "
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(4 .
+ 2) "Präludium"
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(5 .
+ -3)   
+\backslash
+musicglyph #"clefs.G_change"
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(8 .
+ -2) 
+\backslash
+musicglyph #"timesig.C44"
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(12 .
+ -5) 
+\backslash
+note-by-number #1 #0 #DOWN
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(12 .
+ -2) 
+\backslash
+musicglyph #"rests.4"
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(12 .
+ 0) 
+\backslash
+musicglyph #"rests.3"
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(16 .
+ -4) 
+\backslash
+note-by-number #3 #0 #DOWN
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(17.4 .
+ -4.4) 
+\backslash
+musicglyph #"dots.dot"
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(19 .
+ -3) 
+\backslash
+note-by-number #2 #0 #UP
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(23 .
+ -1.5) 
+\backslash
+note-by-number #2 #0 #1.2
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(20.25 .
+ 0) 
+\backslash
+beam #4 #0.5 #0.40
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(20.25 .
+ -1) 
+\backslash
+beam #4 #0.5 #0.40
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(27 .
+ -4) 
+\backslash
+note-by-number #2 #0 #DOWN
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(27 .
+ -0.5) 
+\backslash
+note-by-number #2 #0 #UP
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(31 .
+ -3) 
+\backslash
+note-by-number #2 #0 #1.7
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(35 .
+ -1.5) 
+\backslash
+note-by-number #2 #0 #1.3
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(39 .
+ -0.5) 
+\backslash
+note-by-number #2 #0 #UP
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(28.25 .
+ 2.25) 
+\backslash
+beam #12 #0 #0.4
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(28.25 .
+ 1.35) 
+\backslash
+beam #12 #0 #0.4
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(43 .
+ -5) 
+\backslash
+note-by-number #1 #0 #DOWN
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(43 .
+ -2) 
+\backslash
+musicglyph #"rests.4"
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(43 .
+ 0) 
+\backslash
+musicglyph #"rests.3"
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(47 .
+ -4) 
+\backslash
+note-by-number #3 #0 #DOWN
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(48.4 .
+ -4.4) 
+\backslash
+musicglyph #"dots.dot"
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(50 .
+ -3) 
+\backslash
+note-by-number #2 #0 #UP
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(54 .
+ -1.5) 
+\backslash
+note-by-number #2 #0 #1.2
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(51.25 .
+ 0) 
+\backslash
+beam #4 #0.5 #0.40
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(51.25 .
+ -1) 
+\backslash
+beam #4 #0.5 #0.40
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(58 .
+ -4) 
+\backslash
+note-by-number #2 #0 #DOWN
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(58 .
+ -0.5) 
+\backslash
+note-by-number #2 #0 #UP
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(62 .
+ -3) 
+\backslash
+note-by-number #2 #0 #1.7
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(66 .
+ -1.5) 
+\backslash
+note-by-number #2 #0 #1.3
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(70 .
+ -0.5) 
+\backslash
+note-by-number #2 #0 #UP
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(59.25 .
+ 2.25) 
+\backslash
+beam #12 #0 #0.40
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+translate #'(59.25 .
+ 1.35) 
+\backslash
+beam #12 #0 #0.40
+\end_layout
+
+\begin_layout Plain Layout
+
+  }
+\end_layout
+
+\begin_layout Plain Layout
+
+}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+[adapted from 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://lsr.dsi.unimi.it/LSR/Item?id=628
+\end_layout
+
+\end_inset
+
+]
+\end_layout
+
+\begin_layout Subsection
+Tablatures template
+\begin_inset CommandInset label
+LatexCommand label
+name "sub:Tablatures-template"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Preview
+
+\begin_layout Standard
+\begin_inset Flex LilyPond
+status collapsed
+
+\begin_layout Plain Layout
+
+upper=  
+\backslash
+relative c' {
+\end_layout
+
+\begin_layout Plain Layout
+
+  c4.
+  g4  g  c
+\end_layout
+
+\begin_layout Plain Layout
+
+}
+\end_layout
+
+\begin_layout Plain Layout
+
+lower=  
+\backslash
+relative c {
+\end_layout
+
+\begin_layout Plain Layout
+
+  c4  e  g,  e'
+\end_layout
+
+\begin_layout Plain Layout
+
+}
+\end_layout
+
+\begin_layout Plain Layout
+
+
+\backslash
+score {
+\end_layout
+
+\begin_layout Plain Layout
+
+  
+\backslash
+new StaffGroup <<
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+new Staff = "guitar" <<
+\end_layout
+
+\begin_layout Plain Layout
+
+      
+\backslash
+context Voice = "upper guitar" { 
+\backslash
+clef "G_8" 
+\backslash
+voiceOne  
+\backslash
+upper }
+\end_layout
+
+\begin_layout Plain Layout
+
+      
+\backslash
+context Voice = "lower guitar" { 
+\backslash
+clef "G_8" 
+\backslash
+voiceTwo  
+\backslash
+lower }
+\end_layout
+
+\begin_layout Plain Layout
+
+    >>
+\end_layout
+
+\begin_layout Plain Layout
+
+    
+\backslash
+new TabStaff = "tab" <<
+\end_layout
+
+\begin_layout Plain Layout
+
+      
+\backslash
+context TabVoice = "upper tab" { 
+\backslash
+clef "moderntab" 
+\backslash
+voiceOne 
+\backslash
+upper }
+\end_layout
+
+\begin_layout Plain Layout
+
+      
+\backslash
+context TabVoice = "lower tab" { 
+\backslash
+clef "moderntab" 
+\backslash
+voiceTwo 
+\backslash
+lower }
+\end_layout
+
+\begin_layout Plain Layout
+
+    >>
+\end_layout
+
+\begin_layout Plain Layout
+
+  >>
+\end_layout
+
+\begin_layout Plain Layout
+
+}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+[from 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://lsr.dsi.unimi.it/LSR/Item?id=634
+\end_layout
+
+\end_inset
+
+]
+\end_layout
+
+\end_body
+\end_document

Property changes on: lib/examples/lilypond.lyx
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Reply via email to