+2003-06-29 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ * Documentation/user/introduction.itely (Computerized typography):
+ new section
+
+ * Documentation/user/tutorial.itely (An orchestral part): remove
+ pc example from tutorial.
+
+ * input/tutorial/lilbook.tex: use screech-boink
+
+ * scripts/lilypond-book.py (compile_all_files): split formatting
+ output body and scheduling lilypond compilation.
+ (format_lilypond_output_bodies): new function
+ (format_lilypond_block): new function
+ (html_pages): allow multi-page images in HTML
+
+ * python/lilylib.py (make_ps_images): rename function from
+ make_preview, merge with make_page_images
+
2003-06-28 Graham Percival <gperlist@shaw.ca>
* input/test/key-clefs.ly: moved to regression.
c d e f g a b
@end lilypond
+@item @code{fis bes}
+@tab alteration
+@tab
+@lilypond[relative 1, notime]
+\property Staff.Clef = \turnOff
+fis bes
+@end lilypond
+
@item @code{\clef treble \clef bass }
@tab clefs
@tab
@end lilypond
-@item @code{( )}
+@item @code{-( -)}
@tab slur
@tab
@lilypond[fragment, relative 1]
@end lilypond
-@item @code{\( \)}
+@item @code{-\( -\)}
@tab phrasing slur
@tab
@lilypond[fragment, relative 1]
@end lilypond
-@item @code{[ ]}
+@item @code{-[ -]}
@tab beam
@tab
@lilypond[fragment, relative 1]
@end lilypond
-@item @code{\< \!}
+@item @code{-\< -\!}
@tab crescendo
@tab
@lilypond[fragment, relative 1]
a\< a \!a
@end lilypond
-@item @code{\> \!}
+@item @code{-\> -\!}
@tab decrescendo
@tab
@lilypond[fragment, relative 1]
@item @code{\times 2/3}
@tab triplets
@tab
-@lilypond[relative 1,verbatim,fragment]
+@lilypond[relative 1,fragment]
\times 2/3 { f8 g a }
@end lilypond
@c before saving changes
-@node Advanced topics
-@chapter Advanced topics
+@node Technical manual
+@chapter Technical manual
When LilyPond is run, it reads an input file which is parsed. During
@menu
* Batch processing::
* Music engraving::
+* Computerized typography ::
* Music representation::
* Example applications::
* About this manual::
@cindex Batch
@cindex UNIX
+LilyPond is a @emph{batch} program. To use, one enters commands in a
+file, and the program is run on that file. The output is produced
+without requiring any user-interaction.
+
When we started developing LilyPond, we were still studying at the
university. We were interested in music notation, not as publishers
or musicians, but as programmers and scientists. We wanted to figure
printing. Only a few decades ago, sheet music was made by cutting and
stamping the music into zinc or pewter plates, mirrored. The plate
would be inked, and the depressions caused by the cutting and stamping
-would hold ink. A positive image was formed by pressing paper to the
+would hold ink. An image was formed by pressing paper to the
plate. Stamping and cutting was completely done by hand. Making
corrections was cumbersome, so engraving had to be done correctly in
one go. As you can imagine this was a highly specialized skill, much
practical experience were needed to become an established music
engraver. Even today, with the use of high-speed computers and
advanced software, music requires lots of manual fine tuning before it
-acceptable to be published.
+is acceptable for publication.
-When we wanted to write a computer program to do create music
-typography, we encountered the first problem: there were no sets of
-musical symbols available: either they were not available freely, or
-they did not look well to our taste. Not let down, we decided to try
-font design ourselves. We created a font of musical symbols, relying
-on nice printouts of hand-engraved music. The experience helped
-develop a typographical taste, and it made us appreciate subtle design
-details. Without that experience, we would not have realized how ugly
-the fonts were that we admired at first.
+When we wanted to write a computer program to create music typography,
+we encountered the first problem: there were no sets of musical
+symbols available: either they were not available freely, or they did
+not look well to our taste. Not let down, we decided to try font
+design ourselves. We created a font of musical symbols, relying on
+nice printouts of hand-engraved music. The experience helped develop
+a typographical taste, and it made us appreciate subtle design
+details. Without that experience, we would not have realized the
+shortcomings of the fonts were that we admired at first.
@lilypond[noindent]
The figure above shows a few notable glyphs. For example, the
-vertical stem of a flat symbol should be slightly brushed,
+vertical stem of the flat symbol should be brushed slightly,
i.e. becoming wider at the top. the half-notehead is not elliptic but
slightly diamond shaped. Fine endings, such as the one on the bottom
of the quarter rest, should not end in sharp points, but rather in
Producing a strong and balanced look is the real challenge of music
engraving. It is a recurring theme with many variations. In spacing,
-the balance is in a distribution that reflects the character of the
-music. The spacing should not lead to unnatural clusters of black and
-big gaps with white space. The distances between notes should reflect
-the durations between notes, but adhering with mathematical precision
-to the duration will lead to a poor result. Shown here is an example
-of a motive, printed twice. It is printed using both exact
-mathematical spacing, and with some corrections. Can you spot which is
-which?
+strength and balance are in layout that is `heavy' enough---without
+big gaps of space--- and without big clusters of black. The
+distribution of space should reflect the character of the music.
+
+Spacing is an example of a subtlety of formatting music. The distances
+between notes should reflect the durations between notes, but adhering
+with mathematical precision to the duration will lead to a poor
+result. Shown here is an example of a motive, printed twice. It is
+printed using exact mathematical spacing, and with some
+corrections. Can you spot which fragment is which?
@cindex optical spacing
should be put closer together, all depending on the combined vertical
positions of the notes. The first two measures are printed with this
correction, the last two measures without. The notes in the last two
-measures form downstem/upstems clumps of notes.
+measures form down-stem/up-stems clumps of notes.
+
+@node Computerized typography
+@section Computerized typography
+
+The example in the previous section is one illustration of how subtle
+music engraving can be is a subtle. Producing good engraving requires
+skill and knowledge.
+
+
+It was our challenge to see if we could put typographical knowledge
+into a computer program. Capturing that knowledge has two aspects:
+first, it has to be acquired. Then, it has to be encoded in
+data-structures and algorithms. As the previous example shows, there
+is a lot of subtlety involved in music engraving, and unfortunately,
+only a small fraction of these tiny details are documented.
+
+One reason for the time that it takes to become a master engraver, is
+that all these details must be learned either from experience or from
+other engravers: as an engraver gets older and wiser, he will be able
+to produce better and more complex pieces. A similar situation is
+present when putting typography into computer programs. It is not
+possible to come up with a final solution for a problem at the first
+try. Instead, we start out with simple solution that might cover 75%
+of the cases, and gradually refine that solution over the course of
+months or years, so that 90 or 95 % of the cases are handled.
+
+This has an important implication for the design of the
+program. During development, almost every piece of formatting code
+must be considered as temporary. When the need arises, is to be
+replaced a solution that will cover even more cases. A clean way to
+accomplish this, is a ``plug-in'' architecture: an architecture where
+new pieces of code can be inserted in the program dynamically. In
+such a program, a new solution can be developed along-side the
+existing code. It can be perfected separately until it is better than
+the existing solution, at which point, the new solution is switched on
+by default, and the old one is removed.
+
+Until that time, users must have a way to deal with imperfections:
+these 25%, 10% or 5% of the cases that are not handled
+automatically. In these cases, a user must be able to override
+formatting decisions. A way to accomplish this, is to store decisions
+in generic variables, and let the user manipulate these variables.
+For example, consider the following fragment of notation.
+
+@lilypond
+\score { \notes {
+ g'4-\f g4
+ }
+\paper { raggedright = ##t }
+ }
+@end lilypond
+
+@noindent
+The position of the forte symbol is slightly awkward, because it is
+next to the low note, whereas dynamics should be below notes in
+general. This may be remedied by inserting extra space between the
+high note and the `f', as shown in this example
+
+@lilypond
+\score { \notes {
+ \once\property Voice. DynamicLineSpanner \override #'padding = #4.0
+ g'4-\f g4
+ }
+\paper { raggedright = ##t }
+ }
+@end lilypond
+
+This was achieved with the input statement
+@example
+ \property Voice. DynamicLineSpanner \override #'padding = #4.0
+@end example
+which increases the amount of space (@code{padding}) between the note
+and the dynamic symbol to 4.0 (which is measured in staff space, so
+4.0 equals the height of a staff).
+
+Both design aspects, a plug-in architecture, and formatting variables,
+are built on top of GUILE, an interpreter for the programming language
+Scheme, which is a member of the LISP family. Variables are stored as
+Scheme objects, and attached to graphical objects such as note heads
+and stems. The variables are a means to adjust formatting details in
+individual cases, but they are used in a more general manner.
+
+Consider the case of a publisher that is not satisfied with the in the
+default layout, and wants heavier stems. Normally, they are @code{1.3}
+times the thickness of staff lines, but suppose that their editions
+require them to be twice the thickness of the staff lines. The same
+mechanism can be used to adjust a setting globally. By issuing
+@example
+ \property Score.Stem \override #'thickness = #2.0
+@end example
+the entire piece is formatted with thick stems:
+@lilypond
+\score { \notes {
+ \once\property Voice. DynamicLineSpanner \override #'padding = #4.0
+ g'4-\f g4
+ }
+\paper { raggedright = ##t }
+ }
+@end lilypond
-We hope that these examples show that music typography is a subtle
-business, and that it requires skill and knowledge to produce good
-engraving. It was our challenge to see if we could put such knowledge
-into a computer program.
+@noindent
+In effect, by setting these variables, users can define their own
+layout styles.
+
+``Plug-ins'' are also implemented using Scheme. A formatting
+``plug-in'' takes the form of a function written in Scheme (or a C++
+function made available as a Scheme function), and it is also stored
+in a variable. For example, the placement of the forte symbol in the
+example above is calculated by the function
+@code{Side_position_interface::aligned_side}. If we want to replace
+this function by a more advanced one, we could issue
+@example
+ \property Voice.DynamicLineSpanner \override #'Y-offset-callbacks
+ = #`(,gee-whiz-gadget)
+@end example
+
+@noindent
+Now, the formatting process will trigger a call to our new
+@code{gee-whiz-gadget} function when the position of the f symbol has
+to be determined.
+
+The full scope of this functionality certainly is intimidating, but
+there is no need to fear: normally, it is not necessary to define
+style-sheets or rewrite formatting functions. In fact, LilyPond gets a
+lot of formatting right automatically, so adjusting individual layout
+situations is not needed very often.
@node Music representation
@section Music representation
-One of the big questions when making programs, is what kind of input
-the program should expect. Many music notation programs offer a
+One of the big questions when writing batch programs, is what kind of
+input the program should expect. Many music notation programs offer a
graphical interface that shows notation, and allow you to enter the
music by placing notes on a staff. From our point of view, this design
is a form of cheating. After all, the core message of a piece of music
applied to do useful things. In this section, we show a few small
examples of what is possible.
-The simplest application, is printing just notes.
+The simplest application is printing notes.
@lilypond[relative=1]
\time 2/4 c4 c g'4 g a4 a g2
@end lilypond
-To these notes, chord names and lyrics may be added
+To these notes, chord names and lyrics may be added, yielding
+a lead sheet.
@lilypond[raggedright]
\score { <
\context ChordNames \chords { c2 c f2 c }
\notes \relative c' { \time 2/4 c4 c g'4 g a4 a g2 }
- \context Lyrics \lyrics { twin kle twin kle lit tle star } > }
+ \context Lyrics \lyrics { twin4 kle twin kle lit tle star2 } > }
@end lilypond
-
-[TODO: need piano and tab example]
-
The following example combines some more exotic uses of notation
@lilypondfile{screech-boink.ly}
+
@node About this manual
@section About this manual
The manual is divided into the following chapters
@itemize @bullet
-@item The @emph{tutorial}
-(@ref{Tutorial}) gives a gentle introduction into typesetting music.
+@item
+@ifhtml The
+@end ifhtml
+@emph{@ref{Tutorial}}
+gives a gentle introduction into typesetting music.
First time users should start here.
-@item The @emph{notation manual} (@ref{Notation manual}),
-is a user manual that discusses topics grouped by notation construct.
-@item The @emph{technical manual} (@ref{Advanced topics})
-discusses the general design of the program, and how to extend the
+@item
+@ifhtml
+The
+@end ifhtml
+@emph{@ref{Notation manual}}
+discusses topics grouped by notation construct.
+@item
+@ifhtml
+ The
+ @end ifhtml
+@emph{@ref{Technical manual}}
+@c
+discusses the general design of the program, and how to extend
functionality.
-@item The chapter
-on @emph{Invoking} (@ref{Invoking LilyPond}) explains how to run LilyPond and its helper
+@item
+@ifhtml
+ The chapter
+@end ifhtml
+@emph{@ref{Invoking LilyPond}} explains how to run LilyPond and its helper
programs.
@end itemize
In that case, please file a bug report}, but the document is also
available in
@ifnothtml
-One Big Page,
+a big HTML page,
@end ifnothtml
@ifhtml
-@uref{One Big Page,../lilypond.html}
+@uref{../lilypond.html, a big HTML page}
@end ifhtml
-which is is available for text search using your browser's search
-facility.
+which can be searched easily using the search facility of a web
+browser.
@cindex search in manual
@cindex using the manual
-If you are familiar with music notation, and music terminology
+If you are not familiar with music notation, or music terminology
(especially if you are a foreigner), then it is advisable to consult
-the glossary as well. This documents explains many terms, and includes
-translations to various languages. It is a
+the glossary as well. The glossary explains musical terms, and
+includes translations to various languages. It is a
@ifhtml
@uref{../glossary.html,separate document}
@end ifhtml
@ifnothtml
-separate document, and can be printed as well.
+separate document, available in HTML and PDF and can be printed as
+well.
@end ifnothtml
@cindex idiom
@cindex jargon
(available @uref{../../../input/templates/out-www/collated-files.html,here})
@end ifhtml
- When you have gone through the tutorial, you theoretically should be
-able to start writing input files. However, this turns out to be a
-little intimidating. To give you a headstart, we have collected a
-number of often-used formats in example files. You can take one of
-these example files, and add notes in the appropriate places to
-generate output.
+When you have gone through the tutorial, in theory you are able to
+start writing input files. In practice, writing files from scratch
+turns out to be intimidating. To give a headstart, we have collected
+a number of often-used formats in example files. These files can be
+used as a start, by copying the template, and adding notes in the
+appropriate places.
@item
Various input examples
@end ifhtml
@cindex snippets
-These small files show various applications of lilypond, and are
-available as a big HTML document, with pictures and explanatory texts
-included.
+These small files show various tips and tricks, and are available as a
+big HTML document, with pictures and explanatory texts included.
@item
@end itemize
+
The location of the documentation files that are mentioned here can
-vary from system to system. Throughout this manual, we refer to input
-files relative to the top-directory of the source archive. For
+vary from system to system. On occasion, this manual refers to
+initialization and example files. Throughout this manual, we refer to
+input files relative to the top-directory of the source archive. For
example, @file{input/test/bla.ly} may refer to the file
@file{lilypond-1.7.19/input/test/bla.ly}. On binary packages for the
-Unix platform, these can typically be found somewhere below
-@file{/usr/share/doc/lilypond/}. Initialization files, for example
-@file{scm/lily.scm}, or @file{ly/engraver-init.ly}, are usually found
-in the directory @file{/usr/share/lilypond/}.
+Unix platform, the documentation and examples can typically be found
+somewhere below @file{/usr/share/doc/lilypond/}. Initialization files,
+for example @file{scm/lily.scm}, or @file{ly/engraver-init.ly}, are
+usually found in the directory @file{/usr/share/lilypond/}.
@cindex adjusting output
@cindex variables
@cindex extending lilypond
@cindex bugreport
@cindex index
+
+Finally, this and all other manuals, are available online both as PDF
+files for print and HTML files for browsing. They are available from
+the web site, which can be found at @uref{http://www.lilypond.org/}.
+
+@cindex website
+@cindex URL
@node Invoking LilyPond
@chapter Invoking LilyPond
+This chapter details the technicalities of running LilyPond.
+
+
@menu
+* Invoking the lilypond binary::
* Reporting bugs::
-* Website::
* Point and click::
* Invoking ly2dvi:: Titling LilyPond scores.
@end menu
+
+
+@node Invoking the lilypond binary
+@section Invoking the lilypond binary
@cindex Invoking LilyPond
@cindex command line options
@cindex options, command line
@cindex switches
-Usage:
+
+The LilyPond system consists of two parts: a binary executable, which
+is responsible for the formatting functionality, and support scripts,
+which post-process the resulting output. Normally, the support scripts
+are called, which in turn invoke the @code{lilypond} binary. However,
+@code{lilypond} may be called directly as follows.
@example
lilypond [@var{option}]@dots{} @var{file}@dots{}
-@cindex bugs
-@cindex reporting bugs
@node Reporting bugs
@section Reporting bugs
+@cindex bugs
+@cindex reporting bugs
+
+
+
Since there is no finder's fee which doubles every year, there is no
need to wait for the prize money to grow. Send a bug report today!
@end itemize
-You can send the report to @email{bug-lilypond@@gnu.org}. This is a
-mailinglist, but you do not have to be subscribed to it to post.
-
-@node Website
-@section Website
-
-If you are reading this manual in print, it is possible that the
-website contains updates to the manual. You can find the website at
-@uref{http://www.lilypond.org/}.
-
-
+You can send the report to @email{bug-lilypond@@gnu.org}.
@node Point and click
@section Point and click
* Tutorial:: A tutorial introduction.
* Notation manual:: All notation supported, and how to
produce it
-* Advanced topics:: How it all works.
+* Technical manual:: How it all works.
* Invoking LilyPond:: Operation.
* Converting from other formats:: Converting to lilypond source format.
* lilypond-book manual:: Integrating text and music with lilypond-book.
@node Preface to version 1.8
@unnumberedsec Preface to version 1.8
-During the past year when we worked on 1.8, the focus has not so much
-been on adding shiny new features, or more excellent
-typography. Instead, we have taken stock of how various things worked
-on the inside. In many cases, we found new and more elegant ways to
-implement these systems, making them more robust and more flexible.
-
If you are familiar with LilyPond version 1.6, then version 1.8 will
-no offer no big surprises. The only real change from 1.6 to 1.8 is the
-way that formatted text is entered. There is now a new syntax that is
-more friendly, more versatile and extensible. We hope you like it.
-
-Less visible changes include rewritten chord name formatting and entry
-code, revised music expression storage, and tighter integration
-between lilypond variables and Scheme variables.
+no offer no big surprises. The only conspicuous change is in the way
+that formatted text is entered. There is now a new syntax that is more
+friendly, more versatile and extensible. We hope you like it. In
+general, development on version 1.8 has been focused on improving the
+design of various internal mechanisms. This includes chord name
+formatting and entry code, music expression storage, and integration
+between LilyPond and Scheme. These changes may not be evident
+directly, but they make the program more robust and more flexible,
+which translates into fewer bugs and more adjustment options.
Special thanks for version 1.8 go out to Juergen Reuter for lots of
work on the ancient notation engine, and to Amy Zapf for pushing us to
This tutorial starts with a small introduction to the LilyPond music
language. After this first contact, we will show which commands to
run to produce printed output, so you should then be able to create
-your first sheets of music. The tutorial continues with more and more
-complex examples.
+your first sheets of music. When starting out, it will be convenient
+to print out
+@ifhtml
+the
+@end ifhtml
+@ref{Cheat sheet}, which is a table listing all commands for
+convenient reference.
+
@node First steps
and how to view or print the output. If you have not used LilyPond
before, want to test your setup, or want to run an example file
yourself, read this section. The instructions that follow are for
-Unix-like systems. Some additional instructions for MS Windows are given
+Unix-like systems. Some additional instructions for Microsoft Windows are given
at the end of this section.
Begin by opening a terminal window and starting a text editor.
@unnumberedsubsec Windows users
-Windows users can start the terminal by clicking on the LilyPond or
+On Windows, the terminal is started by clicking on the LilyPond or
Cygwin icon. Any text editor (such as NotePad, Emacs or Vim) may be
used to edit the LilyPond file. When Cygwin's @code{XFree86} X11
window system is installed along with @code{tetex-x11} and
@end quotation
@separate
-Beams are drawn automatically, but if you do not like the choices, you
-can enter beams by hand. Mark the first note to be beamed with
-@code{[} and the last one with @code{]}:
+Beams are drawn automatically, but if you do not like where they are
+put, they can be entered by hand. Mark the first note to be beamed
+with @code{[} and the last one with @code{]}:
@quotation
@lilypond[fragment,relative 1, verbatim]
a8-[ ais-] d-[ es r d-]
To print more than one staff, each piece of music that makes up a staff
is marked by adding @code{\context Staff} before it. These
-@code{Staff}'s are then grouped inside @code{<} and @code{>}, as is
+@code{Staff}'s are then grouped inside @code{\simultaneous @{} and @code{@}}, as is
demonstrated here:
@quotation
@lilypond[fragment,verbatim]
-<
+\simultaneous {
\context Staff = staffA { \clef violin c'' }
\context Staff = staffB { \clef bass c }
->
+}
@end lilypond
@end quotation
given to the staves. It does not matter what names you give, as long
as each staff has a different name. If you give them the same name,
they are assumed to belong on the same staff, and will be printed like
-that.
+that. @code{\simultaneous } indicates that both fragments happen at
+the same time, and must be printed stacked vertically.
@separate
@end lilypond
@end quotation
-Notice that the time signature is specified in one melody staff only
-(the top staff), but is printed on both. LilyPond knows that the time
-signature should be the same for all staves.
+The time signature is specified in one melody staff only
+(the top staff), but is printed on both, since common practice
+dictates that all staves have the same time signature.
@separate
A pickup (or upstep) is entered with the keyword @code{\partial}. It
-is followed by a duration: @code{\partial 4} is a quarter note upstep.
+is followed by a duration: @code{\partial 4} is a quarter note upstep
+and @code{\partial 8} an eighth note.
@lilypond[relative 1,verbatim,fragment]
\partial 8
f8 c2 d e
Tuplets are made with the @code{\times} keyword. It takes two
arguments: a fraction and a piece of music. The duration of the piece
of music is multiplied by the fraction. Triplets make notes occupy
-2/3 of their notated duration, so for a triplet, the fraction is 2/3.
+2/3 of their notated duration, so a triplet has 2/3 as its fraction.
@c
@lilypond[relative 0,verbatim,fragment]
\times 2/3 { f8 g a }
@end lilypond
-
+TODO: grace notes
Comments are pieces of the input that are ignored. There are two
types of comments. A line comments are introduced by @code{%}: after
\context Lyrics \lyrics @{ I want to break free @}
@end example
The melody for this song is as follows
+
@lilypond[fragment,relative=1]
\partial 8
c8
}
@end lilypond
+TODO: fix extender lines here.
+
Similarly, hyphens between words can be entered as two dashes,
resulting in a centered hyphen between two syllables.
@example
\addlyrics \notes \relative f' { \time 2/4
f4 f c' c' }
\context Lyrics \lyrics { Twin -- kle twin -- kle
- }}
+ }
+\paper { linewidth = 6.0 \cm }
+ }
+
@end lilypond
More options, like putting multiple lines of lyrics below a melody are
@lilypond[verbatim]
\chords { c2 f4. g8 }
@end lilypond
+
+@noindent
The result of @code{\chords} is a list of chords, and is equivalent
to entering chords with @code{<<@dots{}>>}.
< { a4 g2 f4-~ f4 } \\
{ r4 g4 f2 f4 } >
@end lilypond
-
-More features of polyphonic typesetting are in the notation manual,
-@ref{Polyphony}.
+The notation @code{< .. >} is a shorthand for @code{\simultaneous @{
+.. @}}. More features of polyphonic typesetting are in the notation
+manual, @ref{Polyphony}.
@node Piano staffs
@section Piano staffs
@lilypondfile[verbatim]{brahms-tweaked.ly}
-@node An orchestral score
-@section An orchestral score
-
-@menu
-* The full score::
-* Extracting an individual part::
-@end menu
-
-
-Our next two examples demonstrate one way to create an orchestral
-score in LilyPond. When typesetting a piece for several instruments,
-you will want to create a full score (for the conductor) along with
-several individual parts (for the players).
-
- We will declare the music for each instrument individually, giving
-the music of each instrument its own name. These pieces of music are
-then combined in different @code{\score} blocks to produce different
-combinations of instruments (for example, one @code{\score} block may
-only include the cello part; another @code{\score} block may be for
-all the strings, and yet another @code{\score} block may be for all
-parts together).
-
-This orchestral score example consists of three input files. In the
-first file, @file{os-music.ly}, we define the music for all
-instruments. This file will be used for producing the score and the
-separate parts, but the file does not produce any sheet music itself.
-Other files reference it by stating @code{\include "os-music.ly"}.
-
-@example
-% os-music.ly
-\header @{
- title = "Zo, goed lieverd?"
- subtitle = "How's, this babe?"
- composer = "JCN"
- opus = "1"
- piece = "Laid back"
-@}
-global = @{
- \time 2/4
- \skip 2*4 \bar "|."
-@}
-Key = \notes \key as \major
-flautoI = \notes\relative c'' @{
- f8 g f g f g f g
- bes as bes as bes as bes as
-@}
-flautoII = \notes\relative c'' @{
- as8 bes as bes R1 d4 ~ d
-@}
-tromboI = \notes\relative c'' @{
- c4. c8 c8 c4. es4 r as, r
-@}
-tromboII = \notes\relative c'' @{
- as4. as8 as8 as4. R1*1/2 as4 es'
-@}
-timpani = \notes\relative c, @{
- \times 2/3 @{ f4 f f @}
- \times 4/5 @{ as8 as as as as @}
- R1
-@}
-corno = \notes\relative c' @{
- bes4 d f, bes d f, bes d
-@}
-@end example
-
-We will not examine this example line by line, since you already know
-most of it. We'll examine a few lines which contain new elements.
-
-
-@separate
-@example
-global = @{
- \time 2/4
- \skip 2*4 \bar "|."
-@}
-@end example
-
-This declares settings to be used globally. The @code{\skip} command
-produces no output, but moves forward in time: in this case, the
-duration of a half note (@code{2}), and that four times (@code{*4}).
-This brings us to the end of the piece, and we can set the end bar.
-You can use @code{s} as a shortcut for @code{\skip} (the last line of
-this section would be @code{s2*4 \bar"|."}).
-
-@separate
-@example
-Key = \notes \key as \major
-@end example
-This declares the key signature of the piece and assign it to the
-identifier @var{Key}. Later on we will use @code{\Key} for all staves
-except those for transposing instruments.
-
-@node The full score
-@subsection The full score
+@node An orchestral part
+@section An orchestral part
-The second file, @inputfileref{input/tutorial,os-score.ly}, reads the
-definitions of the first (@inputfileref{input/tutorial,os-music.ly}), and
-defines the @code{\score} block for the full conductor's score.
+TODO:
-@example
-\version "1.7.6"
-
-\include "os-music.ly"
-\include "paper13.ly"
-
-textFlat = \markup @{\smaller \musicglyph #"accidentals--1"@}
-\score @{
- <
- \global
- \property Score.BarNumber \override #'padding = #3
- \context StaffGroup = woodwind <
- \context Staff = flauti <
- \property Staff.midiInstrument = #"flute"
- \property Staff.instrument = "2 Flauti"
- \property Staff.instr = "Fl."
- \Key
- \context Voice=one @{ \voiceOne \flautoI @}
- \context Voice=two @{ \voiceTwo \flautoII @}
- >
- >
- \context StaffGroup = timpani <
- \context Staff = timpani <
- \property Staff.midiInstrument = #"timpani"
- \property Staff.instrument = \markup @{ \column << "Timpani" "(C-G)" >> @}
- \property Staff.instr = #"Timp."
- \clef bass
- \Key
- \timpani
- >
- >
- \context StaffGroup = brass <
- \context Staff = trombe <
- \property Staff.midiInstrument = #"trumpet"
- \property Staff.instrument = \markup @{ \column << "2 Trombe" "(C)" >> @}
- \property Staff.instr = \markup@{ \column << "Tbe." "(C)">> @}
- \Key
- \context Voice=one \partcombine Voice
- \context Thread=one \tromboI
- \context Thread=two \tromboII
- >
- \context Staff = corni <
- \property Staff.midiInstrument = #"french horn"
- \property Staff.instrument
- = \markup @{ \column << "Corno" @{ "(E" \textFlat ")" @} >> @}
- \property Staff.instr =
- \markup @{ \column << "Cor." @{ "(E" \textFlat ")" @} >> @}
- \property Staff.transposing = #3
- \notes \key bes \major
- \context Voice=one \corno
- >
- >
- >
- \paper @{
- indent = 15 * \staffspace
- linewidth = 60 * \staffspace
- textheight = 90 * \staffspace
- \translator@{
- \VoiceContext
- \consists "Multi_measure_rest_engraver"
- @}
- \translator@{
- \HaraKiriStaffContext
- \remove "Multi_measure_rest_engraver"
- @}
- @}
- \midi @{
- \tempo 4 = 75
- @}
-@}
-@end example
-
-@center @strong{Zo, goed lieverd?}
-@sp 1
-@center How's, this babe?
-@flushright
-Opus 1.
-@end flushright
-@flushleft
-@sc{Laid back}
-@end flushleft
-
-@lilypondfile{os-score.ly}
-
-@separate
-@example
-\include "os-music.ly"
-@end example
-First we need to include the music definitions we made in
-@file{os-music.ly}.
-
-@ignore
-
-[TODO: mention in a more relevant place]
-
-@separate
-@example
-#(ly:set-point-and-click 'line-column)
-@end example
-
-This piece of Scheme code executes the function
-@code{ly:set-point-and-click} with the argument
-@code{line-column}. Editing input files can be complicated if you are
-working with large files: if you are digitizing existing music, you have
-to synchronize the .ly file, the sheet music on your lap and the sheet
-music on the screen. The point-and-click mechanism makes it easy to
-find the origin of an error in the LY file: when you view the file with
-Xdvi and click on a note, your editor will jump to the spot where that
-note was entered. For more information, see @ref{Point and click}.
-@end ignore
-
-
-@separate
-@example
-#(define text-flat '((font-relative-size . -2)
- (music "accidentals--1")))
-@end example
-
-To name the transposition of the french horn, we will need a piece of
-text with a flat sign. LilyPond has a mechanism for font selection and
-kerning called Scheme markup text (See @ref{Text markup}). The flat
-sign is taken from the music font, and its name is @code{accidentals--1}
-(The natural sign is called @code{accidentals-0}). The default font is
-too big for text, so we select a relative size of @code{-2}.
-
-@separate
-@example
- <
- \global
-@end example
-All staves are simultaneous and use the same global settings.
-
-@separate
-@example
- \property Score.BarNumber \override #'padding = #3
-@end example
-LilyPond prints bar numbers at the start of each line, but
-unfortunately they end up a bit too close to the staff in this
-example. In LilyPond, a bar number is called @var{BarNumber}.
-BarNumber objects can be manipulated through their
-@var{side-position-interface}. One of the properties of a
-@var{side-position-interface} that can be tweaked is @var{padding}:
-the amount of extra space that is put between this and other objects.
-We set the padding to three staff spaces.
-
-You can find information on all these kind of properties in LilyPond's
-automatically generated documentation in
-@ifnottex
-@ref{ (lilypond-internals)lilypond-internals, LilyPond Internals}
-or in @ref{Fine tuning a piece}.
-@end ifnottex
-@iftex
-the online documentation or in the previous section of the tutorial.
-@end iftex
-
-@c REFERENCE MAO
-
-@separate
-@example
- \context StaffGroup = woodwind <
- \context Staff = flauti <
-@end example
-A new notation context: the @code{StaffGroup}. @code{StaffGroup} can
-hold one or more @code{Staff}s, and will print a big bracket at the
-left of the score. This starts a new staff group for the woodwind
-section (just the flutes in this case). Immediately after that, we
-start the staff for the two flutes, who also play simultaneously.
-
-@separate
-@example
- \property Staff.midiInstrument = #"flute"
-@end example
-Specify the instrument for MIDI output (see @ref{MIDI instrument
-names}).
-
-@separate
-@example
- \property Staff.instrument = "2 Flauti"
- \property Staff.instr = "Fl."
-@end example
-This defines the instrument names to be printed in the
-margin. @code{instrument} specifies the name for the first line
-of the score, @code{instr} is used for the rest of the score.
-
-@separate
-@example
- \Key
-@end example
-The flutes play in the default key.
-
-@separate
-@example
- \context Voice=one @{ \voiceOne \flautoI @}
- \context Voice=two @{ \voiceTwo \flautoII @}
-@end example
-Last come the actual flute parts. Remember that we are still in
-simultaneous mode. We name both voices differently, so that LilyPond
-will create two Voice contexts. The flute parts are simple, so
-we specify manually which voice is which: @code{\voiceOne} forces the
-direction of stems, beams, slurs and ties up, @code{\voiceTwo} sets
-directions down.
-
-@separate
-@example
- >
- >
-@end example
-Close the flutes staff and woodwind staff group.
-
-@separate
-@example
- \property Staff.instrument = #'(lines "Timpani" "(C-G)")
-@end example
-The timpani staff demonstrates a new piece of scheme markup, it sets two
-lines of text.
-
-@separate
-@example
- \context Voice=one \partcombine Voice
- \context Thread=one \tromboI
- \context Thread=two \tromboII
-@end example
-You have seen the notation contexts Staff and Voice, but here is a new
-one: Thread. One or more Threads can be part of a Voice. Thread
-takes care of note heads and rests; Voice combine note heads onto a
-stem.
-
-For the trumpets we use the automatic part combiner (see @ref{Automatic
-part combining}) to combine the two simultaneous trumpet parts onto the
-trumpet staff. Each trumpet gets its own Thread context, which must be
-named @code{one} and @code{two}). The part combiner makes these two
-threads share a Voice when they are similar, and splits the threads up
-when they are different.
-
-@separate
-@example
-\property Staff.instrument = #`(lines "Corno"
- (columns "(E" ,text-flat ")"))
-@end example
-The french horn (``Corno'') has the most complex scheme markup name, made
-up of two lines of text. The second line has three elements (columns) --
-the @code{(E}, the flat sign @code{text-flat} that we defined previously,
-and a final @code{")"}. We use a backquote instead of an
-ordinary quote at the beginning of the Scheme expression to be able to
-access the @code{text-flat} identifier, `unquoting' it with a ``@code{,}''.
-
-@separate
-@example
- \property Staff.transposing = #3
-@end example
-The french horn is to be tuned in E-flat, so we tell the MIDI back-end to
-transpose this staff by three steps.
-
-Note how we can choose different tunings for the text input, sheet music
-output and, and MIDI output, using @code{\transpose} and the MIDI Staff
-property @var{transposing}.
-
-@separate
-@example
- \notes \key bes \major
-@end example
-Since the horn is transposing, it is in a different key.
-
-@separate
-@example
- indent = 15 * \staffspace
- linewidth = 55 * \staffspace
-@end example
-We specify a big indent for the first line and a small linewidth for this
-tutorial.
-
-@separate
-
-Usually the default setup of notation contexts (Thread, Voice, Staff,
-Staffgroup, Score) is just fine. But in this case we want a different
-type of Staff context.
-
-@example
- \translator@{
- \HaraKiriStaffContext
- @}
-@end example
-
-In orchestral scores it often happens that one instrument only has
-rests during one line of the score. @code{HaraKiriStaffContext} can
-be used as a regular @code{StaffContext} drop-in and will take care of
-the automatic removing of empty staves -- so if the strings are the
-only instruments playing for a line, LilyPond will only print the string
-parts for that line of the score. This reduces the number of page turns
-(and the number of dead trees!) required in a score.
-
-@node Extracting an individual part
-@subsection Extracting an individual part
-
-The third file, @file{os-flute-2.ly} also reads the definitions of the
-first (@file{os-music.ly}), and defines the @code{\score} block for the
-second flute part.
-
-@example
-\include "os-music.ly"
-\include "paper16.ly"
-
-\score @{
- \context Staff <
- \property Score.skipBars = ##t
- \property Staff.midiInstrument = #"flute"
- \global
- \Key
- \flautoII
- >
- \header @{
- instrument = "Flauto II"
- @}
- \paper @{
- linewidth = 80 * \staffspace
- textheight = 200 * \staffspace
- @}
- \midi @{
- \tempo 4 = 75
- @}
-@}
-@end example
-
-@center @strong{Zo, goed lieverd?}
-@sp 1
-@center How's, this babe?
-@center @emph{Flauto II}
-@flushright
-Opus 1.
-@end flushright
-@flushleft
-@sc{Laid back}
-@end flushleft
-@lilypondfile{os-flute-2.ly}
-
-
-Because we separated the music definitions from the @code{\score}
-instantiations, we can easily define a second score with the music of
-the second flute. This is the part for the second flute player. Of
-course, we would make separate parts for all individual instruments if
-we were preparing the score for an orchestra.
-
-@separate
-@example
- \flautoII
-@end example
-In this individual part the second flute has a whole staff for itself,
-so we do not want to force stem or tie directions.
-
-@separate
-@example
- \header @{
- instrument = "Flauto II"
- @}
-@end example
-The @code{\header} definitions were also read from @file{os-music.ly},
-but we need to set the instrument for this particular score.
-
-@separate
-@example
- \property Score.skipBars = ##t
-@end example
-In the conductor's full score, all bars with rests are printed, but for
-the individual parts, we want to print one multimeasure rest instead of
-many consecutive empty bars. LilyPond will do this if
-@code{Score.skipBars} is set to true (@code{##t}).
+\markup, mmrest, transposing, cue notes, identifiers?.
@node Integrating text and music
If you include large examples into the text, it may be more convenient
to put the example in a separate file:
-\lilypondfile[printfilename]{sammartini.ly}
+\lilypondfile[printfilename]{screech-boink.ly}
The \texttt{printfilename} option adds the file name to the output.
SCM style = me->get_grob_property ("style");
if (!gh_symbol_p (style))
{
- return Molecule();
+ return Molecule ();
}
SCM log = gh_int2scm (Note_head::get_balltype (me));
### some versions apparently choke on $(message)
### $(message running from source tree stepmake)
+
+
+### Some versions of What? --hwn
+
ABC2LY = $(script-dir)/abc2ly.py
CONVERT_LY = $(script-dir)/convert-ly.py
LILYPOND = $(builddir)/lily/$(outconfbase)/lilypond
return gr
-def make_preview (name):
- ## ly2dvi/lilypond-book discrepancy
- preview_ps = name + '.preview.ps'
- if not os.path.isfile (preview_ps):
- preview_ps = name + '.eps'
- bbox = get_bbox (preview_ps)
- trans_ps = name + '.trans.ps'
- png = name + '.png'
+
+def make_ps_images (ps_name, resolution = 90):
+
+
+ ## todo:
+ ## have better algorithm for deciding when to crop page,
+ ## and when to show full page
- margin = 0
- fo = open (trans_ps, 'w')
- fo.write ('%d %d translate\n' % (-bbox[0] + margin,
- -bbox[1] + margin))
- fo.close ()
+ single_page = re.search ('^%%Pages: 1', open (ps_name).read (1024))
+ cmd = ''
+
+ if single_page:
+ bbox = get_bbox (ps_name)
+ trans_ps = ps_name + '.trans.ps'
+ output_file = re.sub (r'\.e?ps', '.png', ps_name)
- x = (2* margin + bbox[2] - bbox[0]) \
- * __main__.preview_resolution / 72.0
- y = (2* margin + bbox[3] - bbox[1]) \
- * __main__.preview_resolution / 72.0
- if x == 0:
- x = 1
- if y == 0:
- y = 1
-
- cmd = r'''gs -g%dx%d -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -r%d -dNOPAUSE %s %s -c quit ''' % \
- (x, y, png, __main__.preview_resolution, trans_ps, preview_ps)
+
+ margin = 0
+ fo = open (trans_ps, 'w')
+ fo.write ('%d %d translate\n' % (-bbox[0] + margin,
+ -bbox[1] + margin))
+ fo.close ()
+
+ x = (2* margin + bbox[2] - bbox[0]) \
+ * resolution / 72.0
+ y = (2* margin + bbox[3] - bbox[1]) \
+ * resolution / 72.0
+ if x == 0:
+ x = 1
+ if y == 0:
+ y = 1
+
+ cmd = r'''gs -g%dx%d -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -r%d -dNOPAUSE %s %s -c quit ''' % \
+ (x, y, output_file, resolution, trans_ps, ps_name)
+ else:
+ output_file = re.sub (r'\.e?ps', '-page%d.png', ps_name)
+
+
+ cmd = r'''gs -s -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -dNOPAUSE -r%d %s -c quit''' % (output_file,
+ resolution, ps_name)
status = system (cmd)
signal = 0xf & status
os.unlink (png)
error (_ ("Removing output file"))
exit (1)
-
-def make_page_images (name, resolution = 90):
-
- """ Generate images for
- all pages in the PS file NAME. NAME should be the basename
- (not including the extension.).
- """
-
- cmd = 'gs -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile="%s-page%%d.png" -r%d -dNOPAUSE %s -c quit'
- cmd = cmd % (name, resolution, name + '.ps')
- system (cmd)
## inline music doesn't.
## possibly other center options?
'output-html': r'''
-<a href="%(fn)s.ly">
-<img align="center" valign="center" border="0" src="%(fn)s.png" alt="[picture of music]"></a>
-''',
+%(pageimages)s''',
},
\catcode`\@=0
@end tex
@html
-<p><a href="%(fn)s.ly">
-<img border=0 src="%(fn)s.png" alt="[picture of music]">
-</a><p>
+<p>%(htmlimages)s
+<p>
@end html
''',
'output-texi-quoted': r'''@quotation
\catcode`\@=0
@end tex
@html
-<a href="%(fn)s.ly">
-<img border=0 src="%(fn)s.png" alt="[picture of music]">
-</a>
+<p>%(htmlimages)s
+<p>
@end html
@end quotation
''',
return newchunks
def determine_format (str):
+ """
+
+ SIDE EFFECT! This sets FORMAT and PAPERGURU
+
+ """
+
global format
if format == '':
html = re.search ('(?i)<[dh]tml', str[:200])
def schedule_lilypond_block (chunk):
'''Take the body and options from CHUNK, figure out how the
- real .ly should look, and what should be left MAIN_STR (meant
- for the main file). The .ly is written, and scheduled in
+ real .ly should look. The .ly is written, and scheduled in
TODO.
- Return: multiple chunks.
+ Return: a single chunk.
The chunk pertaining to the lilypond output
has the format (TYPE_STR, MAIN_STR, OPTIONS, TODO, BASE),
where TODO has format [basename, extension, extension, ... ]
'''
- return_chunks = []
-
(type, body, opts) = chunk
assert type == 'lilypond'
file_body = compose_full_body (body, opts)
todo.append ('eps')
if 'png' in needed_filetypes and f (pathbase, '.eps', '.png'):
todo.append ('png')
- newbody = ''
+ return ('lilypond', body, opts, todo, basename)
+
+def format_lilypond_block (chunk):
+ """
+
+ Figure out what should be left MAIN_STR (meant
+ for the main file) from a lilypond chunk: process
+ verbatim, and other options. Return: multiple chunks.
+
+
+ """
+
+
+ return_chunks = []
+
+ (type, body, opts, todo, basename) = chunk
+ assert type == 'lilypond'
+
+
+ newbody = ''
filename_chunk = None
if 'printfilename' in opts:
for o in opts:
s = 'output-texi-noquote'
else: # format == 'html'
s = 'output-html'
- newbody = newbody + get_output (s) % {'fn': basename }
+
+ def html_pages (basename):
+ files = glob.glob ("%s-page*.png"% basename)
+
+ template = '''<img align="center" valign="center"
+ border="0" src="%s" alt="[picture of music]">'''
+
+ str = ''
+ if not files:
+ files = [basename+'.png' ]
+ for f in files:
+ str += template % f
+
+ str = '<a href="%s.ly">%s</a>' % (basename, str)
+ return str
+
+ newbody = newbody + get_output (s) % {'fn': basename,
+ 'htmlimages': html_pages(basename)
+ }
if filename_chunk:
return_chunks += [filename_chunk]
return return_chunks
+def format_lilypond_output_bodies (chunks):
+ newchunks = []
+ for c in chunks:
+
+ if c[0] == 'lilypond':
+ newchunks += format_lilypond_block (c)
+ else:
+ newchunks.append (c)
+
+ return newchunks
newchunks = []
# Count sections/chapters.
for c in chunks:
- cs = [c]
if c[0] == 'lilypond':
- cs = schedule_lilypond_block (c)
+ c = schedule_lilypond_block (c)
elif c[0] == 'numcols':
paperguru.m_num_cols = c[2]
elif c[0] == 'multicols':
paperguru.m_multicols = c[2]
- newchunks += cs
+ newchunks.append (c)
return newchunks
for c in chunks:
if c[0] != 'lilypond':
continue
+
base = c[4]
exts = c[3]
for e in exts:
ly.system ("dvips -E -o %s.eps %s" % (file, file))
map (to_eps, eps)
- map (ly.make_preview, png)
+ map (lambda x: ly.make_ps_images (x + '.eps'), png)
os.chdir (d)
if format == 'texi':
chunks = check_texidoc (chunks)
+ chunks = format_lilypond_output_bodies (chunks)
+
+
x = 0
chunks = completize_preamble (chunks)
ly.setup_environment ()
+
for input_filename in files:
do_file (input_filename)
if preview_p:
for score in find_tex_files (files, extra_init):
preview_base = ly.strip_extension (score[0], '.tex')
- ly.make_preview (preview_base)
+ ly.make_ps_images (preview_base + '.preview.ps',
+ resolution=preview_resolution
+ )
if 'PDFTEX' in targets:
try:
ly.warning (_("Running LaTeX falied. Rerun with --verbose for a trace."))
if page_images_p:
- ly.make_page_images (outbase)
+ ly.make_ps_images (outbase)
# add DEP to targets?
if track_dependencies_p: