lyx_mirror/lib/examples/lilypond.lyx
Pavel Sanda bda8ae6a8c * examples/lilypond.lyx
Patch by Julien Rioux.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36008 a592a061-630c-0410-9148-cb99ea01b6c8
2010-11-03 00:11:33 +00:00

1164 lines
15 KiB
Plaintext

#LyX 2.0.0svn created this file. For more info see http://www.lyx.org/
\lyxformat 404
\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 auto
\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 default
\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
\use_refstyle 0
\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 Itemize
LilyPond-book version 2.13
\end_layout
\begin_layout Paragraph
Notes:
\end_layout
\begin_layout Standard
LilyPond-book supports LaTeX output since version 2.1.
However, some features used by LyX are available only in recent versions:
PDFLaTeX support (version 2.9), the
\family typewriter
--lily-output-dir
\family default
flag (version 2.11) and especially the
\family typewriter
--safe
\family default
flag (version 2.13).
\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 Standard
Another gotcha is with subsequent lilypond snippets with
\family typewriter
\backslash
fret-diagram
\family default
markup commands:
\end_layout
\begin_layout LyX-Code
\backslash
begin{lilypond}
\end_layout
\begin_layout LyX-Code
\backslash
markup{
\backslash
fret-diagram-terse #"x;3;2;o;1;o;" }
\end_layout
\begin_layout LyX-Code
\backslash
end{lilypond}
\end_layout
\begin_layout LyX-Code
\end_layout
\begin_layout LyX-Code
\backslash
begin{lilypond}
\end_layout
\begin_layout LyX-Code
\backslash
markup{
\backslash
fret-diagram-terse #"x;x;o;2;3;2;" }
\end_layout
\begin_layout LyX-Code
\backslash
end{lilypond}
\end_layout
\begin_layout Standard
For some reason LilyPond-book version 2.13 barks on this when run in safe
mode (which you always should use, unless you know what you are doing).
\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 a complex example using many LilyPond constructs; some inline scheme
code has been removed to be able to run in safe mode.
Example
\begin_inset CommandInset ref
LatexCommand ref
reference "sub:Tablatures-template"
\end_inset
shows another LilyPond output which should be interesting to 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
; inline scheme code removed, centering applied through the paragraph settings]
\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 "tab"
\backslash
voiceOne
\backslash
upper }
\end_layout
\begin_layout Plain Layout
\backslash
context TabVoice = "lower tab" {
\backslash
clef "tab"
\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