(~ 2 Mb, in <a class="title" href="../input/test/collated-files.pdf">PDF</a>)
<br>(for advanced users)
+
+<li><a class="title" href="../input/lsr/collated-files.html">Snippets</a>
+ <br>(current in development)
+
<li><a class="title" href="user/music-glossary/index.html">Glossary</a>
(in <a class="title" href="user/music-glossary.html">one big page</a> ~ 1 Mb,
in <a class="title" href="user/music-glossary.pdf">PDF</a>)
@end macro
@end ifnothtml
-
@macro textanchor{NAME}
@html
<a name="\NAME\"></a>
* only show user-visible changes.
@end ignore
+
@item
Notes or rests, such as a typical end note, that fill an entire
measure are preceded by some more space.
-@lilypond[ragged-right,relative=1]
-{
+@lilypond[ragged-right]
+\relative c' {
\time 4/4
s1
c2. c4
@menu
* Pitches::
* Rhythms::
-* Multiple notes at once::
+* Polyphony::
* Staff notation::
* Connecting notes::
* Expressive marks::
* Accidentals::
* Cautionary accidentals::
* Micro tones::
-* Notes names in other languages::
+* Note names in other languages::
* Relative octaves::
* Octave check::
* Transpose::
E-natural, and an F-natural,} regardless of the key
signature. For more information about the distinction between
musical content and the presentation of that content, see
-@ref{More about pitches}.
+@ref{Accidentals and key signatures}.
@lilypond[fragment,quote,ragged-right,verbatim,relative]
\key d \major
standard.
-@node Notes names in other languages
-@subsection Notes names in other languages
+@node Note names in other languages
+@subsection Note names in other languages
There are predefined sets of note names for various other languages.
To use them, include the language specific init file. For
Program reference: @internalsref{Completion_heads_engraver}.
-@node Multiple notes at once
-@section Multiple notes at once
+@node Polyphony
+@section Polyphony
Polyphony in music refers to having more than one voice occurring in
a piece of music. Polyphony in LilyPond refers to having more than
Accidentals and key signatures often confuse new users, because
unaltered notes get natural signs depending on the key signature. For
-more information, see @ref{Accidentals} or @ref{More about pitches}.
+more information, see @ref{Accidentals} or @ref{Accidentals and key signatures}.
@lilypond[quote,ragged-right,verbatim,relative=2,fragment]
\key g \major
@menu
* Setting simple songs::
* Entering lyrics::
-* Hyphens and extenders::
+* Hyphens and extenders::
* The Lyrics context::
* Melismata::
* Another way of entering lyrics::
\relative { c2 e4 g2 e4 }
\addlyrics { gran- de_a- mi- go }
\addlyrics { pu- "ro y ho-" nes- to }
-\addlyrics { pu- ro~yho- nes- to }
+\addlyrics { pu- ro~y~ho- nes- to }
@end lilypond
The lyric ties is implemented with the Unicode character U+203F, so be
must be set one syllable @emph{before} the non-melismatic syllable
in the text, as shown here,
+@c FIXME: breaks compile
@lilypond[verbatim,ragged-right,quote]
+%{
<<
\relative \new Voice = "lahlah" {
\set Staff.autoBeaming = ##f
still
}
>>
+%}
@end lilypond
@node More about stanzas
@subsection More about stanzas
+@c what's this doing here?
@cindex phrasing, in lyrics
-
@cindex stanza number
-@cindex singer's names
-@cindex name of singer
+@subsubsection Adding stanza numbers
Stanza numbers can be added by setting @code{stanza}, e.g.,
}
@end lilypond
-These numbers are put just before the start of first syllable.
+@noindent
+These numbers are put just before the start of the first syllable.
+
+
+@subsubsection Adding dynamics marks
+
+Stanzas differing in loudness may be indicated by putting a
+dynamics mark before each stanza. In Lilypond, everthing coming in
+front of a stanza goes into the @code{StanzaNumber} object; dynamics marks
+are no different. For technical reasons, you have to set the stanza
+outside @code{\lyricmode}:
+
+@lilypond[quote,ragged-right,verbatim]
+text = {
+ \set stanza = \markup { \dynamic "ff" "1. " }
+ \lyricmode {
+ Big bang
+ }
+}
+
+<<
+ \new Voice = "tune" {
+ \time 3/4
+ g'4 c'2
+ }
+\new Lyrics \lyricsto "tune" \text
+>>
+@end lilypond
+
+@cindex singer name
+@cindex name of singer
+@subsubsection Adding singer names
+
+Names of singers can also be added. They are printed at the start of
+the line, just like instrument names. They are created by setting
+@code{vocalName}. A short version may be entered as @code{shortVocalName}.
+
+@lilypond[fragment,ragged-right,quote,verbatim,relative=2]
+\new Voice {
+ \time 3/4 g2 e4 a2 f4 g2.
+} \addlyrics {
+ \set vocalName = "Bert "
+ Hi, my name is Bert.
+} \addlyrics {
+ \set vocalName = "Ernie "
+ Oh, che -- ri, je t'aime
+}
+@end lilypond
+
+
+@subsubsection Printing stanzas at the end
Sometimes it is appropriate to have one stanza set
to the music, and the rest added in verse form at
@end lilypond
-Names of singers can also be added. They are printed at the start of
-the line, just like instrument names. They are created by setting
-@code{vocalName}. A short version may be entered as @code{shortVocalName}.
-
-
-@lilypond[fragment,ragged-right,quote,verbatim,relative=2]
-\new Voice {
- \time 3/4 g2 e4 a2 f4 g2.
-} \addlyrics {
- \set vocalName = "Bert "
- Hi, my name is Bert.
-} \addlyrics {
- \set vocalName = "Ernie "
- Oh, che -- ri, je t'aime
-}
-@end lilypond
-
+@subsubsection Printing stanzas at the end in multiple columns
When a piece of music has many verses, they are often printed in
multiple columns across the page. An outdented verse number often
a list of color names, and the Feta font.
@item
-@emph{@ref{Example templates}}
-provides templates of LilyPond pieces. Just cut and paste a
+@emph{@ref{Templates}}
+of LilyPond pieces. Just cut and paste a
template into a file, add notes, and you're done!
@item
* Literature list:: Reference works about music notation.
* Scheme tutorial:: Programming inside LilyPond.
* Notation manual tables:: Tables and charts.
-* Example templates:: Ready-made templates.
+* Templates:: Ready-made templates.
* Cheat sheet:: Summary of LilyPond syntax.
* GNU Free Documentation License:: License of this document.
* LilyPond command index::
@end macro
+@macro moreinfo
+@subheading More information
+
+@end macro
+
@macro seealso
@noindent
@subsubheading See also
* alto::
* alto clef::
* ambit::
+* anacrusis::
* ancient minor scale::
* andante::
* appoggiatura::
* arpeggio::
+* articulation::
* ascending interval::
* augmented interval::
* autograph::
of pitches for a given voice in a part of music. It may also denote
the pitch range that a musical instrument is capable of playing.
+@node anacrusis
+@section anacrusis
+
+@c TODO: add more languages for anacrusis
+F: anacrouse
+
+An anacrusis (also known as pickup or upbeat) is an incomplete measure
+of music before a section of music.
+
@node ancient minor scale
@section ancient minor scale
>>
@end lilypond
+@node articulation
+@section articulation
+
+@c TODO: add languages for articulation.
+Articulation refers to notation which indicates how a note or notes should
+be played. Slurs, accents, staccato, and legato are all examples of
+articulartion.
+
+
@node ascending interval
@section ascending interval
\context @{
\Voice
\remove "Dynamic_performer"
- \remove "Span_dynamic_performer"
@}
@}
@end example
* Extending the templates::
* How LilyPond files work::
* Score is a single musical expression::
+* An orchestral part::
@end menu
text editor!
+
+
+
+
+@node An orchestral part
+@section An orchestral part
+
+In orchestral music, all notes are printed twice. Once in a part for
+the musicians, and once in a full score for the conductor. Identifiers can
+be used to avoid double work. The music is entered once, and stored in
+a variable. The contents of that variable is then used to generate
+both the part and the full score.
+
+It is convenient to define the notes in a special file. For example,
+suppose that the file @file{horn-music.ly} contains the following part
+of a horn/@/bassoon duo
+
+@example
+hornNotes = \relative c @{
+ \time 2/4
+ r4 f8 a cis4 f e d
+@}
+@end example
+
+@noindent
+Then, an individual part is made by putting the following in a file
+
+@example
+\include "horn-music.ly"
+\header @{
+ instrument = "Horn in F"
+@}
+
+@{
+ \transpose f c' \hornNotes
+@}
+@end example
+
+The line
+
+@example
+\include "horn-music.ly"
+@end example
+
+@noindent
+substitutes the contents of @file{horn-music.ly} at this position in
+the file, so @code{hornNotes} is defined afterwards. The command
+@code{\transpose f@tie{}c'} indicates that the argument, being
+@code{\hornNotes}, should be transposed by a fifth upwards. Sounding
+@samp{f} is denoted by notated @code{c'}, which corresponds with the
+tuning of a normal French Horn in@tie{}F. The transposition can be seen
+in the following output
+
+@lilypond[quote,ragged-right]
+\transpose f c' \relative c {
+ \time 2/4
+ r4 f8 a cis4 f e d
+}
+@end lilypond
+
+In ensemble pieces, one of the voices often does not play for many
+measures. This is denoted by a special rest, the multi-measure
+rest. It is entered with a capital @samp{R} followed by a duration
+(@code{1}@tie{}for a whole note, @code{2}@tie{}for a half note,
+etc.). By multiplying the
+duration, longer rests can be constructed. For example, this rest
+takes 3@tie{}measures in 2/4 time
+
+@example
+R2*3
+@end example
+
+When printing the part, multi-rests
+must be condensed. This is done by setting a run-time variable
+
+@example
+\set Score.skipBars = ##t
+@end example
+
+@noindent
+This command sets the property @code{skipBars} in the
+@code{Score} context to true (@code{##t}). Prepending the rest and
+this option to the music above, leads to the following result
+
+@lilypond[quote,ragged-right]
+\transpose f c' \relative c {
+ \time 2/4
+ \set Score.skipBars = ##t
+ R2*3
+ r4 f8 a cis4 f e d
+}
+@end lilypond
+
+
+The score is made by combining all of the music together. Assuming
+that the other voice is in @code{bassoonNotes} in the file
+@file{bassoon-music.ly}, a score is made with
+
+@example
+\include "bassoon-music.ly"
+\include "horn-music.ly"
+
+<<
+ \new Staff \hornNotes
+ \new Staff \bassoonNotes
+>>
+@end example
+
+@noindent
+leading to
+
+@lilypond[quote,ragged-right]
+\relative c <<
+ \new Staff {
+ \time 2/4 R2*3
+ r4 f8 a cis4 f e d
+ }
+ \new Staff {
+ \clef bass
+ r4 d,8 f | gis4 c | b bes |
+ a8 e f4 | g d | gis f
+ }
+>>
+@end lilypond
+
+More in-depth information on preparing parts and scores can be found
+in the notation manual; see @ref{Orchestral music}.
+
+Setting run-time variables (@q{properties}) is discussed in
+@ref{Changing context properties on the fly}.
+
+
+
Create a file called @code{lilypond} which contains
@example
-exec @var{path/to}/LilyPond.app/Contents/Resources/bin/lilypond "$@"
+exec @var{path/to}/LilyPond.app/Contents/Resources/bin/lilypond "$@@"
@end example
Create similar files @code{lilypond-book}, @code{convert-ly}, and
@uref{http://lilypond.org/web/devel/participating/bugs}
+Please construct submit @ref{Minimal examples} of bug reports. We do not
+have the resources to investigate reports which are not as small as possible.
+
@node Error messages
@section Error messages
@end ifnothtml
-@item JEdit
+@item LilyPondTool
-The @uref{http://@/www@/.jedit@/.org@/,jEdit} editor has a LilyPond plugin.
-This plugin includes a DVI viewer, integrated help and viewing via
-GhostScript. It can be installed by doing @key{Plugins > Plugin
-Manager}, and selecting @code{LilyTool} from the @key{Install} tab.
+Created as a plugin for the @uref{http://@/www@/.jedit@/.org@/,jEdit} text
+editor, LilyPondTool is the most feature-rich text-based tool for editing
+LilyPond scores. Its features include a Document Wizard with lyrics
+support to set up documents easier, and embedded PDF viewer with advanced
+point-and-click support. For screenshots, demos and installation
+instructions, visit @uref{http://lilypondtool@/.organum@/.hu}
@end table
@menu
* Vertical spacing inside a system::
-* Vertical spacing of piano staves::
* Vertical spacing between systems::
* Controlling spacing of individual systems::
* Two-pass vertical spacing::
@inputfileref{input/regression/,alignment-vertical-spacing.ly}.
-@node Vertical spacing of piano staves
-@subsection Vertical spacing of piano staves
-
-The distance between staves of a @internalsref{PianoStaff} cannot be
-computed during formatting. Rather, to make cross-staff beaming work
-correctly, that distance has to be fixed beforehand.
-
-The distance of staves in a @code{PianoStaff} is set with the
-@code{forced-distance} property of the
-@internalsref{VerticalAlignment} object, created in
-@internalsref{PianoStaff}.
-
-It can be adjusted as follows
-@example
-\new PianoStaff \with @{
- \override VerticalAlignment #'forced-distance = #7
-@} @{
- ...
-@}
-@end example
-
-@noindent
-This would bring the staves together at a distance of 7 staff spaces,
-measured from the center line of each staff.
-
-The difference is demonstrated in the following example,
-@lilypond[quote,verbatim]
-\relative c'' <<
- \new PianoStaff \with {
- \override VerticalAlignment #'forced-distance = #7
- } <<
- \new Staff { c1 }
- \new Staff { c }
- >>
- \new PianoStaff <<
- \new Staff { c }
- \new Staff { c }
- >>
->>
-@end lilypond
-
-
-@seealso
-
-Example files: @inputfileref{input/regression/,alignment-vertical-spacing.ly}.
-
-
@node Vertical spacing between systems
@subsection Vertical spacing between systems
version that you are working on. See TRANSLATION for details.
@end ignore
-@node Example templates
-@appendix Example templates
+@node Templates
+@appendix Templates
This section of the manual contains templates with the LilyPond score
already set up for you. Just add notes, run LilyPond, and enjoy
\context {
\PianoStaff
\accepts Dynamics
- \override VerticalAlignment #'forced-distance = #7
}
}
}
version that you are working on. See TRANSLATION for details.
@end ignore
+@ignore
+Tutorial guidelines:
+- unless you have a really good reason, use either
+ @l ilypond[quote,ragged-right,verbatim]
+ or
+ @l ilypond[quote,ragged-right,verbatim,fragment,relative=2]
+ (without spaces)
+ Don't use any other relative=X commands (make it a non-fragment
+ example), and don't use fragment without relative=2.
+- use "aes" and "ees" instead of "as" and "aes". I know it's not
+ correct Dutch naming, but let's not confuse people with this until
+ we get to the Basic notation chapter.
+@end ignore
+
+
+
+@c old info that will probably be removed.
@c TODO:
@c * more details about running lilypond; error messages,
@c compiling/viewing (emacs?)
LilyPond input that was used to generate that image.
Try it on this image
-@lilypond[fragment,quote,ragged-right,relative=2]
-c-\markup { \bold \huge { Click here. } }
+@c no verbatim here
+@lilypond[quote,ragged-right]
+\relative c'' {
+ c-\markup { \bold \huge { Click here. } }
+}
@end lilypond
-@end ifhtml
-By cutting and pasting the full input into a test file, you have a
+By cutting and pasting everything in the @qq{ly snippet} section, you have a
starting template for experiments. If you like learning in this way,
-you will probably want to print out or bookmark
-@ifhtml
-the
-@end ifhtml
+you will probably want to print out or bookmark the
@ref{Cheat sheet}, which is a table listing of the most common
commands for quick reference.
+@end ifhtml
@menu
* First steps::
-* Second steps::
-* More about pitches::
-* Entering ties::
-* Automatic and manual beams::
-* Octave entry::
-* Music expressions explained::
-* More staves::
-* Adding articulation marks to notes::
-* Combining notes into chords::
-* Advanced rhythmic commands::
-* Commenting input files::
-* Printing lyrics::
-* A lead sheet::
-* Adding titles::
-* Single staff polyphony::
-* Piano staves::
-* Organizing larger pieces::
-* An orchestral part::
-* After the tutorial::
+* Single staff notation::
+* Multiple notes at once::
+* Songs::
+* Final touches::
@end menu
@node First steps
@section First steps
-The first example demonstrates how to enter the most elementary piece
-of music, a @rglos{scale}. A @rglos{note} can be entered by typing
-its name, from @samp{a} through @samp{g}. So, if you enter
+This section gives a basic introduction to working with LilyPond.
+
+@menu
+* Compiling a file::
+* Simple notation::
+* Working on text files::
+* How to read the tutorial::
+@end menu
+
+
+@node Compiling a file
+@subsection Compiling a file
+
+The first example demonstrates how to start working with LilyPond. To
+create sheet music, we write a text file that specifies the
+notation. For example, if we write
@example
@{
-c' d' e' f' g' a' b' c''
+ c' e' g' e'
@}
@end example
@noindent
the result looks like this
-@lilypond[quote]
+@c in this case we don't want verbatim
+@lilypond[quote,ragged-right]
{
-c' d' e' f' g' a' b' c''
+ c' e' g' e'
}
@end lilypond
-@emph{Warning:} Every piece of LilyPond input needs to have @{curly
-braces@} placed around the input. The braces should be also be
+@strong{Warning:} Every piece of LilyPond input needs to have @strong{@{ curly
+braces @}} placed around the input. The braces should also be
surrounded by a space unless they are at the beginning or end of a
-line to avoid ambiguities. These may be omitted in examples in this
+line to avoid ambiguities. These may be omitted in some examples in this
manual, but don't forget them in your own music!
@cindex Case sensitive
-In addition, LilyPond input is case sensitive. @code{ @{ c d e @} } is
-valid input; @code{ @{ C D E @} } will produce an error message.
-
+In addition, LilyPond input is @strong{case sensitive}. @code{ @{ c d e @} }
+is valid input; @code{ @{ C D E @} } will produce an error message.
+@sp 1
-@unnumberedsubsec Entering music and viewing output
+@subheading Entering music and viewing output
In this section we will explain what commands to run
and how to view or print the output.
-@unnumberedsubsubsec MacOS X
+@subsubheading MacOS X
If you double click LilyPond.app, it will open with an example
file. Save it, for example, to @file{test.ly} on your Desktop, and
then process it with the menu command @samp{Compile > Typeset File}.
The resulting PDF file will be displayed on your screen.
-Be warned that the first time you ever run lilypond will take a minute
-or two, because all of the system fonts have to be analyzed first.
+Be warned that the first time you ever run LilyPond, it will take a minute
+or two because all of the system fonts have to be analyzed first.
For future use of LilyPond, you should begin by selecting "New"
-or "Open".
+or "Open". You must save your file before typesetting it. If any errors
+occur in processing, please see the log window.
-@unnumberedsubsubsec Windows
+@subsubheading Windows
On Windows, start up a text-editor@footnote{Any simple or
programmer-oriented editor with UTF-8 support will do, for example
codes that will confuse LilyPond.} and enter
@verbatim
-{ c' e' g' c'' }
+{
+ c' e' g' e'
+}
@end verbatim
Save it on the desktop as @file{test.ly} and make sure that it is not
called @file{test.ly.TXT}. Double clicking @file{test.ly} will process
-the file and show the resulting PDF file.
+the file and show the resulting PDF file. To edit an existing
+@file{.ly} file, right-click on it and select @qq{Edit source}.
+If you double-click in the LilyPond icon on the Desktop, it will open
+a simple text editor with an example file. Save it, for example, to
+@file{test.ly} on your Desktop, and then double-click on the file to
+process it. After some seconds, you will get a file @file{test.pdf}
+on your desktop. Double-click on this PDF file to view the typeset
+score. An alternative method to process the @file{test.ly} file
+is to drag and drop it onto the LilyPond icon using your mouse pointer.
-@unnumberedsubsubsec Unix
+Double-clicking the file does not only result in a PDF file, but also
+produces a @file{.log} file that contains some information on what LilyPond
+has done to the file. If any errors occur, please examine this file.
+
+
+@subsubheading Unix
Begin by opening a terminal window and starting a text editor. For
example, you could open an xterm and execute
@code{joe}@footnote{There are macro files for VIM addicts, and there
is a @code{LilyPond-mode} for Emacs addicts. If they have not been
-installed already, refer to the file @file{INSTALL.txt}.}. In your
+installed already, refer to the file @file{INSTALL.txt}. The
+easiest editing environment is @file{LilyPondTool}. See
+@ref{Editor support} for more information.}. In your
text editor, enter the following input and save the file as
@file{test.ly}
@verbatim
-{ c' e' g' c'' }
+{
+ c' e' g' e'
+}
@end verbatim
@noindent
@noindent
The result is the file @file{test.pdf} which you can print or view
with the standard facilities of your operating system.@footnote{If
-your system does not have any tools installed, you can try
+your system does not have any such tools installed, you can try
@uref{http://@/www@/.cs@/.wisc@/.edu/@/~ghost/,Ghostscript}, a freely
available package for viewing and printing PDF and PostScript files.}
-@node Second steps
-@section Second steps
+@node Simple notation
+@subsection Simple notation
-@emph{Remember:} Every piece of LilyPond input needs to have @{curly
-braces@} placed around the input. The braces should be surrounded by
-a space unless they are at the beginning or end of a line to avoid
-ambiguities. For the rest of this manual, most examples will omit
-these braces, but don't forget them in your own music!
+LilyPond will add some notation elements automatically. In the next
+example, we have only specified four pitches, but LilyPond has
+added a clef, time signature, and rhythms.
-@c will be removed once the tutorial either explains \relative or
-@c examples are fixed so they don't use it. -gp
-In addition, many examples use @code{relative} mode. This is explained
-in @ref{Octave entry}; for now simply be aware that some examples
-should be placed inside @code{\relative @{ @emph{...music...} @}}.
-Many example have also been compressed horizontally to save
-space, using @code{\paper @{ ragged-right = ##t @}}.
+@lilypond[quote,ragged-right,verbatim]
+{
+ c' e' g' e'
+}
+@end lilypond
-@cindex Case sensitive
-Finally, LilyPond input is case sensitive. @code{ @{ c d e @} } is
-valid input; @code{ @{ C D E @} } will produce an error message.
+@noindent
+This behavior may be altered, but in most cases these automatic values
+are useful.
-@c End of latest re-write. Since I have no life, I may do more
-@c work on this, but I'd really like to have a Doc Helper take
-@c over this task. -gp
+@subheading Pitches
-The @rglos{duration} of a note is specified by a number after the note
-name. @samp{1} for a @rglos{whole note}, @samp{2} for a @rglos{half note},
-@samp{4} for a @rglos{quarter note} and so on
+The easiest way to enter notes is by using @code{\relative} mode. In
+this mode, the @rglos{interval} between the previous note and the
+current note is assumed to be within a @rglos{fourth}. We begin by
+entering the most elementary piece of music, a @rglos{scale}.
-@example
-a1 a2 a4 a16 a32
-@end example
+@lilypond[quote,ragged-right,verbatim]
+\relative c' {
+ c d e f
+ g a b c
+}
+@end lilypond
+
+The initial note is @rglos{middle C}. Each successive note
+is within a fourth of the previous note -- in other words, the first
+@samp{c} is the closest C to middle C. This is followed by the closest
+D to the previous note. We can create melodies which have larger intervals:
-@lilypond[fragment,quote,notime,relative=2]
-\set Staff.autoBeaming = ##f
-{ a1 a2 a4 a16 a32 s16_" " }
+@lilypond[quote,ragged-right,verbatim]
+\relative c' {
+ d f a g
+ c b f d
+}
@end lilypond
-If you do not specify a duration, the duration last entered is used
-for the next notes. The duration of the first note in input defaults
-to a quarter
+@noindent
+As you may notice, this example does not start on middle C. The first
+note -- the @samp{d} -- is the closest D to middle C.
-@example
-a a8 a a2 a
-@end example
+To add intervals that are larger than a fourth, we can raise the octave
+by adding a single quote @code{'} (or apostrophe) to the note name. We can
+lower the octave by adding a comma @code{,} to the note name.
-@lilypond[fragment,quote,notime,relative=2]
-{ a a8 a a2 a s16_" " }
+@lilypond[quote,ragged-right,verbatim]
+\relative c'' {
+ a a, c' f,
+ g g'' a,, f'
+}
@end lilypond
+@noindent
+To change a note by two (or more!) octaves, we use multiple @code{''} or
+@code{,,} -- but be careful that you use two single quotes @code{''} and
+not one double quote @code{"}@tie{}! The initial value in
+@code{\relative c'} may also be modified like this.
-A @rglos{rest} is entered just like a note, but with the name @samp{r}
-@example
-r2 r4 r8 r16
-@end example
+@subheading Durations (rhythms)
+
+The @rglos{duration} of a note is specified by a number after the note
+name. @samp{1} for a @rglos{whole note}, @samp{2} for a @rglos{half note},
+@samp{4} for a @rglos{quarter note} and so on. Beams are added
+automatically.
-@lilypond[fragment,quote,notime]
-r2 r4 r8 r16 s16_" "
+@lilypond[quote,ragged-right,verbatim]
+\relative c'' {
+ a1
+ a2 a4 a8 a
+ a16 a a a a32 a a a a64 a a a a a a a a2
+}
@end lilypond
-Add a dot @samp{.} after the duration to get a @rglos{dotted note}
+@noindent
+If you do not specify a duration, the previous duration is used
+for the next note. The duration of the first note defaults to a quarter.
-@example
-a2. a4 a8. a16
-@end example
+To create @rglos{dotted notes}, add a dot @samp{.} to the duration number.
-@lilypond[fragment,quote,notime,relative=1]
-{ a2. a4 a8. a16 s16_" " }
+@lilypond[quote,ragged-right,verbatim]
+\relative c'' {
+ a a a4. a8
+ a8. a16 a a8. a8 a4.
+}
@end lilypond
-The (or @rglos{time signature}) can be set with the @code{\time}
-command
-@example
-\time 3/4
-\time 6/8
-\time 4/4
-@end example
+@subheading Rests
+
+A @rglos{rest} is entered just like a note with the name @samp{r}:
-@c A clef here may lead to confusion, remove it.
-@lilypond[fragment,quote]
-\override Staff.Clef #'transparent = ##t
-\time 3/4
-s4_" "
-\time 6/8
-s4_" "
-\time 4/4
-s16_" "
+@lilypond[quote,ragged-right,verbatim]
+\relative c'' {
+ a r r2
+ r8 a r4 r4. r8
+}
@end lilypond
-The @rglos{clef} can be set using the @code{\clef} command
-@example
-\clef treble
-\clef bass
-\clef alto
-\clef tenor
-@end example
+@subheading Time signature
+
+The @rglos{time signature}) can be set with the @code{\time} command:
-@lilypond[fragment,quote,notime]
-\clef treble
-s4_" "
-\clef bass
-s4_" "
-\clef alto
-s4_" "
-\clef tenor
-s16_" "
+@lilypond[quote,ragged-right,verbatim]
+\relative c'' {
+ \time 3/4
+ a4 a a
+ \time 6/8
+ a4. a
+ \time 4/4
+ a4 a a a
+}
@end lilypond
-Remember to enclose the notes and commands in curly braces
-@code{@{@tie{}@dots{}@tie{}@}} to convert it to printable output.
-@lilypond[fragment,quote,noindent,verbatim]
-\time 3/4
-\clef bass
-c2 e4 g2.
-f4 e d c2 r4
+@subheading Clef
+
+The @rglos{clef} can be set using the @code{\clef} command:
+
+@lilypond[quote,ragged-right,verbatim]
+\relative c' {
+ \clef treble
+ c1
+ \clef alto
+ c1
+ \clef tenor
+ c1
+ \clef bass
+ c1
+}
@end lilypond
-For more information on
+@subheading All together
+
+Here is a small example showing all these elements together:
+
+@lilypond[quote,ragged-right,verbatim]
+\relative c, {
+ \time 3/4
+ \clef bass
+ c2 e8 c' g'2.
+ f4 e d c4 c, r4
+}
+@end lilypond
+
+@moreinfo
@quotation
@table @asis
@item Entering pitches and durations
-see
-@ref{Pitches}, and @ref{Durations}.
-@item Clefs
-see @ref{Clef}.
+see @ref{Pitches} and @ref{Durations}.
@item Rests
see @ref{Rests}.
@item Time signatures and other timing commands
see @ref{Time signature}.
+@item Clefs
+see @ref{Clef}.
+@end table
+@end quotation
+
+
+@node Working on text files
+@subsection Working on text files
+
+LilyPond input files are treated like files in most programming languages:
+they are case sensitive, white-space insensitive, expressions are
+formed with curly braces @{ @}, and comments are denoted with @code{%} or
+@code{%@{ .. %@}}.
+
+If the previous sentence sounds like nonsense, don't worry! We'll explain
+what all these terms mean:
+
+@itemize
+
+@cindex Case sensitive
+@item @strong{Case sensitive}:
+it matters whether you enter a letter
+in lower case (i.e. @code{a, b, s, t}) or upper case (i.e.
+@code{A, B, S, T}). Notes are lower case: @code{ @{ c d e @} }
+is valid input; @code{ @{ C D E @} } will produce an error message.
+
+@item @strong{Whitespace insensitive}:
+it does not matter how many
+spaces (or new lines) you add. @code{ @{ c d e @}} means the same thing
+as @code{ @{ c @ @ @ @ @ d e @} } and
+@example
+ @{
+c d
+ e @}
+@end example
+
+@noindent
+Of course, the previous example is hard to read. A good rule of thumb
+is to indent code blocks with either a tab or two spaces:
+@example
+@{
+ c d e
+@}
+@end example
+
+@item @strong{Expressions:}
+Every piece of LilyPond input needs to have
+@strong{@{ curly braces @}} placed around the input. These braces tell
+LilyPond that the input is a single music expression, just like
+parenthesis @samp{()} in mathematics. The braces should
+be surrounded by a space unless they are at the beginning or end of a
+line to avoid ambiguities.
+
+A function (such as @code{\relative @{ @}} ) also counts as a single
+music expression.
+
+@cindex comments
+@cindex line comment
+@cindex block comment
+@item @strong{Comments}:
+A comment is a remark for the human reader of the music input; it is
+ignored while parsing, so it has no effect on the printed output.
+There are two types of comments. The percent symbol @samp{%}
+introduces a line comment; anything after @samp{%} on that line is
+ignored. A block comment marks a whole section of music
+input as a comment. Anything that is enclosed in @code{%@{} and @code{%@}} is
+ignored. The following fragment shows possible uses for comments
+
+@example
+% notes for twinkle twinkle follow
+ c4 c g' g a a g2
+
+%@{
+ This line, and the notes below
+ are ignored, since they are in a
+ block comment.
+
+ g g f f e e d d c2
+%@}
+@end example
+
+@end itemize
+
+There are more tips for constructing input files in
+@ref{Suggestions for writing LilyPond files}.
+
+
+@node How to read the tutorial
+@subsection How to read the tutorial
+
+As we saw in @ref{Working on text files}, LilyPond input must be
+surrounded by @{ @} marks or a @code{\relative c'' @{ ... @}}. For the
+rest of this manual, most examples will omit this.
+
+If you are reading the HTML documentation and wish to see the exact
+exact LilyPond code that was used to create the example, simply click
+on the picture. If you are not reading the HTML version, you could
+copy and paste the displayed input, but you @strong{must} add the
+@code{\relative c'' @{ @}} like this:
+
+@example
+\relative c'' @{
+ ... example goes here...
+@}
+@end example
+
+Why omit the braces? Most examples
+in this manual can be inserted into the middle of a longer piece of
+music. For these examples, it does not make sense to add
+@code{\relative c'' @{ @}} -- you should not place a @code{\relative}
+inside another @code{\relative}, so you would not be able to copy
+a small documentation example and paste it inside a longer piece
+of your own.
+
+
+@node Single staff notation
+@section Single staff notation
+
+This section introduces common notation that is used for one voice
+on one staff.
+
+@menu
+* Relative note names::
+* Accidentals and key signatures::
+* Ties and slurs::
+* Articulation and dynamics::
+* Automatic and manual beams::
+* Advanced rhythmic commands::
+@end menu
+
+
+@node Relative note names
+@subsection Relative note names
+
+As we saw in @ref{Simple notation}, LilyPond calculates the pitch of
+each note relative to the previous one@footnote{There is another mode of
+entering pitches, @ref{Absolute note names}, but in practice relative
+mode is much easier and safer to use.}. If no extra octave marks
+(@code{'} and @code{,}) are added, it assumes that each pitch is within
+a fourth of the previous note.
+
+LilyPond examines pitches based on the note names -- in other words,
+an augmented fourth is @emph{not} the same as a diminished fifth. If we
+begin at a C, then an F-sharp will be placed a higher than the C, while
+a G-flat will be placed lower than the C.
+
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+c2 fis
+c2 ges
+@end lilypond
+
+@moreinfo
+@quotation
+@table @asis
+@item Relative octaves
+see @ref{Relative octaves}.
+@item Octave check
+see @ref{Octave check}.
@end table
@end quotation
-@node More about pitches
-@section More about pitches
+
+@node Accidentals and key signatures
+@subsection Accidentals and key signatures
+
+@subheading Accidentals
A @rglos{sharp} pitch is made by adding @samp{is} to
-the name, a @rglos{flat} pitch by adding @samp{es}. As
+the name, and a @rglos{flat} pitch by adding @samp{es}. As
you might expect, a @rglos{double sharp} or @rglos{double flat} is
made by adding @samp{isis} or @samp{eses}@footnote{This syntax
derived from note naming conventions in Nordic and Germanic languages,
-like German and Dutch.}
-
-@example
-cis1 ees fisis aeses
-@end example
+like German and Dutch. To use other names for accidentals, see
+@ref{Note names in other languages}.}
-@lilypond[fragment,quote,notime]
-\set Score.timing = ##f
-\transpose c c' { cis1 ees fisis aeses s16_" " }
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+cis1 ees fisis, aeses
@end lilypond
@cindex key signature, setting
-The key signature is set with the command @code{\key}, followed by
-a pitch and @code{\major} or @code{\minor}
+@subheading Key signatures
-@example
-\key d \major
-g1
-\key c \minor
-g
-@end example
+The key signature is set with the command @code{\key} followed by
+a pitch and @code{\major} or @code{\minor}.
-@lilypond[fragment,quote,notime,fragment]
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
\key d \major
-g'1
+a1
\key c \minor
-g'
+a
@end lilypond
-@noindent
-Key signatures together with the pitches (including alterations) are
-used to determine when to print accidentals. This is a
+@sp 1
+
+@subheading Warning: key signatures and pitches
+
+To determine whether to print an accidental, LilyPond examines the
+pitches and the key signature. The key signature only effects
+the @emph{printed} accidentals, not the actual pitches! This is a
feature that often causes confusion to newcomers, so let us explain it
in more detail.
-
LilyPond makes a sharp distinction between musical content and
layout. The alteration (flat, natural or sharp) of a note is part of
the pitch, and is therefore musical content. Whether an accidental (a
-flat, natural or sharp @emph{sign}) is printed in front of the
+@emph{printed} flat, natural or sharp sign) is printed in front of the
corresponding note is a question of layout. Layout is something that
follows rules, so accidentals are printed automatically according to
those rules. The pitches in your music are works of art, so they will
In this example
-@lilypond[quote,notime,fragment]
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
\key d \major
-d' cis' fis'
+d cis fis
@end lilypond
@noindent
-no note has an explicit accidental, but you still must enter
-
-@example
-\key d \major
-d cis fis
-@end example
+No note has a printed accidental, but you must still add the @samp{is} to
+@code{cis} and @code{fis}.
-@noindent
-The code @samp{d} does not mean @qq{print a black dot just below the
-staff.} Rather, it means: @qq{a note with pitch D-natural.} In the key
-of A-flat major, it does get an accidental
+The code @samp{e} does not mean @qq{print a black dot just below the
+first line of the staff.} Rather, it means: @qq{there is a note with
+pitch E-natural.} In the key of A-flat major, it @emph{does} get an
+accidental:
-@lilypond[quote,notime,fragment,relative=1,verbatim]
-\key as \major
-d
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+\key aes \major
+e
@end lilypond
Adding all alterations explicitly might require a little more effort
when typing, but the advantage is that transposing is easier, and
accidentals can be printed according to different conventions. See
-@ref{Automatic accidentals}, for some examples how accidentals can be printed
+@ref{Automatic accidentals} for some examples how accidentals can be printed
according to different rules.
-
-For more information on
-
+@moreinfo
@quotation
@table @asis
@item Accidentals
-see @ref{Automatic accidentals}.
-
+see @ref{Accidentals} and @ref{Automatic accidentals}.
@item Key signature
see @ref{Key signature}.
@end table
@end quotation
-@node Entering ties
-@section Entering ties
-@cindex tie
+@node Ties and slurs
+@subsection Ties and slurs
+
+@cindex ties
+@subheading Ties
A @rglos{tie} is created by appending a tilde @samp{~} to the first
note being tied
-@lilypond[quote,notime,fragment,verbatim,relative=3]
-g4~ g a2~ a4
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+g4~ g c2~
+c4 ~ c8 a8 ~ a2
@end lilypond
-For more information on Ties see @ref{Ties}.
-
+@cindex slurs
+@subheading Slurs
+A @rglos{slur} is a curve drawn across many notes. The starting note
+and ending note are marked with @samp{(} and @samp{)} respectively.
-@node Automatic and manual beams
-@section Automatic and manual beams
-
-@cindex beams, by hand
-All @rglos{beam}s are drawn automatically
-
-@lilypond[quote,fragment,relative=2,verbatim]
-a8 ais d es r d
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+d4( c16) cis( d e c cis d) e( d4)
@end lilypond
-@noindent
-If you do not like where beams are put, they can be entered by
-hand. Mark the first note to be beamed with @samp{[} and the last one
-with @samp{]}.
+@cindex slurs, phrasing
+@cindex phrasing slurs
+@subheading Phrasing slurs
-@lilypond[quote,fragment,relative=2,verbatim]
-a8[ ais] d[ es r d]
+@cindex phrasing slurs
+Slurs to indicate longer phrasing can be entered with @code{\(} and
+@code{\)}. You can have both legato slurs and phrasing slurs at the
+same time, but you cannot have simultaneous slurs or simultaneous
+phrasing slurs.
+
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+a8(\( ais b c) cis2 b'2 a4 cis,\)
@end lilypond
-For more information on beams, see @ref{Manual beams}.
+@sp 1
+@cindex slurs versus ties
+@subheading Warnings: slurs vs. ties
-Here are key signatures, accidentals and ties in action
+A slur looks like a @rglos{tie}, but it has a different meaning. A
+tie simply makes the first note longer, and can only be used on
+pairs of notes with the same pitch. Slurs indicate the articulations
+of notes, and can be used on larger groups of notes. Slurs and ties
+can be nested.
-@lilypond[fragment,quote,noindent,line-width=50\staff-space,verbatim]
-\relative c'' {
- \time 4/4
- \key g \minor
- \clef treble
- r4 r8 a8 gis4 b
- a8 d4.~ d e,8
- fis4 fis8 fis8 eis4 a8 gis~
- gis2 r2
-}
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+c2~( c8 fis fis4 ~ fis2 g2)
@end lilypond
-@cindex accidentals
-
-
-@noindent
-There are some interesting points to note in this example. Bar lines
-and beams are drawn automatically. Line breaks are calculated
-automatically; it does not matter where the line breaks are in the
-source file. Finally, the order in which time, key, and clef changes
-are entered is not relevant: in the printout, these are ordered
-according to standard notation conventions.
+@moreinfo
+@quotation
+@table @asis
+@item Ties
+see @ref{Ties}.
+@item Slurs
+see @ref{Slurs}.
+@item Phrasing slurs
+see @ref{Phrasing slurs}.
+@end table
+@end quotation
+@node Articulation and dynamics
+@subsection Articulation and dynamics
-@node Octave entry
-@section Octave entry
+@cindex articulation
+@cindex accents
+@cindex staccato
+@subheading Articulations
+Common @rglos{articulations} can be added to a note using a dash @samp{-}
+and a single character:
-@c Tim wants to move this quotes example just before the: quotes-do not-work
-@c score, but we'd need to remove quotes from the other two (key and
-@c tie) examples...
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+c-. c-- c-> c-^ c-+ c-_
+@end lilypond
-@c better to have this just before the `octaves are bad' snipped
-@c but we'd need to remove the ', from \key and tie
-To raise a note by an octave, add a high quote @samp{'} (apostrophe) to
-the note name, to lower a note one octave, add a @q{low quote} @samp{,}
-(comma). Middle C is @code{c'}
+@cindex fingering
+@subheading Fingerings
+Similarly, fingering indications can be added to a note using a dash
+(@samp{-}) and the digit to be printed:
-@lilypond[quote,notime,fragment,verbatim]
-c'4 c'' c''' \clef bass c c,
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+c-3 e-5 b-2 a-1
@end lilypond
-An example of the use of quotes is in the following Mozart fragment
+Articulations and fingerings are usually placed automatically, but you
+can specify a direction using @samp{^} (up) or @samp{_} (down). You can
+also use multiple articulations on the same note. However, in most cases
+it is best to let LilyPond determine the articulation directions.
-@lilypond[quote,ragged-right,fragment,verbatim]
-\key a \major
-\time 6/8
-cis''8. d''16 cis''8 e''4 e''8
-b'8. cis''16 b'8 d''4 d''8
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+c_-^1 d^. f^4_2-> e^-_+
@end lilypond
-@noindent
-This example shows that music in a high register needs lots of quotes.
-This makes the input less readable, and it is a source of errors. The
-solution is to use @q{relative octave} mode. This is the
-most convenient way to copy existing music.
-
-In relative mode, a note without octavation quotes (i.e., the @samp{'}
-or @samp{,} after a note) is chosen so that it is closest to the
-previous one. For example, @samp{c f} goes up while @samp{c g} goes
-down.
+@subheading Dynamics
+Dynamic signs are made by adding the markings (with a backslash) to
+the note
-To use relative mode, add @code{\relative} before the piece of
-music. The first note is taken relative to the middle C
-@c no , for this sentence
-(i.e., @code{c'})
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+c\ff c\mf c\p c\pp
+@end lilypond
+@cindex dynamics
+@cindex decrescendo
+@cindex crescendo
+Crescendi and decrescendi are started with the commands @code{\<} and
+@code{\>}. An ending dynamic, for example @code{\f}, will finish the
+(de)crescendo, or the command @code{\!} can be used
-@lilypond[quote,notime,fragment,verbatim]
-\relative {
- c' f c g c
-}
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+c2\< c2\ff\> c2 c2\!
@end lilypond
-
-Since most music has small intervals, pieces can be written almost
-without octavation quotes in relative mode. The previous example is
-entered as
-
-@lilypond[quote,ragged-right,verbatim]
-\relative {
- \key a \major
- \time 6/8
- cis'8. d16 cis8 e4 e8
- b8. cis16 b8 d4 d8
-}
+@moreinfo
+@quotation
+@table @asis
+@item Articulations
+see @ref{Articulations}.
+@item Fingering
+see @ref{Fingering instructions}.
+@item Dynamics
+see @ref{Dynamics}.
+@end table
+@end quotation
+
+
+@node Automatic and manual beams
+@subsection Automatic and manual beams
+
+@cindex beams, by hand
+All @rglos{beam}s are drawn automatically:
+
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+a8 ais d ees r d c16 b a8
@end lilypond
-@c needed better, maybe even redundant explanation
-@c added another example below.
-@c grappig: Pa vond het heel logies, en slim toen-i eenmaal begreep.
-@c in eerste instantie drong het `relative' niet door zonder extra uitleg.
-Larger intervals are made by adding octavation quotes.
+@noindent
+If you do not like the automatic beams, they may be overridden
+manually. Mark the first note to be beamed with @samp{[} and the last one
+with @samp{]}.
-@lilypond[quote,notime,verbatim,fragment]
-\relative c {
- c'' f, f c' c g' c,
-}
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+a8[ ais] d[ ees r d] a b
@end lilypond
-In summary, quotes or commas no longer determine the absolute height
-of a note in @code{\relative} mode. Rather, the height of a note is
-relative to the previous one, and changing the octave of a single note
-shifts all following notes an octave up or down.
+@moreinfo
+@quotation
+@table @asis
+@item Automatic beams
+see @ref{Automatic beams}.
+@item Manual beams
+see @ref{Manual beams}.
+@end table
+@end quotation
+
+
+@node Advanced rhythmic commands
+@subsection Advanced rhythmic commands
-For more information on relative octaves see @ref{Relative octaves},
-and @ref{Octave check}.
+@cindex pickup
+@cindex anacruse
+@cindex partial measure
+@subheading Partial measure
+A pickup (or @rglos{anacrusis}) is entered with the keyword
+@code{\partial}. It is followed by a duration: @code{\partial 4} is
+a quarter note pickup and @code{\partial 8} an eighth note.
-@node Music expressions explained
-@section Music expressions explained
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+\partial 8
+f8 c2 d
+@end lilypond
+
+@cindex tuplets
+@cindex triplets
+@subheading Tuplets
+
+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 a triplet has 2/3 as its fraction
+
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+\times 2/3 { f8 g a }
+\times 2/3 { c r c }
+\times 2/3 { f,8 g16 a g a }
+\times 2/3 { d4 a8 }
+@end lilypond
+
+@cindex grace notes
+@cindex acciaccatura
+@cindex appoggiatura
+@subheading Grace notes
+
+Grace notes are created with the @code{\grace} command, although they
+can also be created by prefixing a music expression with the
+keyword @code{\appoggiatura} or @code{\acciaccatura}
+
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+c2 \grace { a32 b} c2
+c2 \appoggiatura b16 c2
+c2 \acciaccatura b16 c2
+@end lilypond
+
+@moreinfo
+@quotation
+@table @asis
+@item Grace notes
+see @ref{Grace notes},
+@item Tuplets
+see @ref{Tuplets},
+@item Pickups
+see @ref{Partial measures}.
+@end table
+@end quotation
+
+
+@node Multiple notes at once
+@section Multiple notes at once
+
+This section introduces having more than one note at the same time:
+multiple instruments, multiple staves for a single instrument (i.e. piano),
+and chords.
+
+Polyphony in music refers to having more than one voice occurring in
+a piece of music. Polyphony in LilyPond refers to having more than
+one voice on the same staff.
+
+@menu
+* Music expressions explained::
+* Multiple staves::
+* Piano staves::
+* Single staff polyphony::
+* Combining notes into chords::
+@end menu
-In input files, music is represent by so-called @emph{music
-expression}s. We have already seen some in the previous examples;
-a single note is a music expression
+@node Music expressions explained
+@subsection Music expressions explained
+
+In LilyPond input files, music is represented by @emph{music
+expressions}. A single note is a music expression, although it is not
+valid input all on its own.
-@lilypond[fragment,quote,verbatim,relative=3]
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
a4
@end lilypond
-Enclosing a group of notes in braces creates a new music
-expression
+Enclosing a group of notes in braces creates a new music expression:
-@lilypond[fragment,quote,verbatim,relative=3]
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
{ a4 g4 }
@end lilypond
-Putting a bunch of music expressions (e.g., notes) in braces, means that
-they should be played in sequence. The result again is a music
-expression, which can be grouped with other expressions sequentially.
-Here, the expression from the previous example is combined with two
-notes
+Putting a group of music expressions (e.g. notes) in braces means that
+they are in sequence (i.e. each one follows the previous one). The result
+is another music expression:
-@lilypond[fragment,quote,verbatim,relative=3]
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
{ { a4 g } f g }
@end lilypond
-This technique is useful for non-monophonic music. To enter music
-with more voices or more staves, we also combine expressions in
-parallel. Two voices that should play at the same time, are entered
-as a simultaneous combination of two sequences. A @q{simultaneous}
-music expression is formed by enclosing expressions in @code{<<} and
-@code{>>}. In the following example, three sequences (all containing
-two separate notes) are combined simultaneously
+@subheading Simultaneous music expressions: multiple staves
-@lilypond[fragment,quote,verbatim,relative=3]
-<<
- { a4 g }
- { f e }
- { d b }
->>
+This technique is useful for polyphonic music. To enter music
+with more voices or more staves, we combine expressions in
+parallel. To indicate that two voices should play at the same time,
+simply enter a simultaneous combination of music expressions. A
+@q{simultaneous} music expression is formed by enclosing expressions inside
+@code{<<} and @code{>>}. In the following example, three sequences (all
+containing two separate notes) are combined simultaneously:
+
+@lilypond[quote,ragged-right,verbatim]
+\relative c'' {
+ <<
+ { a4 g }
+ { f e }
+ { d b }
+ >>
+}
+@end lilypond
+
+Note that we have indented each level of the input with a different
+amount of space. LilyPond does not care how much (or little) space there
+is at the beginning of a line, but indenting LilyPond code like this makes
+it much easier for humans to read.
+
+@strong{Warning}: each note is relative to the
+previous note in the input, not relative to the @code{c''} in the
+initial @code{\relative} command.
+
+
+@subheading Simultaneous music expressions: single staff
+
+To determine the number of staves in a piece, LilyPond looks at the first
+expression. If it is a single note, there is one staff; if there is a
+simultaneous expression, there is more than one staff.
+
+@lilypond[quote,ragged-right,verbatim]
+\relative c'' {
+ c2 <<c e>>
+ << { e f } { c <<b d>> } >>
+}
@end lilypond
+@cindex expression
+@cindex music expression
+@subheading Analogy: mathematical expressions
+
This mechanism is similar to mathematical
formulas: a big formula is created by composing small formulas. Such
-formulas are called expressions, and their definition is recursive, so
+formulas are called expressions, and their definition is recursive so
you can make arbitrarily complex and large expressions. For example,
@example
((1 + 2) * 3) / (4 * 5)
@end example
-@cindex expression
-@cindex music expression
This is a sequence of expressions, where each expression is contained
in the next (larger) one. The simplest expressions are numbers, and larger
ones are made by combining expressions with operators (like @samp{+},
music expressions can be nested arbitrarily deep, which is necessary
for complex music like polyphonic scores.
-Note that this example only has one staff, whereas
-the previous example had three separate staves. That is because this
-example begins with a single note. To determine the number of staves,
-LilyPond looks at the first element. If it is a single note, there is one
-staff; if there is a simultaneous expression, there is more than one staff.
-
-@lilypond[fragment,quote,verbatim,relative=2]
-{
- c <<c e>>
- << { e f } { c <<b d>> } >>
-}
-@end lilypond
-
-Music files with deep nesting can be confusing to enter and
-maintain. One convention that helps against this confusion is
-indenting. When entering a file with deep nesting of braces and
-angles, it is customary to use an indent that indicates the nesting
-level. Formatting music like this eases reading and helps you insert
-the right number of closing braces at the end of an expression. For
-example,
-
-@example
-<<
- @{
- @dots{}
- @}
- @{
- @dots{}
- @}
->>
-@end example
-Some editors have special support for entering LilyPond, and can help
-indenting source files. See @ref{Editor support} for more information.
+@node Multiple staves
+@subsection Multiple staves
-@node More staves
-@section More staves
+As we saw in @ref{Music expressions explained}, LilyPond input files
+are constructed out of music expressions. If the score begins with
+simultaneous music expressions, LilyPond creates multiples staves. However,
+it is easier to see what happens if we create each staff explicitly.
To print more than one staff, each piece of music that makes up a
staff is marked by adding @code{\new Staff} before it. These
@code{Staff} elements are then combined in parallel with @code{<<} and
-@code{>>}, as demonstrated here
+@code{>>}:
-@lilypond[quote,fragment,verbatim]
-<<
- \new Staff { \clef treble c'' }
- \new Staff { \clef bass c }
->>
+@lilypond[quote,ragged-right,verbatim]
+\relative c'' {
+ <<
+ \new Staff { \clef treble c }
+ \new Staff { \clef bass c,, }
+ >>
+}
@end lilypond
-
The command @code{\new} introduces a @q{notation context.} A notation
context is an environment in which musical events (like notes or
@code{\clef} commands) are interpreted. For simple pieces, such
notation contexts are created automatically. For more complex pieces, it
-is best to mark contexts explicitly. This ensures that each fragment
-gets its own stave.
+is best to mark contexts explicitly.
-There are several types of contexts. @code{Staff}, @code{Voice} and
-@code{Score} handle melodic notation, while @code{Lyrics} sets lyric
+There are several types of contexts. @code{Score}, @code{Staff},
+and @code{Voice} handle melodic notation, while @code{Lyrics} sets lyric
texts and @code{ChordNames} prints chord names.
In terms of syntax, prepending @code{\new} to a music expression
sign in mathematics. The formula @math{(4+5)} is an expression, so
@math{-(4+5)} is a bigger expression.
-We can now typeset a melody with two staves
-
-@c TODO: (c) status of this Paul McCartney (?) song (let's all stand together)
+Time signatures entered in one staff affects all other staves, but
+the key signature of one staff does @emph{not} affect other
+staves@footnote{This behavior may be changed if desired; see
+@ref{Changing defaults} for details.}.
-@lilypond[fragment,quote,verbatim,ragged-right]
-\relative <<
- \new Staff {
- \time 3/4
- \clef treble
-
- e'2 d4 c2 b4 a8[ a]
- b[ b] g[ g] a2.
- }
- \new Staff {
- \clef bass
- c,,2 e4 g2.
- f4 e d c2.
- }
->>
+@lilypond[quote,ragged-right,verbatim]
+\relative c'' {
+ <<
+ \new Staff { \clef treble \time 3/4 c }
+ \new Staff { \clef bass \key d \major c,, }
+ >>
+}
@end lilypond
-For more information on contexts see the description in
-@ref{Interpretation contexts}.
-@node Adding articulation marks to notes
-@section Adding articulation marks to notes
-
-@cindex articulation
-@cindex accents
-@cindex staccato
-
-Common accents can be added to a note using a dash (@samp{-}) and a
-single character
-
-@lilypond[fragment,quote,verbatim,relative=2]
-c-. c-- c-> c-^ c-+ c-_
-@end lilypond
-
-@cindex fingering
-Similarly, fingering indications can be added to a note using a dash
-(@samp{-}) and the digit to be printed
-
-@lilypond[fragment,quote,verbatim,relative=2]
-c-3 e-5 b-2 a-1
-@end lilypond
+@node Piano staves
+@subsection Piano staves
-Articulations and fingerings are usually placed automatically, but you
-can specify a direction using @samp{^} (up) or @samp{_} (down). You can
-also use multiple articulations on the same note. In most cases, however,
-it is best to let LilyPond determine the articulation directions.
+@cindex staff switch, manual
+@cindex cross staff voice, manual
+Piano music is typeset in two staves connected by a brace. Printing
+such a staff is similar to the polyphonic example in @ref{Multiple staves},
+but now this entire expression is inserted inside a @code{PianoStaff}:
-@lilypond[fragment,quote,verbatim,relative=2]
-c_-^1 d^. f^4_2-> e^-_+
-@end lilypond
+@example
+\new PianoStaff <<
+ \new Staff @dots{}
+ \new Staff @dots{}
+>>
+@end example
-Dynamic signs are made by adding the markings (with a backslash) to
-the note
+Here is a small example
-@lilypond[fragment,quote,verbatim,relative=2]
-c\ff c\mf
+@lilypond[quote,ragged-right,verbatim]
+\relative c'' {
+ \new PianoStaff <<
+ \new Staff { \time 2/4 c4 e g g, }
+ \new Staff { \clef bass c,, c' e c }
+ >>
+}
@end lilypond
-@cindex dynamics
-@cindex decrescendo
-@cindex crescendo
-
-Crescendi and decrescendi are started with the commands @code{\<} and
-@code{\>}. An ending dynamic, for example @code{\f}, will finish the
-(de)crescendo, or the command @code{\!} can be used
-
-@lilypond[fragment,quote,verbatim,relative=2]
-c2\< c2\ff\> c2 c2\!
-@end lilypond
+@moreinfo
+@quotation
+See @ref{Piano music}.
+@end quotation
+@node Single staff polyphony
+@subsection Single staff polyphony
-@cindex slur
+@cindex polyphony
+@cindex multiple voices
+@cindex voices, more -- on a staff
+When different melodic lines are combined on a single staff they are
+printed as polyphonic voices; each voice has its own stems, slurs and
+beams, and the top voice has the stems up, while the bottom voice has
+them down.
-A @rglos{slur} is a curve drawn across many notes, and indicates
-legato articulation. The starting note and ending note are marked
-with @samp{(} and @samp{)}, respectively
+Entering such parts is done by entering each voice as a sequence (with
+@code{@{...@}}) and combining these simultaneously, separating the
+voices with @code{\\}
-@lilypond[fragment,quote,fragment,relative=2,verbatim]
-d4( c16) cis( d e c cis d) e( d4)
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+<<
+ { a4 g2 f4~ f4 } \\
+ { r4 g4 f2 f4 }
+>>
@end lilypond
-@cindex slurs versus ties
-A slur looks like a @rglos{tie}, but it has a different meaning. A
-tie simply makes the first note sound longer, and can only be used on
-pairs of notes with the same pitch. Slurs indicate the articulations
-of notes, and can be used on larger groups of notes. Slurs and ties
-can be nested
+For polyphonic music typesetting, spacer rests can also be convenient;
+these are rests that do not print. They are useful for filling up
+voices that temporarily do not play. Here is the same example with a
+spacer rest (@samp{s}) instead of a normal rest (@samp{r}),
-@lilypond[quote,fragment,relative=2]
-c2~( c8 fis fis4 ~ fis2 g2)
+@lilypond[quote,ragged-right,verbatim,fragment,relative=2]
+<<
+ { a4 g2 f4~ f4 } \\
+ { s4 g4 f2 f4 }
+>>
@end lilypond
-@cindex phrasing slurs
-Slurs to indicate phrasing can be entered with @code{\(} and
-@code{\)}, so you can have both legato slurs and phrasing slurs at the
-same time. You cannot have simultaneous slurs or simultaneous
-phrasing slurs.
+@noindent
+Again, these expressions can be nested arbitrarily.
-@lilypond[quote,fragment,relative=2,verbatim]
-a8(\( ais b c) cis2 b'2 a4 cis, c\)
+@lilypond[quote,fragment,verbatim,relative=2,fragment]
+<<
+ \new Staff <<
+ { a4 g2 f4~ f4 } \\
+ { s4 g4 f2 f4 }
+ >>
+ \new Staff <<
+ \clef bass
+ { <c g>1 ~ <c g>4 } \\
+ { e,,4 d e2 ~ e4}
+ >>
+>>
@end lilypond
-
-For more information on
-
+@moreinfo
@quotation
-@table @asis
-@item Fingering
-see @ref{Fingering instructions}.
-@item Articulations
-see @ref{Articulations}.
-@item Slurs
-see @ref{Slurs}.
-@item Phrasing slurs
-see @ref{Phrasing slurs}.
-@item Dynamics
-see @ref{Dynamics}.
-@end table
+See @ref{Basic polyphony}.
@end quotation
@node Combining notes into chords
-@section Combining notes into chords
+@subsection Combining notes into chords
@cindex chords
-Chords can be made by surrounding pitches with angle brackets.
-Angle brackets are the symbols @samp{<} and @samp{>}.
+Chords can be made by surrounding pitches with single angle brackets. Angle
+brackets are the symbols @samp{<} and @samp{>}.
-@lilypond[quote,relative=1,fragment,verbatim]
-r4 <c e g>4 <c f a>8
+@lilypond[quote,fragment,verbatim,relative=2,fragment]
+r4 <c e g>4 <c f a>2
@end lilypond
-
You can combine markings like beams and ties with chords. They must
-be placed outside the angled brackets
-
-@lilypond[quote,relative=1,fragment,verbatim]
-r4 <c e g>8[ <c f a>]~ <c f a>
-@end lilypond
-
-@example
-r4 <c e g>8\>( <c e g> <c e g> <c f a>\!)
-@end example
-
-@lilypond[quote,relative=1,fragment]
-\slurUp
-r4 <c e g>8\>( <c e g> <c e g> <c f a>\!)
-@end lilypond
-
-
-@node Advanced rhythmic commands
-@section Advanced rhythmic commands
-
-@cindex pickup
-@cindex anacruse
-@cindex partial measure
-A pickup is entered with the keyword @code{\partial}. It
-is followed by a duration: @code{\partial 4} is a quarter note upstep
-and @code{\partial 8} an eighth note
-
-@lilypond[quote,relative=2,verbatim,fragment]
-\partial 8
-f8 c2 d e
-@end lilypond
-
-@cindex tuplets
-@cindex triplets
-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 a triplet has 2/3 as its fraction
+be placed outside the angle brackets
-@lilypond[quote,relative=1,verbatim,fragment]
-\times 2/3 { f8 g a }
-\times 2/3 { c r c }
+@lilypond[quote,fragment,verbatim,relative=2,fragment]
+r4 <c e g>8[ <c f a>]~ <c f a>2
@end lilypond
-@cindex grace notes
-@cindex acciaccatura
-Grace notes are also made by prefixing a music expression with the
-keyword @code{\appoggiatura} or @code{\acciaccatura}
-@cindex appoggiatura
-@cindex acciaccatura
-
-@lilypond[quote,relative=2,verbatim,fragment]
-c4 \appoggiatura b16 c4
-c4 \acciaccatura b16 c4
+@lilypond[quote,fragment,verbatim,relative=2,fragment]
+r4 <c e g>8\>( <c e g> <c e g>4 <c f a>\!)
@end lilypond
-@noindent
-
-For more information on
-
-@quotation
-@table @asis
-@item Grace notes
-see @ref{Grace notes},
-@item Tuplets
-see @ref{Tuplets},
-@item Pickups
-see @ref{Partial measures}.
-@end table
-@end quotation
-
-
-@node Commenting input files
-@section Commenting input files
-
-@cindex comments
-@cindex line comment
-@cindex block comment
-A comment is a remark for the human reader of the music input; it is
-ignored while parsing, so it has no effect on the printed output.
-There are two types of comments. The percent symbol @samp{%}
-introduces a line comment; after @samp{%} the rest of the line is
-ignored. A block comment marks a whole section of music
-input. Anything that is enclosed in @code{%@{} and @code{%@}} is
-ignored. The following fragment shows possible uses for comments
-
-@example
-% notes for twinkle twinkle follow
- c4 c g' g a a g2
-
-%@{
- This line, and the notes below
- are ignored, since they are in a
- block comment.
-
- g g f f e e d d c2
-%@}
-@end example
-
-@c TODO post-2.6 reorg
-@c This is good info, but I wouldn't call it a comment. IMO it should
-@c be moved somewhere else.
-@cindex versioning
-
-There is a special statement that is a kind of comment. The @code{\version}
-statement marks for which version of LilyPond the file was written.
-To mark a file for version 2.10.1, use
+@node Songs
+@section Songs
-@example
-\version "2.10.1"
-@end example
+This section introduces vocal music and simple song sheets.
-@noindent
-These annotations make future upgrades of LilyPond go more
-smoothly. Changes in the syntax are handled with a special program,
-@file{convert-ly} (see @ref{Updating files with convert-ly}), and it uses
-@code{\version} to determine what rules to apply.
+@menu
+* Printing lyrics::
+* A lead sheet::
+@end menu
@node Printing lyrics
-@section Printing lyrics
-@cindex lyrics
-
-@c TODO: (c) status of the Queen fragment.
+@subsection Printing lyrics
@cindex Lyrics
@cindex Songs
-Lyrics are entered by separating each syllable with a space
-
-@example
-I want to break free
-@end example
+Consider a simple melody:
-Consider the melody
-
-@lilypond[quote,verbatim,fragment,ragged-right]
-\relative {
- r4 c \times 2/3 { f g g }
- \times 2/3 { g4( a2) }
+@lilypond[quote,ragged-right,verbatim]
+\relative c'' {
+ a4 e c8 e r4
+ b2 c4( d)
}
@end lilypond
The lyrics can be set to these notes, combining both with the
-@code{\addlyrics} keyword
+@code{\addlyrics} keyword. Lyrics are entered by separating each
+syllable with a space.
-@lilypond[quote,verbatim,fragment,ragged-right]
+@lilypond[quote,ragged-right,verbatim]
<<
- \relative {
- r4 c \times 2/3 { f g g }
- \times 2/3 { g4( a2) }
+ \relative c'' {
+ a4 e c8 e r4
+ b2 c4( d)
}
- \addlyrics { I want to break free }
+ \addlyrics { One day this shall be free }
>>
@end lilypond
@cindex melisma
@cindex extender line
-@c synonyms?
This melody ends on a @rglos{melisma}, a single syllable (@q{free})
sung to more than one note. This is indicated with an @emph{extender
-line}. It is entered as two underscores, i.e.,
+line}. It is entered as two underscores @code{__}:
-@example
-@{ I want to break free __ @}
-@end example
-
-@lilypond[fragment,quote,ragged-right]
+@lilypond[quote,ragged-right,verbatim]
<<
- \relative {
- r4 c \times 2/3 { f g g }
- \times 2/3 { g4( a2) }
+ \relative c'' {
+ a4 e c8 e r4
+ b2 c4( d)
}
- \addlyrics { I want to break free __ }
+ \addlyrics { One day this shall be free __ }
>>
@end lilypond
Similarly, hyphens between words can be entered as two dashes,
resulting in a centered hyphen between two syllables
-@example
-A -- le gri -- a
-@end example
-
-@c no ragged-right here, because otherwise the hypens get lost.
-@lilypond[fragment,quote]
+@c no ragged-right here because otherwise the hypens get lost.
+@lilypond[quote,verbatim]
<<
- \relative {
+ \relative c' {
\time 2/4
- f4 f c' c
+ f4 f c c
}
- \addlyrics { A -- le gri -- a }
+ \addlyrics { A -- le -- gri -- a }
>>
@end lilypond
-More options, like putting multiple lines of lyrics below a melody are
+@moreinfo
+@quotation
+More options, such as putting multiple stanzas below a melody, are
discussed in @ref{Vocal music}.
+@end quotation
@node A lead sheet
-@section A lead sheet
+@subsection A lead sheet
@cindex Lead sheets
@cindex chords
@cindex chord names
@c TODO: revise this, \chords { } is shorter and more intuitive.
+@c I need help for this. -gp
-In popular music, it is common to denote accompaniment with chord names.
+In popular music it is common to denote accompaniment with chord names.
Such chords can be entered like notes,
-@lilypond[quote,verbatim,ragged-right]
+@lilypond[quote,ragged-right,verbatim]
\chordmode { c2 f4. g8 }
@end lilypond
When put together, chord names, lyrics and a melody form
a lead sheet, for example,
-@example
-<<
- \chords @{ @emph{chords} @}
- @emph{the melody}
- \addlyrics @{ @emph{the text} @}
->>
-@}
-@end example
-
-@lilypond[quote,ragged-right]
+@lilypond[quote,verbatim,ragged-right]
+% FIXME: this melody needs to be changed. See my new example in 2.4.1. -gp
<<
\chords { r2 c:sus4 f }
\relative {
in @ref{Chords}.
+@node Final touches
+@section Final touches
+
+This is the final section of the tutorial; it demonstrates how to add the
+final touches to simple pieces, and provides an introduction to the rest
+of the manual.
+
+@menu
+* Version number::
+* Adding titles::
+* Absolute note names::
+* Organizing pieces with identifiers::
+* After the tutorial::
+* How to read the manual::
+@end menu
+
+
+@node Version number
+@subsection Version number
+
+@cindex versioning
+The @code{\version} statement marks for which version of LilyPond the file
+was written. To mark a file for version 2.10.1, place
+
+@example
+\version "2.10.1"
+@end example
+
+@noindent
+at the top of your LilyPond file.
+
+These annotations make future upgrades of LilyPond go more
+smoothly. Changes in the syntax are handled with a special program,
+@file{convert-ly} (see @ref{Updating files with convert-ly}), and it uses
+@code{\version} to determine what rules to apply.
+
+
@node Adding titles
-@section Adding titles
+@subsection Adding titles
-Bibliographic information is entered in a separate block, the
-@code{\header} block. The name of the piece, its composer, etc., are
-entered as an assignment, within @code{\header
-@{@tie{}@dots{}@tie{}@}}. The @code{\header} block is usually put at
-the top of the file. For example,
+The title, composer, opus number, and similar information are entered
+in the @code{\header} block. This exists outside of the main
+music expression; the @code{\header} block is usually placed underneath
+the @ref{Version number}.
@example
+\version "2.10.1"
\header @{
- title = "Miniature"
- composer = "Igor Stravinsky"
+ title = "Symphony"
+ composer = "Me"
+ opus = "Op. 9"
@}
-@{ @dots{} @}
+@{
+ @dots{} music @dots{}
+@}
@end example
-
When the file is processed, the title and composer are printed above
the music. More information on titling can be found in @ref{Creating
titles}.
-@node Single staff polyphony
-@section Single staff polyphony
+@node Absolute note names
+@subsection Absolute note names
-@cindex polyphony
-@cindex multiple voices
-@cindex voices, more -- on a staff
-When different melodic lines are combined on a single staff they are
-printed as polyphonic voices; each voice has its own stems, slurs and
-beams, and the top voice has the stems up, while the bottom voice has
-them down.
+So far we have always used @code{\relative} to define pitches. This is
+the easiest way to enter most music, but another way of defining pitches
+exists: absolute mode.
-Entering such parts is done by entering each voice as a sequence (with
-@code{@{...@}}), and combining these simultaneously, separating the
-voices with @code{\\}
+If you omit the @code{\relative}, LilyPond treats all pitches as
+absolute values. A @code{c'} will always mean middle C, a @code{b} will
+always mean the note one step below middle C, and a @code{g,} will
+always mean the note on the bottom staff of the bass clef.
-@lilypond[quote,verbatim,relative=2,fragment]
-<< { a4 g2 f4~ f4 } \\
- { r4 g4 f2 f4 } >>
+@lilypond[quote,verbatim,ragged-right]
+{
+ \clef bass
+ c' b g, g,
+ g, f, f c'
+}
@end lilypond
-For polyphonic music typesetting, spacer rests can also be convenient;
-these are rests that do not print. They are useful for filling up
-voices that temporarily do not play. Here is the same example with a
-spacer rest (@samp{s}) instead of a normal rest (@samp{r}),
+Here is a four-octave scale:
-@lilypond[quote,verbatim,relative=2,fragment]
-<< { a4 g2 f4~ f4 } \\
- { s4 g4 f2 f4 } >>
+@lilypond[quote,verbatim,ragged-right]
+{
+ \clef bass
+ c, d, e, f,
+ g, a, b, c
+ d e f g
+ a b c' d'
+ \clef treble
+ e' f' g' a'
+ b' c'' d'' e''
+ f'' g'' a'' b''
+ c'''1
+}
@end lilypond
-@noindent
-Again, these expressions can be nested arbitrarily
+As you can see, writing a melody in the treble clef involves a lot of
+quote ' marks. Consider this fragment from Mozart:
-@lilypond[quote,fragment,verbatim,relative=2,fragment]
-<<
- \new Staff <<
- { a4 g2 f4~ f4 } \\
- { s4 g4 f2 f4 }
- >>
- \new Staff <<
- \clef bass
- { <c g>1 ~ <c g>4 } \\
- { e,,4 d e2 ~ e4}
- >>
->>
+@lilypond[quote,verbatim,ragged-right]
+{
+ \key a \major
+ \time 6/8
+ cis''8. d''16 cis''8 e''4 e''8
+ b'8. cis''16 b'8 d''4 d''8
+}
@end lilypond
-More features of polyphonic typesetting are described in this manual
-in section @ref{Basic polyphony}.
-
-
-@node Piano staves
-@section Piano staves
-
-@cindex staff switch, manual
-@cindex cross staff voice, manual
-Piano music is typeset in two staves connected by a brace. Printing
-such a staff is similar to the polyphonic example in @ref{More staves},
-
-@example
-<< \new Staff @{ @dots{} @}
- \new Staff @{ @dots{} @} >>
-@end example
-
-@noindent
-but now this entire expression must be interpreted as a
-@code{PianoStaff}
-
-@example
-\new PianoStaff << \new Staff @dots{} >>
-@end example
+All these quotes makes the input less readable and it is a source of
+errors. With @code{\relative}, the previous example is much easier
+to read:
-Here is a small example
-
-@lilypond[quote,verbatim,relative=1,fragment]
-\new PianoStaff <<
- \new Staff { \time 2/4 c4 c g' g }
- \new Staff { \clef bass c,, c' e c }
->>
+@lilypond[quote,verbatim,ragged-right]
+\relative c'' {
+ \key a \major
+ \time 6/8
+ cis8. d16 cis8 e4 e8
+ b8. cis16 b8 d4 d8
+}
@end lilypond
-More information on formatting piano music is given in @ref{Piano music}.
+If you make a mistake with an octave mark (@code{'} or @code{,}) while
+working in @code{\relative} mode, it is very obvious -- many notes will
+be in the wrong octave. When working in absolute mode, a single mistake
+will not be as visible, and will not be as easy to find.
+However, absolute mode is useful for music which has large intervals, and
+is extremely useful for computer-generated LilyPond files.
-@node Organizing larger pieces
-@section Organizing larger pieces
+
+@node Organizing pieces with identifiers
+@subsection Organizing pieces with identifiers
When all of the elements discussed earlier are combined to produce
-larger files, the @code{\score} blocks get a lot bigger because the
-music expressions are longer, and, in the case of polyphonic music,
-more deeply nested. Such large expressions can become unwieldy.
+larger files, the music expressions get a lot bigger. In polyphonic
+music with many staves, the input files can become very confusing. We can
+reduce this confusion by using @emph{identifiers}.
-By using variables, also known as identifiers, it is possible to break
-up complex music expressions. An identifier is assigned as follows
+With identifiers (also known as variables or macros), we can break up
+complex music expressions. An identifier is assigned as follows
@example
namedMusic = @{ @dots{} @}
@end example
-@noindent
-The contents of the music expression @code{namedMusic}, can be used
-later by preceding the name with a backslash, i.e., @code{\namedMusic}.
-In the next example, a two-note motive is repeated two times by using
-variable substitution
-
-@lilypond[quote,ragged-right,verbatim,nofragment]
-seufzer = {
- e'4( dis'4)
+The contents of the music expression @code{namedMusic} can be used
+later by placing a backslash in front of the name
+(@code{\namedMusic}, just like a normal LilyPond command). Identifiers
+must be defined @emph{before} the main music expression.
+
+@lilypond[quote,verbatim,ragged-right]
+violin = \new Staff { \relative c'' {
+ a4 b c b
+}}
+cello = \new Staff { \relative c {
+ \clef bass
+ e2 d
+}}
+{
+ <<
+ \violin
+ \cello
+ >>
}
-{ \seufzer \seufzer }
@end lilypond
-The name of an identifier should have alphabetic characters only: no
-numbers, underscores, or dashes. The assignment should be outside of
-running music.
+@noindent
+The name of an identifier must have alphabetic characters only: no
+numbers, underscores, or dashes.
It is possible to use variables for many other types of objects in the
input. For example,
@end example
Depending on its contents, the identifier can be used in different
-places. The following example uses the above variables
+places. The following example uses the above variables:
@example
\paper @{
@{ c4^\name @}
@end example
-More information on the possible uses of identifiers is given in the
-technical manual, in @ref{Input variables and Scheme}.
-@c fixme: the ref is too technical.
-
-
-@node An orchestral part
-@section An orchestral part
-
-In orchestral music, all notes are printed twice. Once in a part for
-the musicians, and once in a full score for the conductor. Identifiers can
-be used to avoid double work. The music is entered once, and stored in
-a variable. The contents of that variable is then used to generate
-both the part and the full score.
-
-It is convenient to define the notes in a special file. For example,
-suppose that the file @file{horn-music.ly} contains the following part
-of a horn/@/bassoon duo
-
-@example
-hornNotes = \relative c @{
- \time 2/4
- r4 f8 a cis4 f e d
-@}
-@end example
-
-@noindent
-Then, an individual part is made by putting the following in a file
-
-@example
-\include "horn-music.ly"
-\header @{
- instrument = "Horn in F"
-@}
-
-@{
- \transpose f c' \hornNotes
-@}
-@end example
-
-The line
-
-@example
-\include "horn-music.ly"
-@end example
-
-@noindent
-substitutes the contents of @file{horn-music.ly} at this position in
-the file, so @code{hornNotes} is defined afterwards. The command
-@code{\transpose f@tie{}c'} indicates that the argument, being
-@code{\hornNotes}, should be transposed by a fifth upwards. Sounding
-@samp{f} is denoted by notated @code{c'}, which corresponds with the
-tuning of a normal French Horn in@tie{}F. The transposition can be seen
-in the following output
-
-@lilypond[quote,ragged-right]
-\transpose f c' \relative c {
- \time 2/4
- r4 f8 a cis4 f e d
-}
-@end lilypond
-
-In ensemble pieces, one of the voices often does not play for many
-measures. This is denoted by a special rest, the multi-measure
-rest. It is entered with a capital @samp{R} followed by a duration
-(@code{1}@tie{}for a whole note, @code{2}@tie{}for a half note,
-etc.). By multiplying the
-duration, longer rests can be constructed. For example, this rest
-takes 3@tie{}measures in 2/4 time
-
-@example
-R2*3
-@end example
-
-When printing the part, multi-rests
-must be condensed. This is done by setting a run-time variable
-
-@example
-\set Score.skipBars = ##t
-@end example
-
-@noindent
-This command sets the property @code{skipBars} in the
-@code{Score} context to true (@code{##t}). Prepending the rest and
-this option to the music above, leads to the following result
-
-@lilypond[quote,ragged-right]
-\transpose f c' \relative c {
- \time 2/4
- \set Score.skipBars = ##t
- R2*3
- r4 f8 a cis4 f e d
-}
-@end lilypond
-
-
-The score is made by combining all of the music together. Assuming
-that the other voice is in @code{bassoonNotes} in the file
-@file{bassoon-music.ly}, a score is made with
-
-@example
-\include "bassoon-music.ly"
-\include "horn-music.ly"
-
-<<
- \new Staff \hornNotes
- \new Staff \bassoonNotes
->>
-@end example
-
-@noindent
-leading to
-
-@lilypond[quote,ragged-right]
-\relative c <<
- \new Staff {
- \time 2/4 R2*3
- r4 f8 a cis4 f e d
- }
- \new Staff {
- \clef bass
- r4 d,8 f | gis4 c | b bes |
- a8 e f4 | g d | gis f
- }
->>
-@end lilypond
-
-More in-depth information on preparing parts and scores can be found
-in the notation manual; see @ref{Orchestral music}.
-
-Setting run-time variables (@q{properties}) is discussed in
-@ref{Changing context properties on the fly}.
-
@node After the tutorial
-@section After the tutorial
+@subsection After the tutorial
After finishing the tutorial, you should probably try writing a
-piece or two. Start with one of the @ref{Example templates} and
+piece or two. Start with one of the @ref{Templates} and
add notes. If you need any notation that was not covered in the
tutorial, look at the Notation Reference, starting with
@ref{Basic notation}. If you want to write for an instrument
-ensemble which is not covered in the @ref{Example templates},
+ensemble which is not covered in the templates,
take a look at @ref{Extending the templates}.
Once you have written a few short pieces, read the rest of
now, and come back to them after you have more experience.
+@node How to read the manual
+@subsection How to read the manual
+
+As we saw in @ref{How to read the tutorial}, many examples in the
+tutorial omitted a @code{\relative c'' @{ ... @}} around the printed
+example.
+
+In the rest of the manual, we are much more lax about the
+printed examples: sometimes they may have omitted a
+@code{\relative c'' @{ ... @}}, but in other times a different initial
+pitch may be used (such as @code{c'} or @code{c,,}), and in some cases
+the whole example is in absolute note mode! However, ambiguities like
+this only exist where the pitches are not important. In any example
+where the pitch matters, we have explicitly stated our @code{\relative}
+our our absolute-mode @code{@{ @}}.
+
+If you are still confused about the exact LilyPond input that was
+used in an example, read the HTML version (if you are not already doing
+so) and click on the picture of the music. This will display the exact
+input that LilyPond used to generate this manual.
+
* Style sheets::
* Updating old files::
* Troubleshooting (taking it all apart)::
+* Minimal examples::
@end menu
Now start slowly uncommenting more and more of the
@code{bass} part until you find the problem line.
+Another very useful debugging technique is constructing
+@ref{Minimal examples}.
+
+
+@node Minimal examples
+@section Minimal examples
+
+A minimal example is an example which is small as possible. These
+examples are much easier to understand than long examples. Minimal
+examples are used for
+
+@itemize
+@item Bug reports
+@item Sending a help request to mailists
+@item Adding an example to the @uref{http://lsr@/.dsi@/.unimi/2.it/,LilyPond
+Snippet Repository}
+@end itemize
+
+To construct an example which is as small as possible, the rule is
+quite simple: remove anything which is not necessary. When trying to
+remove unnecessary parts of a file, it is a very good idea to comment
+out lines instead of deleting them. That way, if you discover that you
+actually @emph{do} need some lines, you can un-comment them, instead of
+typing them in from scratch.
+
+There are two exceptions to the @qq{as small as possible} rule:
+
+@itemize
+@item Include the @code{\version} number.
+@item If possible, use @code{\paper@{ ragged-right=##t @}} at the
+top of your example.
+@end itemize
+
+The whole point of a minimal example is to make it easy to read:
+
+@itemize
+@item Avoid using complicated notes, keys, or time signatures, unless you
+wish to demonstrate something is about the behavior of those items.
+@item Do not use \override commands unless that is the point of the
+example.
+@end itemize
+
PACKAGE_NAME=LilyPond
MAJOR_VERSION=2
MINOR_VERSION=11
-PATCH_LEVEL=12
+PATCH_LEVEL=13
MY_PATCH_LEVEL=
fi
mkdir -p scripts/out-cov/
-touch scripts/out-cov/midi2ly.1
+touch scripts/out-cov/midi2ly scripts/out-cov/midi2ly.1
make conf=cov -j2 && \
make conf=cov test-clean OUT_TEST=testcov LILYPOND_JOBS= && \
- make conf=cov test OUT_TEST=testcov LILYPOND_JOBS=
+ make conf=cov test OUT_TEST=testcov LILYPOND_JOBS='-dtrace-scheme-coverage '
if test "$?" != "0"; then
tail -100 out-cov/test-run.log
cd $resultdir
ln $depth/lily/* .
+ln $depth/scm/*.scm .
+mv $depth/input/regression/out-testcov/*.scm.cov .
+ln $depth/ly/*.ly .
ln $depth/lily/out-cov/*[ch] .
mkdir include
ln $depth/lily/include/* include/
python $depth/buildscripts/coverage.py --uncovered *.cc > uncovered.txt
python $depth/buildscripts/coverage.py --hotspots *.cc > hotspots.txt
python $depth/buildscripts/coverage.py --summary *.cc > summary.txt
+python $depth/buildscripts/coverage.py --uncovered *.scm > uncovered-scheme.txt
head -20 summary.txt
out/coverage-results/summary.txt
out/coverage-results/uncovered.txt
+ out/coverage-results/uncovered-scheme.txt
out/coverage-results/hotspots.txt
EOF
cat > long-score.ly << EOF
\version "2.10.0"
foo = \new Staff \new Voice \repeat unfold 50 \relative { c4 d8[ d16( e]~ e16[ e e) f] g8 }
-\new ChoirStaff <<
- \foo \foo \foo \foo
- \foo \foo \foo \foo
-
->>
+\score {
+ \new ChoirStaff <<
+ \foo \foo \foo \foo
+ \foo \foo \foo \foo
+
+ >>
+ \midi {}
+ \layout {}
+}
EOF
rm gmon.sum
cov = ''
sys.stdout.write ('%8s:%8d:%s' % (cov, n, l))
+ def uncovered_score (self):
+ return self.length ()
+
+class SchemeChunk (Chunk):
+ def uncovered_score (self):
+ text = self.text ()
+ if (text.startswith ('(define ')
+ and not text.startswith ('(define (')):
+ return 0
+
+ if (text.startswith ('(define-public ')
+ and not text.startswith ('(define-public (')):
+ return 0
+
+ return len ([l for (c,n,l) in self.lines() if (c == 0)])
+
def read_gcov (f):
ls = []
in_lines = [l for l in open (f).readlines ()]
- (count_len, line_num_len) = tuple (map (len, in_lines[0].split( ':')[:2]))
+ (count_len, line_num_len) = tuple (map (len, in_lines[0].split (':')[:2]))
for l in in_lines:
c = l[:count_len].strip ()
return ls
-def get_chunks (ls, file):
+def get_c_chunks (ls, file):
chunks = []
chunk = []
return chunks
+def get_scm_chunks (ls, file):
+ chunks = []
+ chunk = []
+
+ def new_chunk ():
+ if chunk:
+ nums = [n-1 for (n, l) in chunk]
+ chunks.append (SchemeChunk ((min (nums), max (nums)+1),
+ max (last_c, 0), ls, file))
+ chunk[:] = []
+
+ last_c = -1
+ for (cov_count, line_number, line) in ls:
+ if line.startswith ('('):
+ new_chunk ()
+ last_c = -1
+
+ chunk.append ((line_number, line))
+ if cov_count >= 0:
+ last_c = cov_count
+
+ return chunks
+
def widen_chunk (ch, ls):
a -= 1
b += 1
print s
return []
- return get_chunks (ls, file)
+ cs = []
+ if 'scm' in file:
+ cs = get_scm_chunks (ls, file)
+ else:
+ cs = get_c_chunks (ls, file)
+ return cs
+
def filter_uncovered (chunks):
def interesting (c):
if options.uncovered or options.hotspots:
chunks = []
for a in args:
- chunks += extract_chunks ('%s.gcov' % a)
+ name = a
+ if name.endswith ('scm'):
+ name += '.cov'
+ else:
+ name += '.gcov'
+
+ chunks += extract_chunks (name)
if options.uncovered:
chunks = filter_uncovered (chunks)
- chunks = [(c.length (), c) for c in chunks]
+ chunks = [(c.uncovered_score (), c) for c in chunks]
elif options.hotspots:
chunks = [((c.coverage_count, -c.length()), c) for c in chunks]
--- /dev/null
+#!/usr/bin/python
+import sys
+import os
+import os.path
+import shutil
+
+dirs = ['advanced','trick']
+
+try:
+ in_dir = sys.argv[1]
+except:
+ print "Please specify input_file."
+ sys.exit()
+
+for dir in dirs:
+ srcdir = os.path.join (in_dir, dir)
+ destdir = os.path.join ('input', 'lsr', dir)
+ if not(os.path.isdir(destdir)):
+ print "Please run this script from the head of the source tree,"
+ print " and/or check that you have the right categories."
+ sys.exit()
+
+ file_names = os.listdir (destdir)
+ for file in file_names:
+ if (file.endswith ('.ly')):
+ if (file[:3] != 'AAA'):
+ os.remove( os.path.join(destdir,file) )
+
+ file_names = os.listdir (in_dir + dir)
+ for file in file_names:
+ src = os.path.join (srcdir, file)
+ dest = os.path.join (destdir, file)
+ shutil.copyfile (src, dest)
+
note_info, self.contents[oldnew])
dist = 0.0
- factor = {'time': 3.0 ,
- 'cells': 5.0,
- }
+ factor = {
+ 'time': 1.0 ,
+ 'cells': 5.0,
+ }
for k in ('time', 'cells'):
- real_val = math.tan (self.get_ratio (k) * 0.5* math.pi)
+ real_val = math.tan (self.get_ratio (k) * 0.5 * math.pi)
dist += math.exp (math.fabs (real_val) * factor[k]) - 1
dist = min (dist, 100)
return *this;
}
- Real linear_combination (Real x) const
- {
- Drul_array<Real> da (at (LEFT), at (RIGHT));
- return ::linear_combination (da, x);
- }
+ Real linear_combination (Real x) const;
string to_string () const;
bool contains (T r) const;
#include "std-string.hh"
#include "real.hh"
-class Offset;
-Offset complex_multiply (Offset, Offset);
-Offset complex_divide (Offset, Offset);
-Offset complex_exp (Offset);
/*
This is a mixture a 2D vector. Sometimes it can
coordinate_a_[a] = -coordinate_a_[a];
return *this;
}
-
+ Offset direction () const;
+
Real arg () const;
+ Real angle_degrees () const;
Real length () const;
bool is_sane () const;
- Offset operator *= (Offset z2)
- {
- *this = complex_multiply (*this, z2);
- return *this;
- }
+ Offset operator *= (Offset z2);
};
#include "arithmetic-operator.hh"
IMPLEMENT_ARITHMETIC_OPERATOR (Offset, -);
IMPLEMENT_ARITHMETIC_OPERATOR (Offset, *);
+
+
+Offset complex_multiply (Offset, Offset);
+Offset complex_divide (Offset, Offset);
+Offset complex_exp (Offset);
+
+inline Offset
+Offset::operator *= (Offset z2)
+{
+ *this = complex_multiply (*this, z2);
+ return *this;
+}
+
inline Offset
operator * (Real o1, Offset o2)
{
#include "offset.hh"
-
#ifndef STANDALONE
string
Offset::to_string () const
return atan2 (coordinate_a_[Y_AXIS], coordinate_a_[X_AXIS]);
}
+Real
+Offset::angle_degrees () const
+{
+ return arg () * 180 / M_PI;
+}
/**
euclidian vector length / complex modulus
*/
&& !isinf (coordinate_a_[X_AXIS])
&& !isnan (coordinate_a_[Y_AXIS]);
}
+
+Offset
+Offset::direction () const
+{
+ Offset d = *this;
+ d /= length ();
+ return d;
+}
depth = ..
-SUBDIRS = test regression tutorial mutopia manual
+SUBDIRS = test regression tutorial mutopia manual lsr
examples = typography-demo les-nereides wilhelmus proportional bach-schenker cary
--- /dev/null
+depth = ../../
+
+SUBDIRS = advanced trick
+
+STEPMAKE_TEMPLATES=documentation texinfo tex
+LOCALSTEPMAKE_TEMPLATES=lilypond ly lysdoc
+
+include $(depth)/make/stepmake.make
+
+
+TITLE=LilyPond Examples
+
--- /dev/null
+\version "2.10.0"
+\header{
+texidoc = "@unnumbered LilyPond Examples
+
+These pages show LilyPond examples (snippets) from the
+@uref{http://lsr@/.dsi@/.unimi@/.it,LilyPond Snippet Repository}.
+
+@c @h eading @uref{../trick/collated-files.html,Trick}:
+@strong{@uref{trick/collated-files.html,Trick}}:
+These snippets are blah blah.
+
+@c @h eading @uref{../advanced/collated-files.html,Advanced}:
+@strong{@uref{advanced/collated-files.html,Advanced}}:
+These snippets are fazzle snap.
+
+"
+}
+
+% make sure .png is generated.
+\lyrics { " " }
+% \lyrics { "(left blank intentionally)" }
--- /dev/null
+# -*-python-*-
+
+Import ('env', 'collate')
+collate (title = 'LilyPond Examples')
--- /dev/null
+\version "2.10.0"
+%% +.ly: Be the first .ly file for lys-to-tely.py.
+%% Better to make lys-to-tely.py include "introduction.texi" or
+%% other .texi documents too?
+
+\header{
+texidoc = #(string-append "
+@unnumbered Introduction
+
+This document shows all kinds of advanced snippets from the
+@uref{http://lsr@/.dsi@/.unimi@/.it,LilyPond Snippet Repository}.
+
+In the web version of this document, you can click on the file name
+or figure for each example to see the corresponding input file.
+
+This document is for LilyPond version
+" (lilypond-version) "." )
+}
+
+% make sure .png is generated.
+\lyrics { " " }
--- /dev/null
+\version "2.10.12"
+
+\header { texidoc = "
+<p>The eighth notes may be seemingly attached to different
+ beams, and the corresponding notes connected by ties.
+ Such a situation may occur, for example, in the cello suites.
+" }
+
+wipeNote = {
+ \once \override NoteHead #'transparent = ##t
+ \once \override Stem #'transparent = ##t
+}
+\layout { raggedright = ##t }
+
+
+\relative c''<< {
+ c8[~
+ \wipeNote
+ c8
+ c8~
+ \wipeNote
+ c
+ c]~
+ \wipeNote
+ c\noBeam
+}\\
+ { s8 c8 [ s c s c] }
+
+
+>>
+
--- /dev/null
+
+depth = ../../../
+
+STEPMAKE_TEMPLATES=documentation texinfo tex
+LOCALSTEPMAKE_TEMPLATES=lilypond ly lysdoc
+
+## Hmm, would this work? No -- if we really want examples, move
+## to other dir (input/) comes to mind.
+## examples = font20 ancient-font
+## LOCALSTEPMAKE_TEMPLATES += ly mutopia
+
+EXTRA_DIST_FILES=
+
+include $(depth)/make/stepmake.make
+
+TITLE=Advanced snippets
--- /dev/null
+# -*-python-*-
+
+Import ('env', 'collate')
+collate (title = 'Advanced snippets')
--- /dev/null
+\version "2.10.0"
+%% +.ly: Be the first .ly file for lys-to-tely.py.
+%% Better to make lys-to-tely.py include "introduction.texi" or
+%% other .texi documents too?
+
+\header{
+texidoc = #(string-append "
+@unnumbered Introduction
+
+This document shows all kinds of tricks from the
+@uref{http://lsr@/.dsi@/.unimi@/.it,LilyPond Snippet Repository}.
+
+In the web version of this document, you can click on the file name
+or figure for each example to see the corresponding input file.
+
+This document is for LilyPond version
+" (lilypond-version) "." )
+}
+
+% make sure .png is generated.
+\lyrics { " " }
--- /dev/null
+\version "2.10.12"
+
+\header { texidoc = "
+A caesura is sometimes denoted with a double \"railtracks\" breath mark with a fermata sign positioned over the top of the railtracks. This snippet should present an optically pleasing combination of railtracks and a fermata.
+
+It works for lilypond 2.5 and above.
+" }
+
+{
+ \context Voice {
+ c''2.
+ % use some scheme code to construct the symbol
+ \override BreathingSign #'text = #(markup #:line
+ (#:musicglyph "scripts.caesura"
+ #:translate (cons -1.75 1.6)
+ #:musicglyph "scripts.ufermata"
+ ))
+ \breathe c''4
+ % set the breathe mark back to normal
+ \revert BreathingSign #'text
+ c''2. \breathe c''4
+ \bar "|."
+ }
+}
+
--- /dev/null
+
+depth = ../../../
+
+STEPMAKE_TEMPLATES=documentation texinfo tex
+LOCALSTEPMAKE_TEMPLATES=lilypond ly lysdoc
+
+## Hmm, would this work? No -- if we really want examples, move
+## to other dir (input/) comes to mind.
+## examples = font20 ancient-font
+## LOCALSTEPMAKE_TEMPLATES += ly mutopia
+
+EXTRA_DIST_FILES=
+
+include $(depth)/make/stepmake.make
+
+TITLE=Trick snippets
--- /dev/null
+# -*-python-*-
+
+Import ('env', 'collate')
+collate (title = 'Trick snippets')
--- /dev/null
+\version "2.10.12"
+
+\header { texidoc = "
+This snippet shows a way to insert available Feta font symbols as caesurae and ways to create tramlines. Normally a caesura is indicated by a pair of oblique lines lying through the top line of the staff, also called a fetura, tramlines, railroad tracks, or a cut-off. LilyPond provides several alternatives. A stylized version of tramlines is called caesura. The normal tramline form, here called fetura, is not in the Feta font set, but can be constructed using the / character.
+" }
+
+\version "2.8.4"
+%{ This snippet shows a way to insert available Feta font symbols as caesurae
+ and ways to create tramlines. Normally a caesura is indicated by a pair of
+ oblique lines lying through the top line of the staff, also called a fetura,
+ tramlines, railroad tracks, or a cut-off. LilyPond provides several
+ alternatives. A stylized version of tramlines is called caesura. The normal
+ tramline form, here called fetura, is not in the Feta font set, but can be
+ constructed using the / character.%}
+ \relative c'' {
+\time 3/4
+e4 d e
+ % default
+e_\markup { "default - breathe" }
+ \breathe d e |
+ % rcomma
+ % by default, \breathe uses the rcomma, just as if saying:
+ \override BreathingSign #'text =
+ #(make-musicglyph-markup "scripts.rcomma")
+e_\markup rcomma \breathe d e |
+ % lcomma
+ \override BreathingSign #'text =
+ #(make-musicglyph-markup "scripts.lcomma")
+e_\markup lcomma \breathe d e |
+ % rvarcomma
+ \override BreathingSign #'text =
+ #(make-musicglyph-markup "scripts.rvarcomma")
+e_\markup rvarcomma \breathe d e | \break
+ % lvarcomma
+ \override BreathingSign #'text =
+ #(make-musicglyph-markup "scripts.lvarcomma")
+e_\markup lvarcomma \breathe d e |
+ % upbow or wedge
+ \override BreathingSign #'text =
+ #(make-musicglyph-markup "scripts.upbow")
+e_\markup upbow \breathe d e |
+ % caesura
+ \override BreathingSign #'text =
+ #(make-musicglyph-markup "scripts.caesura")
+e_\markup caesura \breathe d e |
+ % fetura, tramlines, or railroad tracks
+<<{
+\hideNotes a16 a a a a4 a \unHideNotes
+}\\{
+ \once\override TextScript #'extra-offset = #'(4.0 . -2.7)
+e^\markup {\fontsize #2 {\bold "/" \hspace #-1.4 \bold "/"}}
+d_\markup { \hspace #-10 "fetura" } e |
+}>>
+ \once\override TextScript #'font-name = #"cmb10"
+ \once\override TextScript #'extra-offset = #'(4.0 . -2.2)
+e^\markup {\magnify #1.3 { "/" \hspace #-1.5 "/"}}
+ \once \override Score.SeparationItem #'padding = #4
+d_\markup { \hspace #-10 "fetura" } e |
+
+e d e \bar "||"
+ }%end relative
+ \layout{
+indent = 0.00\in
+ }%end layout
+
+
+++ /dev/null
-\version "2.10.0"
-%% +.ly: Be the first .ly file for lys-to-tely.py.
-%% Better to make lys-to-tely.py include "introduction.texi" or
-%% other .texi documents too?
-
-
-\header{
-texidoc =
-
-#(string-append "@unnumbered Introduction
-
-This document presents proofs for
-LilyPond " (lilypond-version) ". When the
-text corresponds with the shown notation, we consider LilyPond Officially
-BugFree (tm). This document is intended for finding bugs and for
-documenting bugfixes.
-
-In the web version of this document, you can click on the file name
-or figure for each example to see the corresponding input file.
-
-TODO: order of tests (file names!), test only one feature per test.
-Smaller and neater tests.
-")
-
-}
-
-%
-% make sure the .png is generated.
-%
-\lyrics { "(left blank intentionally)" }
-
--- /dev/null
+\version "2.10.0"
+%% +.ly: Be the first .ly file for lys-to-tely.py.
+%% Better to make lys-to-tely.py include "introduction.texi" or
+%% other .texi documents too?
+
+
+\header{
+texidoc =
+
+#(string-append "@unnumbered Introduction
+
+This document presents proofs for
+LilyPond " (lilypond-version) ". When the
+text corresponds with the shown notation, we consider LilyPond Officially
+BugFree (tm). This document is intended for finding bugs and for
+documenting bugfixes.
+
+In the web version of this document, you can click on the file name
+or figure for each example to see the corresponding input file.
+
+TODO: order of tests (file names!), test only one feature per test.
+Smaller and neater tests.
+")
+
+}
+
+%
+% make sure the .png is generated.
+%
+\lyrics { "(left blank intentionally)" }
+
--- /dev/null
+
+\header {
+
+
+ texidoc = "Autobeamer remembers @code{subdivideBeams} and other
+beaming pattern related functions at the start of an autobeam."
+
+}
+
+
+\version "2.11.12"
+\paper { ragged-right = ##t }
+{
+ \time 2/4
+ b16 b b b
+ b16 b b b
+ \set subdivideBeams = ##t
+ \set Score.beatLength = #(ly:make-moment 1 8)
+ b16 b b b
+ b16 b b b
+}
\makeClusters { <g a>8 <e a> <g a>4 }
\override Glissando #'style = #'zigzag
- f2 \glissando f'
+ \slurDashed
+ f2( \glissando f')
\setEasyHeads
f e
}
%%%
%%% Testing utilities
%%%
-
+#(use-modules (scm display-lily))
+#(memoize-clef-names supported-clefs)
#(define (parse-lily-and-compute-lily-string chr port)
(let ((lily-string (call-with-output-string
(lambda (out)
(if result-info
result-info "BUG")
input output))
-
-
- (make-music 'SequentialMusic 'void #t)
-
- ))))
+ (make-music 'SequentialMusic 'void #t)))))
test =
#(define-music-function (parser location result-info strings) (string? pair?)
stderr of this run."
}
-
%% Sequential music
\test "" ##[ { { a b } { c d } } #] % SequentialMusic
\test "" ##[ << { a b } { c d } >> #] % SimultaneousMusic
--- /dev/null
+\header {
+ texidoc = "If broken, Glissandi anticipate on the pitch of the next line."
+
+}
+\version "2.11.13"
+\paper {
+ ragged-right = ##T }
+
+\relative c'' {
+ \override Glissando #'breakable = ##t
+ d1 \glissando |
+ \break
+ c,1
+}
--- /dev/null
+\version "2.11.12"
+\paper { ragged-right = ##t }
+\header {
+
+ texidoc = "hairpinToBarline is not confused by very long marks."
+
+}
+
+\new Staff \relative c' {
+ c1\< |
+ \mark "Very long mark"
+ c4\> c c c\! |
+}
--- /dev/null
+\header {
+ texidoc = "Cover all line styles available"
+
+}
+\version "2.11.13"
+\paper {
+ ragged-right = ##T
+}
+
+\relative c'' {
+ \override Glissando #'breakable = ##t
+
+ s2
+ d2 \glissando d'2
+ \once \override Glissando #'dash-fraction = #0.5
+ d,2 \glissando d'2
+ \override Glissando #'style = #'dotted-line
+ d,2 \glissando d'2
+
+ \override Glissando #'style = #'zigzag
+ d,2 \glissando d'2
+ \override Glissando #'style = #'trill
+ d,2 \glissando d'2
+}
--- /dev/null
+\header {
+
+ texidoc = "@code{showLastLength} will only show the last bit of a score"
+
+ }
+
+\version "2.10.12"
+
+showLastLength = R1*3
+\paper {
+ ragged-right = ##T
+}
+
+{
+ c1 c1
+ c1 c1
+ c1 c1
+}
--- /dev/null
+\header{
+
+ texidoc = "Skyline horizontal spacing may fold non-adjacent columns
+together, but they still do not collide. In this case, the arpeggio
+and the barline do not collide."
+
+}
+
+\version "2.11.13"
+
+\paper
+{
+ ragged-right = ##t
+}
+
+\new Staff
+\relative c
+{
+ \override Score.NonMusicalPaperColumn #'stencil = #ly:paper-column::print
+ \time 6/8
+ \clef bass
+ s2. |
+ \relative c <<
+ {
+ <des ges b des>4\arpeggio
+ }
+ \\
+ {
+ \acciaccatura ges,8 \voiceTwo ges4
+ }
+ >>
+}
--- /dev/null
+\header
+{
+
+ texidoc = "Tab supports slides."
+}
+
+\version "2.11.10"
+\paper {
+ ragged-right = ##T
+}
+
+
+\relative \new TabVoice
+{
+ <c g'\harmonic> d\2\glissando e\2
+}
+++ /dev/null
-\version "2.10.0"
-%% +.ly: Be the first .ly file for lys-to-tely.py.
-%% Better to make lys-to-tely.py include "introduction.texi" or
-%% other .texi documents too?
-
-\header{
-texidoc = #(string-append "
-@section Introduction
-
-This document shows all kinds of tips and tricks, from simple to
-advanced. You may also find dirty tricks, or the very very
-latest features that have not been documented or fully implemented
-yet.
-
-In the web version of this document, you can click on the file name
-or figure for each example to see the corresponding input file.
-
-This document is for LilyPond version
-" (lilypond-version) ".")
-}
-
-% make sure .png is generated.
-\lyrics { "(left blank intentionally)" }
--- /dev/null
+\version "2.10.0"
+%% +.ly: Be the first .ly file for lys-to-tely.py.
+%% Better to make lys-to-tely.py include "introduction.texi" or
+%% other .texi documents too?
+
+\header{
+texidoc = #(string-append "
+@unnumbered Introduction
+
+This document shows all kinds of tips and tricks, from simple to
+advanced. You may also find dirty tricks, or the very very
+latest features that have not been documented or fully implemented
+yet.
+
+In the web version of this document, you can click on the file name
+or figure for each example to see the corresponding input file.
+
+This document is for LilyPond version
+" (lilypond-version) ".")
+}
+
+% make sure .png is generated.
+\lyrics { "(left blank intentionally)" }
Real padding = robust_scm2double (me->get_property ("padding"), 0.2);
Skyline left_skyline = head_ape->left_skyline_;
- left_skyline.raise (-robust_scm2double (me->get_property ("right-padding"), 0))
-;
+ left_skyline.raise (-robust_scm2double (me->get_property ("right-padding"), 0));
+
/*
Add accs entries right-to-left.
*/
me->flush_extent_cache (X_AXIS);
me->set_property ("X-extent", scm_width);
- for (vsize i = apes.size (); i--;)
- delete apes[i];
+ junk_pointers (apes);
+ delete head_ape;
+
return SCM_BOOL_T;
}
vector<Box> boxes;
bool parens = to_boolean (me->get_property ("parenthesized"));
+ if (!me->is_live ())
+ return boxes;
SCM scm_style = me->get_property ("style");
if (!scm_is_symbol (scm_style)
&& !to_boolean (me->get_property ("restore-first"))
&& !parens)
{
- Rational alteration = ly_scm2rational (me->get_property ("alteration"));
+ Rational alteration
+ = robust_scm2rational (me->get_property ("alteration"), 0);
if (alteration == FLAT_ALTERATION)
{
Box stem = b;
if (!scm_is_string (glyph_name))
{
me->warning (_f ("Could not find glyph-name for alteration %s",
- ly_scm2rational (alt).to_string ().c_str ()));
+ ly_scm_write_string (alt).c_str ()));
return SCM_EOL;
}
start_key_sig_);
Rational sig_alter = (handle != SCM_BOOL_F)
- ? ly_scm2rational (scm_cdr (handle)) : Rational (0);
+ ? robust_scm2rational (scm_cdr (handle), Rational (0)) : Rational (0);
if (sig_alter == p.get_alteration ())
{
#include "audio-staff.hh"
-#include "midi-item.hh"
+#include "midi-chunk.hh"
#include "midi-stream.hh"
#include "midi-walker.hh"
Midi_walker i (this, &midi_track, channel);
for (; i.ok (); i++)
i.process ();
+
+ i.finalize ();
midi_stream.write (midi_track);
}
Moment beam_start_moment_;
Moment beam_start_location_;
- bool subdivide_beams_;
- Moment beat_length_;
-
// We act as if beam were created, and start a grouping anyway.
Beaming_pattern *grouping_;
SCM beam_settings_;
Beaming_pattern *finished_grouping_;
+
+ Beaming_options beaming_options_;
+ Beaming_options finished_beaming_options_;
+
+
void check_bar_property ();
};
stems_ = new vector<Item*>;
grouping_ = new Beaming_pattern ();
+ beaming_options_.from_context (context ());
beam_settings_ = updated_grob_properties (context (), ly_symbol2scm ("Beam"));
beam_start_moment_ = now_mom ();
{
announce_end_grob (finished_beam_, SCM_EOL);
finished_grouping_ = grouping_;
+ finished_beaming_options_ = beaming_options_;
}
delete stems_;
stems_ = 0;
if (!finished_beam_->get_bound (RIGHT))
finished_beam_->set_bound (RIGHT, finished_beam_->get_bound (LEFT));
- finished_grouping_->beamify (context ());
+ finished_grouping_->beamify (finished_beaming_options_);
Beam::set_beaming (finished_beam_, finished_grouping_);
finished_beam_ = 0;
/// moment (global time) where beam started.
Moment beam_start_mom_;
- bool subdivide_beams_;
- Moment beat_length_;
-
+ Beaming_options beaming_options_;
+ Beaming_options finished_beaming_options_;
+
void typeset_beam ();
void set_melisma (bool);
beam_start_location_ = mp;
beam_start_mom_ = now_mom ();
+ beaming_options_.from_context (context ());
beam_info_ = new Beaming_pattern;
/* urg, must copy to Auto_beam_engraver too */
}
typeset_beam ();
if (stop_ev_ && beam_)
- announce_end_grob (beam_, stop_ev_->self_scm ());
+ {
+ announce_end_grob (beam_, stop_ev_->self_scm ());
+
+ }
}
void
{
if (!finished_beam_->get_bound (RIGHT))
finished_beam_->set_bound (RIGHT, finished_beam_->get_bound (LEFT));
-
- finished_beam_info_->beamify (context ());
+
+ finished_beam_info_->beamify (finished_beaming_options_);
Beam::set_beaming (finished_beam_, finished_beam_info_);
delete finished_beam_info_;
{
finished_beam_ = beam_;
finished_beam_info_ = beam_info_;
-
+ finished_beaming_options_ = beaming_options_;
+
stop_ev_ = 0;
beam_ = 0;
beam_info_ = 0;
}
void
-Beaming_pattern::beamify (Context *context)
+Beaming_pattern::beamify (Beaming_options const &options)
{
if (infos_.size () <= 1)
return;
if (infos_[0].start_moment_.grace_part_)
de_grace ();
-
- bool subdivide_beams = to_boolean (context->get_property ("subdivideBeams"));
- Moment beat_length = robust_scm2moment (context->get_property ("beatLength"), Moment (1, 4));
- Moment measure_length = robust_scm2moment (context->get_property ("measureLength"), Moment (1, 4));
if (infos_[0].start_moment_ < Moment (0))
for (vsize i = 0; i < infos_.size(); i++)
- infos_[i].start_moment_ += measure_length;
+ infos_[i].start_moment_ += options.measure_length_;
- SCM grouping = context->get_property ("beatGrouping");
Moment measure_pos (0);
vector<Moment> group_starts;
vector<Moment> beat_starts;
-
+
+ SCM grouping = options.grouping_;
while (measure_pos <= infos_.back().start_moment_)
{
int count = 2;
group_starts.push_back (measure_pos);
for (int i = 0; i < count; i++)
{
- beat_starts.push_back (measure_pos + beat_length * i);
+ beat_starts.push_back (measure_pos + options.beat_length_ * i);
}
- measure_pos += beat_length * count;
+ measure_pos += options.beat_length_ * count;
}
vsize j = 0;
&& group_starts[j+1] <= infos_[i].start_moment_)
j++;
- infos_[i].group_start_ = group_starts[j];
- infos_[i].beat_length_ = beat_length;
+ if (j < group_starts.size ())
+ infos_[i].group_start_ = group_starts[j];
+
+ infos_[i].beat_length_ = options.beat_length_;
while (k + 1 < beat_starts.size()
&& beat_starts[k+1] <= infos_[i].start_moment_)
k++;
- infos_[i].beat_start_ = beat_starts[k];
+ if (k < beat_starts.size())
+ infos_[i].beat_start_ = beat_starts[k];
}
- beamify (subdivide_beams);
+ beamify (options.subdivide_beams_);
}
{
return infos_.at (i).beam_count_drul_[d];
}
+
+void
+Beaming_options::from_context (Context *context)
+{
+ grouping_ = context->get_property ("beatGrouping");
+ subdivide_beams_ = to_boolean (context->get_property ("subdivideBeams"));
+ beat_length_ = robust_scm2moment (context->get_property ("beatLength"), Moment (1, 4));
+ measure_length_ = robust_scm2moment (context->get_property ("measureLength"), Moment (1, 4));
+}
+
+Beaming_options::Beaming_options ()
+{
+ grouping_ = SCM_EOL;
+ subdivide_beams_ = false;
+}
int
Constrained_breaking::max_system_count (vsize start, vsize end)
{
- vsize brk = (end >= start_.size ()) ? breaks_.size () - 1 : starting_breakpoints_[end];
+ vsize brk = (end >= start_.size ()) ? breaks_.size () : starting_breakpoints_[end];
return brk - starting_breakpoints_[start];
}
}
void
-Context::internal_set_property (SCM sym, SCM val
-#ifndef NDEBUG
- , char const *file, int line, char const *fun
-#endif
- )
+Context::internal_set_property (SCM sym, SCM val)
{
-#ifndef NDEBUG
- (void) file;
- (void) line;
- (void) fun;
-#endif
-
if (do_internal_type_checking_global)
assert (type_check_assignment (sym, val, ly_symbol2scm ("translation-type?")));
#include "stream-event.hh"
#include "warn.hh"
#include "spanner.hh"
+#include "text-interface.hh"
#include "translator.icc"
context ()->set_property ((start_type
+ "Spanner").c_str (), SCM_EOL);
s = get_property ((start_type + "Text").c_str ());
- /*
- FIXME: use get_markup () to check type.
- */
- if (scm_is_string (s) || scm_is_pair (s))
+ if (Text_interface::is_markup (s))
{
- cresc_->set_property ("edge-text",
- scm_cons (s, scm_from_locale_string ("")));
+ cresc_->set_property ("text", s);
context ()->set_property ((start_type + "Text").c_str (),
SCM_EOL);
}
if (!finished_cresc_->get_bound (RIGHT)
|| use_bar)
{
- Grob *column_bound = unsmob_grob (use_bar
- ? get_property ("currentCommandColumn")
- : get_property ("currentMusicalColumn"));
-
+
+ Grob *column_bound = 0;
+ if (use_bar)
+ {
+ column_bound = unsmob_grob (get_property ("breakableSeparationItem"));
+ }
+
+ if (!column_bound)
+ column_bound = unsmob_grob (use_bar
+ ? get_property ("currentCommandColumn")
+ : get_property ("currentMusicalColumn"));
+
finished_cresc_->set_bound (RIGHT, script_
? script_
: column_bound);
+++ /dev/null
-/*
- dynamic-text-spanner.cc -- implement Text_spanner
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2000--2007 Jan Nieuwenhuizen <janneke@gnu.org>
-
- Revised over good by Han-Wen.
-*/
-
-#include "text-interface.hh"
-#include "text-spanner.hh"
-#include "line-spanner.hh"
-#include "spanner.hh"
-#include "font-interface.hh"
-#include "dimensions.hh"
-#include "output-def.hh"
-#include "warn.hh"
-#include "paper-column.hh"
-
-class Dynamic_text_spanner
-{
-public:
- DECLARE_SCHEME_CALLBACK (print, (SCM));
- DECLARE_GROB_INTERFACE();
-};
-
-/*
- This is a partial C&P from text-spanner.cc
-
- Dynamic_text_spanner is similar, but
-
- * does not require bracket functionality.
-
- * should make room for spanning points (mf/f/mp texts).
-
- * In the future, we should support
-
- cresc - - - - poco - - - a - - - - poco - - -
-
- as well
-
-
- The cut & paste is rather inelegant, but text-spanner was a failed
- and buggy attempt at being generic.
-*/
-MAKE_SCHEME_CALLBACK (Dynamic_text_spanner, print, 1);
-SCM
-Dynamic_text_spanner::print (SCM smob)
-{
- Grob *me = unsmob_grob (smob);
- Spanner *spanner = dynamic_cast<Spanner *> (me);
-
- Grob *common = spanner->get_bound (LEFT)
- ->common_refpoint (spanner->get_bound (RIGHT), X_AXIS);
- Output_def *layout = me->layout ();
-
- Interval span_points;
- Drul_array<bool> broken;
- Direction d = LEFT;
- do
- {
- Item *b = spanner->get_bound (d);
- broken[d] = b->break_status_dir () != CENTER;
-
- if (broken[d])
- {
- if (d == LEFT)
- span_points[d] = spanner->get_broken_left_end_align ();
- else
- span_points[d] = b->relative_coordinate (common, X_AXIS);
- }
- else
- {
- Real pad = 0.0;
- Real encl = d;
- if (b->internal_has_interface (ly_symbol2scm ("dynamic-interface")))
- {
- pad = robust_scm2double (me->get_property ("bound-padding"), 0.0);
- encl = -d;
- }
-
- /*
- ugh - a special case.
-
- FIXME: this fixed an issue, but need to have this issue in
- the issue tracker.
-
- This fix doesn't quite work: it should only do this if the
- right bound has a trill too.
- */
-#if 0
- if (d == RIGHT && me->get_property ("style") == ly_symbol2scm ("trill"))
- {
- pad = 2.0;
- encl = LEFT;
- }
-#endif
-
- Interval ext = b->extent (common, X_AXIS);
- span_points[d] = -d * pad
- + robust_relative_extent (b, common, X_AXIS)
- .linear_combination (encl);
- }
- }
- while (flip (&d) != LEFT);
-
- SCM properties = Font_interface::text_font_alist_chain (me);
- SCM edge_text = me->get_property ("edge-text");
- Drul_array<Stencil> edge;
- if (scm_is_pair (edge_text))
- {
- Direction d = LEFT;
- do
- {
- if (broken[d])
- continue;
-
- SCM text = index_get_cell (edge_text, d);
-
- if (Text_interface::is_markup (text))
- edge[d] = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, text));
-
- if (!edge[d].is_empty ())
- edge[d].align_to (Y_AXIS, CENTER);
- }
- while (flip (&d) != LEFT);
- }
-
- Stencil m;
- do
- {
- Interval ext = edge[d].extent (X_AXIS);
- Real pad = robust_scm2double (me->get_property ("bound-padding"), 0.0);
- if (!ext.is_empty ())
- {
- edge[d].translate_axis (span_points[d], X_AXIS);
- m.add_stencil (edge[d]);
- span_points[d] += -d * (ext[-d] + pad);
- }
- }
- while (flip (&d) != LEFT);
-
- if (!span_points.is_empty ()
- && span_points.length () > robust_scm2double (me->get_property ("dash-period"), 0.0))
- {
- Stencil l = Line_spanner::line_stencil (me,
- Offset (span_points[LEFT], 0),
- Offset (span_points[RIGHT], 0));
- m.add_stencil (l);
- }
- m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
- return m.smobbed_copy ();
-}
-
-ADD_INTERFACE (Dynamic_text_spanner,
- "A text spanner for crescendo texts",
-
- "bound-padding "
- "dash-period "
- "dash-fraction "
- "edge-text "
- "style "
- "thickness");
-
--- /dev/null
+/*
+ freetype-error.cc -- implement freetype error messages
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2007 Han-Wen Nienhuys <hanwen@lilypond.org>
+
+*/
+
+#include "freetype.hh"
+
+#undef __FTERRORS_H__
+#define FT_ERRORDEF( e, v, s ) { e, s },
+#define FT_ERROR_START_LIST {
+#define FT_ERROR_END_LIST { 0, 0 } };
+
+const struct Freetype_error_message
+{
+ int err_code;
+ const char* err_msg;
+} ft_errors[] =
+
+#include <freetype/fterrors.h>
+
+ ;
+
+
+#include <string>
+
+string
+freetype_error_string (int code)
+{
+ for (Freetype_error_message const *p = ft_errors;
+ p->err_msg; p ++)
+ {
+ if (p->err_code == code)
+ return p->err_msg;
+ }
+
+ return "<unknown error>";
+}
+
#include "config.hh"
#include <cstdio>
+#include <ctype.h>
#include <cstring> /* memset */
using namespace std;
#include "file-path.hh"
#include "relocate.hh"
#include "file-name.hh"
+#include "string-convert.hh"
LY_DEFINE (ly_find_file, "ly:find-file",
1, 0, 0, (SCM name),
return lst;
}
+string
+format_single_argument (SCM arg, int precision)
+{
+ if (scm_is_integer (arg) && scm_exact_p (arg) == SCM_BOOL_T)
+ return (String_convert::int_string (scm_to_int (arg)));
+ else if (scm_is_number (arg))
+ {
+ Real val = scm_to_double (arg);
+
+ if (isnan (val) || isinf (val))
+ {
+ warning (_ ("Found infinity or nan in output. Substituting 0.0"));
+ return ("0.0");
+ if (strict_infinity_checking)
+ abort();
+ }
+ else
+ return (String_convert::form_string ("%.*lf", precision, val));
+ }
+ else if (scm_is_string (arg))
+ return (ly_scm2string (arg));
+ else if (scm_is_symbol (arg))
+ return (ly_symbol2string (arg));
+ else
+ {
+ ly_progress (scm_from_locale_string ("Unsupported SCM value for format: ~a"),
+ scm_list_1 (arg));
+ }
+
+
+ return "";
+}
+
+LY_DEFINE (ly_format, "ly:format",
+ 1, 0, 1, (SCM str, SCM rest),
+ "LilyPond specific format, supporting ~a ~[0-9]f.")
+{
+ SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
+
+ string format = ly_scm2string (str);
+ vector<string> results;
+
+ vsize i = 0;
+ while (i < format.size())
+ {
+ vsize tilde = format.find ('~', i);
+
+ results.push_back (format.substr (i, (tilde-i)));
+
+ if (tilde == NPOS)
+ break ;
+
+ tilde ++;
+
+ char spec = format.at (tilde ++);
+ if (spec == '~')
+ results.push_back ("~");
+ else
+ {
+ if (!scm_is_pair (rest))
+ {
+ programming_error (string (__FUNCTION__)
+ + ": not enough arguments for format.");
+ return ly_string2scm ("");
+ }
+
+ SCM arg = scm_car (rest);
+ rest = scm_cdr (rest);
+
+ int precision = 8;
+
+ if (spec == '$')
+ precision = '2';
+ else if (isdigit (spec))
+ {
+ precision = spec - '0';
+ spec = format.at (tilde ++);
+ }
+
+ if (spec == 'a' || spec == 'f')
+ results.push_back (format_single_argument (arg, precision));
+ else if (spec == 'l')
+ {
+ SCM s = arg;
+ for (; scm_is_pair (s); s = scm_cdr (s))
+ {
+ results.push_back (format_single_argument (scm_car (s), precision));
+ if (scm_cdr (s) != SCM_EOL)
+ results.push_back (" ");
+ }
+
+ if (s != SCM_EOL)
+ results.push_back (format_single_argument (s, precision));
+
+ }
+ }
+
+ i = tilde;
+ }
+
+ if (scm_is_pair (rest))
+ programming_error (string (__FUNCTION__)
+ + ": too many arguments");
+
+ vsize len = 0;
+ for (vsize i = 0; i < results.size(); i++)
+ len += results[i].size();
+
+ char *result = (char*) scm_malloc (len + 1);
+ char *ptr = result;
+ for (vsize i = 0; i < results.size(); i++)
+ {
+ strncpy (ptr, results[i].c_str (), results[i].size());
+ ptr += results[i].size();
+ }
+ *ptr = '\0';
+
+ return scm_take_locale_stringn (result, len);
+}
#include "translator.icc"
-/**
- Create line-spanner grobs for glissandi lines that connect note
- heads.
-*/
class Glissando_engraver : public Engraver
{
public:
ADD_ACKNOWLEDGER (Glissando_engraver, rhythmic_head);
ADD_TRANSLATOR (Glissando_engraver,
- /* doc */ "Engrave a glissandi",
- /* create */ "Glissando",
- /* read */ "followVoice",
+ /* doc */ "",
+ /* create */
+ "Glissando",
+
+ /* read */
+ "",
+
/* write */ "");
extern void check_interfaces_for_property (Grob const *me, SCM sym);
-#ifndef NDEBUG
+#if 0
+
+/*
+ We can't change signatures depending on NDEBUG, since NDEBUG comes
+ over the command line and may be different per .cc file. This
+ should be done through the macro expansion of get_property().
+ */
void
Grob::internal_set_property (SCM sym, SCM v, char const *file, int line, char const *fun)
{
sym, v, SCM_UNDEFINED));
}
#else
+
+
void
Grob::internal_set_property (SCM sym, SCM v)
{
Real x = scm_to_double (scm_cadr (rot));
Real y = scm_to_double (scm_caddr (rot));
- retval.rotate (angle, Offset (x, y));
+ retval.rotate_degrees (angle, Offset (x, y));
}
/* color support... see interpret_stencil_expression () for more... */
}
Interval_t<int>
-Grob::spanned_rank_iv ()
+Grob::spanned_rank_iv () const
{
return Interval_t<int> (-1, 0);
}
#include "international.hh"
#include "main.hh"
#include "source-file.hh"
-#include "source.hh"
+#include "sources.hh"
#include "warn.hh"
#ifndef YY_BUF_SIZE
#include "moment.hh"
#include "lily-proto.hh"
+struct Beaming_options
+{
+ SCM grouping_;
+ bool subdivide_beams_;
+ Moment beat_length_;
+ Moment measure_length_;
+
+ Beaming_options ();
+ void from_context (Context*);
+};
+
struct Beam_rhythmic_element
{
Moment start_moment_;
public:
Beaming_pattern ();
- void beamify (Context*);
+ void beamify (Beaming_options const&);
void de_grace ();
void add_stem (Moment d, int beams);
int beamlet_count (int idx, Direction d) const;
Context *where_defined (SCM name_sym, SCM *value) const;
void unset_property (SCM var_sym);
-#ifndef NDEBUG
- void internal_set_property (SCM var_sym, SCM value, char const *file, int line, char const *fun);
-#else
void internal_set_property (SCM var_sym, SCM value);
-#endif
Context *create_context (Context_def *, string, SCM);
DECLARE_LISTENER (create_context_from_event);
FT_Face open_ft_face (string str);
+string freetype_error_string (int code);
+
#endif /* FREETYPE_HH */
SCM internal_get_object (SCM symbol) const;
void internal_set_object (SCM sym, SCM val);
void internal_del_property (SCM symbol);
-
-#ifndef NDEBUG
- void internal_set_property (SCM sym, SCM val, char const *file, int line, char const *fun);
-#else
void internal_set_property (SCM sym, SCM val);
-#endif
/* messages */
void warning (string) const;
Grob *get_parent (Axis a) const;
void fixup_refpoint ();
- virtual Interval_t<int> spanned_rank_iv ();
+ virtual Interval_t<int> spanned_rank_iv () const;
};
/* smob utilities */
virtual System *get_system () const;
virtual Paper_column *get_column () const;
virtual void handle_prebroken_dependencies ();
- virtual Interval_t<int> spanned_rank_iv ();
+ virtual Interval_t<int> spanned_rank_iv () const;
DECLARE_GROB_INTERFACE();
protected:
virtual void discretionary_processing ();
virtual void derived_mark () const;
};
+Interval_t<Moment> spanned_time_interval (Item *l, Item *r);
+
#endif
#define del_property(x) internal_del_property (ly_symbol2scm (x))
#ifndef NDEBUG
-#define set_property(x, y) internal_set_property (ly_symbol2scm (x), y, __FILE__, __LINE__, __FUNCTION__)
+/*
+ TODO: include modification callback support here, perhaps
+ through intermediate Grob::instrumented_set_property( .. __LINE__ ).
+ */
+#define set_property(x, y) internal_set_property (ly_symbol2scm (x), y)
#else
#define set_property(x, y) internal_set_property (ly_symbol2scm (x), y)
#endif
A ly_B2A (B b); */
SCM ly_last (SCM list);
-SCM ly_write2scm (SCM s);
+string ly_scm_write_string (SCM s);
SCM ly_deep_copy (SCM);
SCM ly_truncate_list (int k, SCM lst);
Interval robust_scm2interval (SCM, Drul_array<Real>);
Offset robust_scm2offset (SCM, Offset);
string robust_scm2string (SCM, string);
+Rational robust_scm2rational (SCM, Rational);
SCM ly_quote_scm (SCM s);
SCM ly_hash_table_keys (SCM tab);
SCM ly_assoc_prepend_x (SCM alist, SCM key, SCM val);
+inline bool ly_is_fraction (SCM x) { return SCM_FRACTIONP(x) || scm_is_integer (x); }
+
inline bool ly_is_list (SCM x) { return SCM_NFALSEP (scm_list_p (x)); }
inline bool ly_is_procedure (SCM x) { return SCM_NFALSEP (scm_procedure_p (x)); }
inline bool ly_is_port (SCM x) { return SCM_NFALSEP (scm_port_p (x)); }
class Midi_chunk;
class Midi_duration;
class Midi_dynamic;
+class Midi_event;
class Midi_header;
class Midi_instrument;
class Midi_item;
{
static Stencil line (Grob *me, Offset from, Offset to);
DECLARE_GROB_INTERFACE();
+ static Stencil make_zigzag_line (Grob *me,
+ Offset from,
+ Offset to);
+ static Stencil make_trill_line (Grob *me,
+ Offset from,
+ Offset to);
static Stencil make_dashed_line (Real th, Offset from, Offset to, Real, Real);
static Stencil make_line (Real th, Offset from, Offset to);
static Stencil make_arrow (Offset beg, Offset end, Real thick,
--- /dev/null
+/*
+ midi-chunk.hh -- declare Midi_chunk
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2007 Han-Wen Nienhuys <hanwen@lilypond.org>
+
+*/
+
+#ifndef MIDI_CHUNK_HH
+#define MIDI_CHUNK_HH
+
+#include "lily-proto.hh"
+#include "virtual-methods.hh"
+#include "std-vector.hh"
+
+
+/**
+ timed MIDI event
+*/
+class Midi_event
+{
+public:
+ Midi_event (int delta, Midi_item *midi);
+
+ int delta_ticks_;
+ Midi_item *midi_;
+ string to_string () const;
+};
+
+
+
+
+/**
+ variable sized MIDI data
+*/
+class Midi_chunk
+{
+public:
+ void set (string header_string, string data_string, string footer_string);
+ virtual string to_string () const;
+ virtual string data_string () const;
+ DECLARE_CLASSNAME(Midi_chunk);
+ virtual ~Midi_chunk ();
+private:
+ string data_string_;
+ string footer_string_;
+ string header_string_;
+};
+
+class Midi_header : public Midi_chunk
+{
+public:
+ DECLARE_CLASSNAME(Midi_header);
+
+ Midi_header (int format_i, int tracks_i, int clocks_per_4_i);
+};
+
+class Midi_track : public Midi_chunk
+{
+public:
+ int number_;
+ DECLARE_CLASSNAME(Midi_track);
+
+ vector<Midi_event*> events_;
+
+ Midi_track ();
+ ~Midi_track ();
+
+ void add (int, Midi_item *midi);
+ virtual string data_string () const;
+};
+
+#endif /* MIDI_CHUNK_HH */
+
#include "audio-item.hh"
#include "std-vector.hh"
+string int2midi_varint_string (int i);
+
/**
Any piece of midi information.
virtual ~Midi_item ();
virtual char const *name () const;
- /// factory
static Midi_item *get_midi (Audio_item *a);
- static string i2varint_string (int i);
virtual string to_string () const = 0;
};
Midi_channel_item ();
};
-/**
- timed MIDI event
-*/
-class Midi_event
-{
-public:
- Midi_event (int delta, Midi_item *midi);
-
- int delta_ticks_;
- Midi_item *midi_;
- string to_string () const;
-};
-
-/**
- variable sized MIDI data
-*/
-class Midi_chunk : public Midi_item
-{
-public:
- void set (string header_string, string data_string, string footer_string);
- virtual string to_string () const;
- virtual string data_string () const;
- DECLARE_CLASSNAME(Midi_chunk);
-
-private:
- string data_string_;
- string footer_string_;
- string header_string_;
-};
-
class Midi_duration : public Midi_item
{
public:
Real seconds_;
};
-class Midi_header : public Midi_chunk
-{
-public:
- DECLARE_CLASSNAME(Midi_header);
-
- Midi_header (int format_i, int tracks_i, int clocks_per_4_i);
-};
/**
Change instrument event
Audio_tempo *audio_;
};
-class Midi_track : public Midi_chunk
-{
-public:
- int number_;
- DECLARE_CLASSNAME(Midi_track);
-
- vector<Midi_event*> events_;
-
- Midi_track ();
- ~Midi_track ();
- void add (int, Midi_item *midi);
- virtual string data_string () const;
-};
#endif // MIDI_ITEM_HH
using namespace std;
#include "std-string.hh"
+#include "lily-proto.hh"
-class Midi_item;
-
-/// Midi outputfile
struct Midi_stream
{
Midi_stream (string file_name_string);
~Midi_stream ();
void write (string);
- void write (Midi_item const &);
- void write (int);
-
+ void write (Midi_chunk const &);
void open ();
FILE *out_file_;
void process ();
void operator ++ (int);
bool ok () const;
-
+ void finalize ();
private:
void do_start_note (Midi_note *note);
void do_stop_notes (int);
void output_event (int, Midi_item *l);
-
+ Midi_item *get_midi (Audio_item*);
int channel_;
Midi_track *track_;
Audio_staff *staff_;
PQueue<Midi_note_event> stop_note_queue;
int last_tick_;
+ vector<Midi_item*> midi_events_;
};
#endif // MIDI_WALKER_HH
SCM type () const { return type_; }
SCM get_property_alist (bool mutble) const;
SCM internal_get_property (SCM sym) const;
-
-#ifndef NDEBUG
- void internal_set_property (SCM sym, SCM val, const char *file, int line, char const *fun);
-#else
void internal_set_property (SCM sym, SCM val);
-#endif
};
DECLARE_UNSMOB(Prob,prob);
SCM ly_prob_set_property_x (SCM system, SCM sym, SCM value);
-/*
- source.hh -- part of LilyPond
-
- (c) 1997--2007 Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-
-#ifndef SOURCE_HH
-#define SOURCE_HH
-
-#include "flower-proto.hh"
-#include "std-vector.hh"
-
-/* A set of sourcefiles. */
-class Sources
-{
- Sources (Sources const &);
- vector<Source_file*> sourcefiles_;
-
-public:
- Sources ();
- ~Sources ();
-
- Source_file *get_file (string *file_name);
- Source_file *get_sourcefile (char const *);
- void add (Source_file *sourcefile);
- void set_path (File_path *);
-
- const File_path *path_;
-};
-
-#endif /* SOURCE_HH */
+#error
--- /dev/null
+/*
+ sources.hh -- part of LilyPond
+
+ (c) 1997--2007 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#ifndef SOURCES_HH
+#define SOURCES_HH
+
+#include "flower-proto.hh"
+#include "std-vector.hh"
+
+class Sources
+{
+ Sources (Sources const &);
+ vector<Source_file*> sourcefiles_;
+
+public:
+ Sources ();
+ ~Sources ();
+
+ Source_file *get_file (string *file_name);
+ Source_file *get_sourcefile (char const *);
+ void add (Source_file *sourcefile);
+ void set_path (File_path *);
+
+ const File_path *path_;
+};
+
+#endif /* SOURCE_HH */
void substitute_one_mutable_property (SCM sym, SCM val);
bool fast_substitute_grob_array (SCM sym, Grob_array *);
- virtual Interval_t<int> spanned_rank_iv ();
+ Interval_t<Moment> spanned_time () const;
+ virtual Interval_t<int> spanned_rank_iv () const;
void set_bound (Direction d, Grob *);
Item *get_bound (Direction d) const;
DECLARE_GROB_INTERFACE();
virtual System *get_system () const;
+
protected:
void set_my_columns ();
virtual Grob *clone () const;
void translate (Offset);
Stencil translated (Offset) const;
void rotate (Real, Offset);
+ void rotate_degrees (Real, Offset);
void align_to (Axis a, Real x);
void translate_axis (Real, Axis);
typedef map < Tuple<int, 2>, Skyline> Chord_outline_map;
typedef map < Tuple<int, 2>, Box> Column_extent_map;
typedef map <int, Slice> Position_extent_map;
+
class Tie_formatting_problem
{
Chord_outline_map chord_outlines_;
#include "international.hh"
#include "source-file.hh"
-#include "source.hh"
+#include "sources.hh"
#include "warn.hh"
Input::Input (Input const &i)
#include "system.hh"
#include "pointer-group-interface.hh"
+#include "moment.hh"
+
+
Grob *
Item::clone () const
{
}
Interval_t<int>
-Item::spanned_rank_iv ()
+Item::spanned_rank_iv () const
{
int c = get_column ()->get_rank ();
return Interval_t<int> (c, c);
}
+Interval_t<Moment>
+spanned_time_interval (Item *l, Item *r)
+{
+ Drul_array<Item*> bounds (l, r);
+ Interval_t<Moment> iv;
+
+ Direction d = LEFT;
+ do
+ {
+ if (bounds[d] && bounds[d]->get_column ())
+ iv[d] = robust_scm2moment (bounds[d]->get_column ()->get_property ("when"),
+ iv[d]);
+ }
+ while (flip (&d) != LEFT);
+
+ do
+ {
+ if (!bounds[d] || !bounds[d]->get_column ())
+ iv[d] = iv[-d];
+ }
+ while (flip (&d) != LEFT);
+
+
+ return iv;
+}
+
+
void
Item::derived_mark () const
{
for (SCM s = last; scm_is_pair (s); s = scm_cdr (s))
{
SCM new_alter_pair = scm_assoc (scm_caar (s), key);
- Rational old_alter = ly_scm2rational (scm_cdar (s));
+ Rational old_alter = robust_scm2rational (scm_cdar (s), 0);
if (new_alter_pair == SCM_BOOL_F
|| extranatural
&& (ly_scm2rational (scm_cdr (new_alter_pair)) - old_alter)*old_alter < Rational (0))
Real den = (count * sqx - sqr (sx));
if (!count || !den)
{
- programming_error ("minimise_least_squares (): Nothing to minimise");
+ programming_error ("minimise_least_squares (): Nothing to minimise\n"
+ "This means that vertical spacing is triggered\n"
+ "before line breaking\n");
*coef = 0.0;
*offset = count ? sy / count : 0.0;
}
/*
symbols/strings.
*/
-SCM
-ly_write2scm (SCM s)
+string
+ly_scm_write_string (SCM s)
{
SCM port = scm_mkstrport (SCM_INUM0,
scm_make_string (SCM_INUM0, SCM_UNDEFINED),
// scm_apply (write, port, SCM_EOL);
scm_call_2 (write, s, port);
- return scm_strport_to_string (port);
+ return ly_scm2string (scm_strport_to_string (port));
}
SCM
string
print_scm_val (SCM val)
{
- string realval = ly_scm2string (ly_write2scm (val));
+ string realval = ly_scm_write_string (val);
if (realval.length () > 200)
realval = realval.substr (0, 100)
+ "\n :\n :\n"
scm_to_int (scm_denominator (r)));
}
+Rational
+robust_scm2rational (SCM n, Rational rat)
+{
+ if (ly_is_fraction (n))
+ return ly_scm2rational (n);
+ else
+ return rat;
+}
SCM
alist_to_hashq (SCM alist)
return ly_string_array_to_scm (string_split (s, ' '));
}
-
-bool
-ly_is_fraction (SCM x)
-{
- return SCM_FRACTIONP(x);
-}
-
+/* GDB debugging. */
struct ly_t_double_cell
{
SCM a;
#include "ly-module.hh"
#include "main.hh"
#include "program-option.hh"
-#include "source.hh"
+#include "sources.hh"
#include "warn.hh"
/* Do not append `!' suffix, since 1st argument is not modified. */
#include "paper-book.hh"
#include "parser.hh"
#include "score.hh"
-#include "source.hh"
+#include "sources.hh"
#include "text-metrics.hh"
#include "warn.hh"
#include "lookup.hh"
#include "output-def.hh"
#include "grob.hh"
+#include "font-interface.hh"
Stencil
Line_interface::make_arrow (Offset begin, Offset end,
return Lookup::round_filled_polygon (points, thick);
}
+Stencil
+Line_interface::make_trill_line (Grob *me,
+ Offset from,
+ Offset to)
+{
+ Offset dz = (to-from);
+ SCM alist_chain = Font_interface::text_font_alist_chain (me);
+ SCM style_alist = scm_list_n (scm_cons (ly_symbol2scm ("font-encoding"),
+ ly_symbol2scm ("fetaMusic")),
+ SCM_UNDEFINED);
+
+ Font_metric *fm = select_font (me->layout (),
+ scm_cons (style_alist,
+ alist_chain));
+
+ Stencil elt = fm->find_by_name ("scripts.trill_element");
+
+ Real elt_len = elt.extent (X_AXIS).length ();
+ if (elt_len <= 0.0)
+ {
+ programming_error ("can't find scripts.trill_element");
+ return Stencil ();
+ }
+
+ Stencil line;
+ Real len = 0.0;
+ do
+ {
+ line.add_at_edge (X_AXIS, RIGHT, elt, 0);
+ len = line.extent (X_AXIS).length ();
+ }
+ while (len + elt_len < dz.length ());
+
+ line.rotate (dz.arg (), Offset (0,0));
+ line.translate (from);
+
+ return line;
+}
+
+
+Stencil
+Line_interface::make_zigzag_line (Grob *me,
+ Offset from,
+ Offset to)
+{
+ Offset dz = to -from;
+
+ Real thick = Staff_symbol_referencer::line_thickness (me);
+ thick *= robust_scm2double (me->get_property ("thickness"), 1.0); // todo: staff sym referencer?
+
+ Real staff_space = Staff_symbol_referencer::staff_space (me);
+
+ Real w = robust_scm2double (me->get_property ("zigzag-width"), 1) * staff_space;
+ int count = (int) ceil (dz.length () / w);
+ w = dz.length () / count;
+
+ Real l = robust_scm2double (me->get_property ("zigzag-length"), 1) * w;
+ Real h = l > w / 2 ? sqrt (l * l - w * w / 4) : 0;
+
+ Offset rotation_factor = complex_exp (Offset (0, dz.arg ()));
+
+ Offset points[3];
+ points[0] = Offset (0, -h / 2);
+ points[1] = Offset (w / 2, h / 2);
+ points[2] = Offset (w, -h / 2);
+ for (int i = 0; i < 3; i++)
+ points[i] = complex_multiply (points[i], rotation_factor);
+
+ Stencil squiggle (Line_interface::make_line (thick, points[0], points[1]));
+ squiggle.add_stencil (Line_interface::make_line (thick, points[1], points[2]));
+
+ Stencil total;
+ for (int i = 0; i < count; i++)
+ {
+ Stencil moved_squiggle (squiggle);
+ moved_squiggle.translate (from + Offset (i * w, 0) * rotation_factor);
+ total.add_stencil (moved_squiggle);
+ }
+
+ Box b;
+ b.add_point (Offset (0, 0));
+ b.add_point (dz);
+ b[X_AXIS].widen (thick / 2);
+ b[Y_AXIS].widen (thick / 2);
+
+ return Stencil (b, total.expr ());
+}
+
+
Stencil
Line_interface::make_dashed_line (Real thick, Offset from, Offset to,
Real dash_period, Real dash_fraction)
* robust_scm2double (me->get_property ("thickness"), 1);
SCM type = me->get_property ("style");
-
+ if (type == ly_symbol2scm ("zigzag"))
+ {
+ return make_zigzag_line (me, from, to);
+ }
+ else if (type == ly_symbol2scm ("trill"))
+ return make_trill_line (me, from, to);
+
Stencil stil;
SCM dash_fraction = me->get_property ("dash-fraction");
"dash-fraction "
"thickness "
"style "
+ "zigzag-length "
+ "zigzag-width "
"arrow-length "
"arrow-width ")
#include "lookup.hh"
#include "line-interface.hh"
-Stencil
-zigzag_stencil (Grob *me,
- Offset from,
- Offset to)
-{
- Offset dz = to -from;
-
- Real thick = Staff_symbol_referencer::line_thickness (me);
- thick *= robust_scm2double (me->get_property ("thickness"), 1.0); // todo: staff sym referencer?
-
- Real staff_space = Staff_symbol_referencer::staff_space (me);
-
- Real w = robust_scm2double (me->get_property ("zigzag-width"), 1) * staff_space;
- int count = (int) ceil (dz.length () / w);
- w = dz.length () / count;
-
- Real l = robust_scm2double (me->get_property ("zigzag-length"), 1) * w;
- Real h = l > w / 2 ? sqrt (l * l - w * w / 4) : 0;
-
- Offset rotation_factor = complex_exp (Offset (0, dz.arg ()));
-
- Offset points[3];
- points[0] = Offset (0, -h / 2);
- points[1] = Offset (w / 2, h / 2);
- points[2] = Offset (w, -h / 2);
- for (int i = 0; i < 3; i++)
- points[i] = complex_multiply (points[i], rotation_factor);
-
- Stencil squiggle (Line_interface::make_line (thick, points[0], points[1]));
- squiggle.add_stencil (Line_interface::make_line (thick, points[1], points[2]));
-
- Stencil total;
- for (int i = 0; i < count; i++)
- {
- Stencil moved_squiggle (squiggle);
- moved_squiggle.translate (from + Offset (i * w, 0) * rotation_factor);
- total.add_stencil (moved_squiggle);
- }
-
- Box b;
- b.add_point (Offset (0, 0));
- b.add_point (dz);
- b[X_AXIS].widen (thick / 2);
- b[Y_AXIS].widen (thick / 2);
-
- return Stencil (b, total.expr ());
-}
-
MAKE_SCHEME_CALLBACK (Line_spanner, after_line_breaking, 1);
SCM
Line_spanner::after_line_breaking (SCM g)
Offset from,
Offset to)
{
- Offset dz = to -from;
- SCM type = me->get_property ("style");
-
- Stencil line;
-
- if (scm_is_symbol (type)
- && (type == ly_symbol2scm ("line")
- || type == ly_symbol2scm ("dashed-line")
- || type == ly_symbol2scm ("dotted-line")
- || type == ly_symbol2scm ("zigzag")
- || (type == ly_symbol2scm ("trill") && dz[Y_AXIS] != 0)))
- {
- line = (type == ly_symbol2scm ("zigzag"))
- ? zigzag_stencil (me, from, to)
- : Line_interface::line (me, from, to);
- }
- else if (scm_is_symbol (type)
- && type == ly_symbol2scm ("trill"))
- {
- SCM alist_chain = Font_interface::text_font_alist_chain (me);
- SCM style_alist = scm_list_n (scm_cons (ly_symbol2scm ("font-encoding"),
- ly_symbol2scm ("fetaMusic")),
- SCM_UNDEFINED);
-
- Font_metric *fm = select_font (me->layout (),
- scm_cons (style_alist,
- alist_chain));
- Stencil m = fm->find_by_name ("scripts.trill_element");
- Stencil mol;
-
- do
- mol.add_at_edge (X_AXIS, RIGHT, m, 0);
- while (m.extent (X_AXIS).length ()
- && mol.extent (X_AXIS).length ()
- + m.extent (X_AXIS).length () < dz[X_AXIS])
- ;
-
- /*
- FIXME: should center element on x/y
- */
- mol.translate_axis (m.extent (X_AXIS).length () / 2, X_AXIS);
- mol.translate_axis (- (mol.extent (Y_AXIS)[DOWN]
- + mol.extent (Y_AXIS).length ()) / 2, Y_AXIS);
-
- mol.translate (from);
- line = mol;
- }
+ Stencil line = Line_interface::line (me, from, to);
if (to_boolean (me->get_property ("arrow")))
line.add_stencil (Line_interface::arrows (me, from, to, false, true));
"arrow "
"gap "
"thickness "
- "zigzag-length "
- "zigzag-width "
);
--- /dev/null
+/*
+ midi-chunk.cc -- implement Midi_chunk
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2007 Han-Wen Nienhuys <hanwen@lilypond.org>
+
+*/
+
+#include "midi-chunk.hh"
+
+#include "midi-item.hh"
+#include "std-string.hh"
+#include "string-convert.hh"
+
+Midi_track::Midi_track ()
+{
+ // 4D 54 72 6B MTrk
+ // 00 00 00 3B chunk length (59)
+ // 00 FF 58 04 04 02 18 08 time signature
+ // 00 FF 51 03 07 A1 20 tempo
+
+ // FF 59 02 sf mi Key Signature
+ // sf = -7: 7 flats
+ // sf = -1: 1 flat
+ // sf = 0: key of C
+ // sf = 1: 1 sharp
+ // sf = 7: 7 sharps
+ // mi = 0: major key
+ // mi = 1: minor key
+
+ number_ = 0;
+
+ char const *data_str0 = ""
+ // "00" "ff58" "0404" "0218" "08"
+ // "00" "ff51" "0307" "a120"
+ // why a key at all, in midi?
+ // key: C
+ // "00" "ff59" "02" "00" "00"
+ // key: F (scsii-menuetto)
+ // "00" "ff59" "02" "ff" "00"
+ ;
+
+ string data_string;
+ // only for format 0 (currently using format 1)?
+ data_string += String_convert::hex2bin (data_str0);
+
+ char const *footer_str0 = "00" "ff2f" "00";
+ string footer_string = String_convert::hex2bin (footer_str0);
+
+ set ("MTrk", data_string, footer_string);
+}
+
+void
+Midi_track::add (int delta_ticks, Midi_item *midi)
+{
+ assert (delta_ticks >= 0);
+
+ Midi_event *e = new Midi_event (delta_ticks, midi);
+ events_.push_back (e);
+}
+
+string
+Midi_track::data_string () const
+{
+ string str = Midi_chunk::data_string ();
+
+ for (vector<Midi_event*>::const_iterator i (events_.begin());
+ i != events_.end(); i ++)
+ {
+ str += (*i)->to_string ();
+ }
+ return str;
+}
+
+
+Midi_track::~Midi_track ()
+{
+ junk_pointers (events_);
+}
+
+/****************************************************************
+ event
+*/
+Midi_event::Midi_event (int delta_ticks, Midi_item *midi)
+{
+ delta_ticks_ = delta_ticks;
+ midi_ = midi;
+}
+
+string
+Midi_event::to_string () const
+{
+ string delta_string = int2midi_varint_string (delta_ticks_);
+ string midi_string = midi_->to_string ();
+ assert (midi_string.length ());
+ return delta_string + midi_string;
+}
+/****************************************************************
+ header
+*/
+
+Midi_header::Midi_header (int format, int tracks, int clocks_per_4)
+{
+ string str;
+
+ string format_string = String_convert::int2hex (format, 4, '0');
+ str += String_convert::hex2bin (format_string);
+
+ string tracks_string = String_convert::int2hex (tracks, 4, '0');
+ str += String_convert::hex2bin (tracks_string);
+
+ string tempo_string = String_convert::int2hex (clocks_per_4, 4, '0');
+ str += String_convert::hex2bin (tempo_string);
+
+ set ("MThd", str, "");
+}
+
+
+/****************************************************************
+ chunk
+ */
+Midi_chunk::~Midi_chunk ()
+{
+
+}
+
+void
+Midi_chunk::set (string header_string, string data_string, string footer_string)
+{
+ data_string_ = data_string;
+ footer_string_ = footer_string;
+ header_string_ = header_string;
+}
+
+string
+Midi_chunk::data_string () const
+{
+ return data_string_;
+}
+
+string
+Midi_chunk::to_string () const
+{
+ string str = header_string_;
+ string dat = data_string ();
+ string length_string = String_convert::int2hex (dat.length ()
+ + footer_string_.length (), 8, '0');
+ length_string = String_convert::hex2bin (length_string);
+
+ str += length_string;
+ str += dat;
+ str += footer_string_;
+
+ return str;
+}
+
return 0;
}
-void
-Midi_chunk::set (string header_string, string data_string, string footer_string)
-{
- data_string_ = data_string;
- footer_string_ = footer_string;
- header_string_ = header_string;
-}
-
-string
-Midi_chunk::data_string () const
-{
- return data_string_;
-}
-string
-Midi_chunk::to_string () const
-{
- string str = header_string_;
- string dat = data_string ();
- string length_string = String_convert::int2hex (dat.length ()
- + footer_string_.length (), 8, '0');
- length_string = String_convert::hex2bin (length_string);
-
- str += length_string;
- str += dat;
- str += footer_string_;
-
- return str;
-}
Midi_duration::Midi_duration (Real seconds_f)
{
return string ("<duration: ") + ::to_string (seconds_) + ">";
}
-Midi_event::Midi_event (int delta_ticks, Midi_item *midi)
-{
- delta_ticks_ = delta_ticks;
- midi_ = midi;
-}
-
-string
-Midi_event::to_string () const
-{
- string delta_string = Midi_item::i2varint_string (delta_ticks_);
- string midi_string = midi_->to_string ();
- assert (midi_string.length ());
- return delta_string + midi_string;
-}
-
-Midi_header::Midi_header (int format, int tracks, int clocks_per_4)
-{
- string str;
-
- string format_string = String_convert::int2hex (format, 4, '0');
- str += String_convert::hex2bin (format_string);
-
- string tracks_string = String_convert::int2hex (tracks, 4, '0');
- str += String_convert::hex2bin (tracks_string);
-
- string tempo_string = String_convert::int2hex (clocks_per_4, 4, '0');
- str += String_convert::hex2bin (tempo_string);
-
- set ("MThd", str, "");
-}
-
Midi_instrument::Midi_instrument (Audio_instrument *a)
{
audio_ = a;
}
string
-Midi_item::i2varint_string (int i)
+int2midi_varint_string (int i)
{
int buffer = i & 0x7f;
while ((i >>= 7) > 0)
{
string str = "ff" + String_convert::int2hex (audio_->type_, 2, '0');
str = String_convert::hex2bin (str);
- str += i2varint_string (audio_->text_string_.length ());
+ str += int2midi_varint_string (audio_->text_string_.length ());
str += audio_->text_string_;
return str;
}
-Midi_track::Midi_track ()
- : Midi_chunk ()
-{
- // 4D 54 72 6B MTrk
- // 00 00 00 3B chunk length (59)
- // 00 FF 58 04 04 02 18 08 time signature
- // 00 FF 51 03 07 A1 20 tempo
-
- // FF 59 02 sf mi Key Signature
- // sf = -7: 7 flats
- // sf = -1: 1 flat
- // sf = 0: key of C
- // sf = 1: 1 sharp
- // sf = 7: 7 sharps
- // mi = 0: major key
- // mi = 1: minor key
-
- number_ = 0;
-
- char const *data_str0 = ""
- // "00" "ff58" "0404" "0218" "08"
- // "00" "ff51" "0307" "a120"
- // why a key at all, in midi?
- // key: C
- // "00" "ff59" "02" "00" "00"
- // key: F (scsii-menuetto)
- // "00" "ff59" "02" "ff" "00"
- ;
-
- string data_string;
- // only for format 0 (currently using format 1)?
- data_string += String_convert::hex2bin (data_str0);
-
- char const *footer_str0 = "00" "ff2f" "00";
- string footer_string = String_convert::hex2bin (footer_str0);
-
- set ("MTrk", data_string, footer_string);
-}
-
-void
-Midi_track::add (int delta_ticks, Midi_item *midi)
-{
- assert (delta_ticks >= 0);
-
- Midi_event *e = new Midi_event (delta_ticks, midi);
- events_.push_back (e);
-}
-
-string
-Midi_track::data_string () const
-{
- string str = Midi_chunk::data_string ();
-
- for (vector<Midi_event*>::const_iterator i (events_.begin());
- i != events_.end(); i ++)
- {
- str += (*i)->to_string ();
- }
- return str;
-}
-
-
char const *
Midi_item::name () const
{
return this->class_name ();
}
-
-Midi_track::~Midi_track ()
-{
- junk_pointers (events_);
-}
#include "international.hh"
#include "main.hh"
-#include "midi-item.hh"
+#include "midi-chunk.hh"
#include "misc.hh"
#include "program-option.hh"
#include "stream.hh"
}
void
-Midi_stream::write (Midi_item const &midi)
+Midi_stream::write (Midi_chunk const &midi)
{
string str = midi.to_string ();
return write (str);
}
-void
-Midi_stream::write (int i)
-{
- write (Midi_item::i2varint_string (i));
-}
-
#include "audio-column.hh"
#include "audio-staff.hh"
#include "midi-item.hh"
+#include "midi-chunk.hh"
#include "midi-stream.hh"
#include "warn.hh"
Midi_walker::~Midi_walker ()
{
- do_stop_notes (INT_MAX);
+ junk_pointers (midi_events_);
}
+void
+Midi_walker::finalize ()
+{
+ do_stop_notes (INT_MAX);
+}
/**
Find out if start_note event is needed, and do it if needed.
{
/* skip this stopnote,
don't play the start note */
- delete note;
note = 0;
break;
}
{
Midi_note_event e;
e.val = new Midi_note_off (note);
+
+ midi_events_.push_back (e.val);
e.key = int (stop_ticks);
stop_note_queue.insert (e);
Midi_note_event e = stop_note_queue.get ();
if (e.ignore_)
{
- delete e.val;
continue;
}
Audio_item *audio = items_[index_];
do_stop_notes (audio->audio_column_->ticks ());
- if (Midi_item *midi = Midi_item::get_midi (audio))
+ if (Midi_item *midi = get_midi (audio))
{
if (Midi_channel_item *mci = dynamic_cast<Midi_channel_item*> (midi))
mci->channel_ = channel_;
}
}
+Midi_item*
+Midi_walker::get_midi (Audio_item *i)
+{
+ Midi_item *mi = Midi_item::get_midi (i);
+ midi_events_.push_back (mi);
+ return mi;
+}
+
bool
Midi_walker::ok () const
{
--- /dev/null
+/*
+ line-spanner.cc -- implement New_line_spanner
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2000--2007 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "spanner.hh"
+#include "output-def.hh"
+#include "paper-column.hh"
+#include "staff-symbol-referencer.hh"
+#include "font-interface.hh"
+#include "warn.hh"
+#include "align-interface.hh"
+#include "lookup.hh"
+#include "line-interface.hh"
+#include "moment.hh"
+
+#include "lily-proto.hh"
+#include "grob-interface.hh"
+#include "text-interface.hh"
+
+class New_line_spanner
+{
+public:
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
+
+ DECLARE_SCHEME_CALLBACK (calc_left_bound_info, (SCM));
+ DECLARE_SCHEME_CALLBACK (calc_left_bound_info_and_text, (SCM));
+ DECLARE_SCHEME_CALLBACK (calc_right_bound_info, (SCM));
+ DECLARE_SCHEME_CALLBACK (calc_bound_info, (SCM, Direction));
+ DECLARE_GROB_INTERFACE();
+
+ static Grob *common_y (Grob*);
+};
+
+Grob*
+New_line_spanner::common_y (Grob*me_grob)
+{
+ Spanner *me = dynamic_cast<Spanner*> (me_grob);
+
+ Grob *commony = me;
+ Direction d = LEFT;
+ do
+ if (me->get_bound (d)->break_status_dir () == CENTER)
+ commony = me->get_bound (d)->common_refpoint (commony, Y_AXIS);
+ while (flip (&d) != LEFT);
+
+ return commony;
+}
+
+static Grob *
+line_spanner_common_parent (Grob *me)
+{
+ Grob *common = find_fixed_alignment_parent (me);
+ if (!common)
+ {
+ common = Staff_symbol_referencer::get_staff_symbol (me);
+ if (common)
+ common = common->get_parent (Y_AXIS);
+ else
+ common = me->get_parent (Y_AXIS);
+ }
+
+ return common;
+}
+
+SCM
+New_line_spanner::calc_bound_info (SCM smob, Direction dir)
+{
+ Spanner *me = unsmob_spanner (smob);
+
+ Grob *commonx = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS);
+ commonx = me->common_refpoint (commonx, X_AXIS);
+
+ SCM bound_details = me->get_property ("bound-details");
+
+ SCM details = SCM_BOOL_F;
+ if (details == SCM_BOOL_F)
+ details = ly_assoc_get ((dir == LEFT)
+ ? ly_symbol2scm ("left")
+ : ly_symbol2scm ("right"), bound_details, SCM_BOOL_F);
+
+ if (me->get_bound (dir)->break_status_dir ())
+ {
+ SCM extra = ly_assoc_get ((dir == LEFT)
+ ? ly_symbol2scm ("left-broken")
+ : ly_symbol2scm ("right-broken"), bound_details, SCM_EOL);
+
+ for (SCM s = extra; scm_is_pair (s); s = scm_cdr (s))
+ details = scm_cons (scm_car (s), details);
+ }
+
+ if (details == SCM_BOOL_F)
+ details = ly_assoc_get (ly_symbol2scm ("default"), bound_details, SCM_EOL);
+
+ SCM text = ly_assoc_get (ly_symbol2scm ("text"), details, SCM_BOOL_F);
+ if (Text_interface::is_markup (text))
+ {
+ Output_def *layout = me->layout ();
+ SCM properties = Font_interface::text_font_alist_chain (me);
+ details = scm_acons (ly_symbol2scm ("stencil"),
+ Text_interface::interpret_markup (layout->self_scm (),
+ properties, text),
+ details);
+ }
+
+ if (!scm_is_number (ly_assoc_get (ly_symbol2scm ("X"), details, SCM_BOOL_F)))
+ {
+ Direction attach = (Direction)
+ robust_scm2int (ly_assoc_get (ly_symbol2scm ("attach-dir"),
+ details, SCM_BOOL_F),
+ CENTER);
+
+ details = scm_acons (ly_symbol2scm ("X"),
+ scm_from_double (me->get_bound (dir)->extent (commonx, X_AXIS)
+ .linear_combination (attach)),
+ details);
+ }
+
+
+ if (!scm_is_number (ly_assoc_get (ly_symbol2scm ("Y"), details, SCM_BOOL_F)))
+ {
+ Real y = 0.0;
+
+ Real extra_dy = robust_scm2double (me->get_property ("extra-dy"),
+ 0.0);
+
+ if (me->get_bound (dir)->break_status_dir ())
+ {
+ /*
+ This is hairy. For the normal case, we simply find common
+ parents, and draw a line between the bounds. When two note
+ heads are on different systems, there is no common parent
+ anymore. We have to find the piano-staff object.
+ */
+
+ Spanner *next_sp = me->broken_neighbor (dir);
+ Item *next_bound = next_sp->get_bound (dir);
+
+ if (next_bound->break_status_dir ())
+ {
+ programming_error ("no note heads for the line spanner on neighbor line?"
+ " Confused.");
+ me->suicide ();
+ return SCM_EOL;
+ }
+
+ Grob *next_common_y = line_spanner_common_parent (next_bound);
+ Interval next_ext = next_bound->extent (next_common_y, Y_AXIS);
+
+ y = next_ext.center ();
+ }
+ else
+ {
+ Grob *commony = common_y (me);
+ y = me->get_bound (dir)->extent (commony, Y_AXIS).center();
+ }
+
+ y += dir * extra_dy / 2;
+ details = scm_acons (ly_symbol2scm ("Y"), scm_from_double (y), details);
+ }
+
+ return details;
+}
+
+MAKE_SCHEME_CALLBACK (New_line_spanner, calc_right_bound_info, 1);
+SCM
+New_line_spanner::calc_right_bound_info (SCM smob)
+{
+ return New_line_spanner::calc_bound_info (smob, RIGHT);
+}
+
+MAKE_SCHEME_CALLBACK (New_line_spanner, calc_left_bound_info, 1);
+SCM
+New_line_spanner::calc_left_bound_info (SCM smob)
+{
+ return New_line_spanner::calc_bound_info (smob, LEFT);
+}
+
+MAKE_SCHEME_CALLBACK (New_line_spanner, calc_left_bound_info_and_text, 1);
+SCM
+New_line_spanner::calc_left_bound_info_and_text (SCM smob)
+{
+ SCM alist = New_line_spanner::calc_bound_info (smob, LEFT);
+ Spanner *me = unsmob_spanner (smob);
+
+ SCM text = me->get_property ("text");
+ if (Text_interface::is_markup (text)
+ && me->get_bound (LEFT)->break_status_dir () == CENTER
+ && ly_assoc_get (ly_symbol2scm ("stencil"), alist, SCM_BOOL_F) == SCM_BOOL_F)
+ {
+ Output_def *layout = me->layout ();
+ SCM properties = Font_interface::text_font_alist_chain (me);
+ alist = scm_acons (ly_symbol2scm ("stencil"),
+ Text_interface::interpret_markup (layout->self_scm (),
+ properties, text),
+ alist);
+ }
+
+ return alist;
+}
+
+MAKE_SCHEME_CALLBACK (New_line_spanner, print, 1);
+SCM
+New_line_spanner::print (SCM smob)
+{
+ Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
+
+ Interval_t<Moment> moments = me->spanned_time ();
+ /*
+ We remove the line at the start of the line. For piano voice
+ indicators, it makes no sense to have them at the start of the
+ line.
+
+ I'm not sure what the official rules for glissandi are, but
+ usually the 2nd note of the glissando is "exact", so when playing
+ from the start of the line, there is no need to glide.
+
+ From a typographical p.o.v. this makes sense, since the amount of
+ space left of a note at the start of a line is very small.
+
+ --hwn.
+
+ */
+ if (moments.length () == Moment (0,0))
+ return SCM_EOL;
+
+ Drul_array<SCM> bounds (me->get_property ("left-bound-info"),
+ me->get_property ("right-bound-info"));
+
+
+ Grob *commonx = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS);
+ commonx = me->common_refpoint (commonx, X_AXIS);
+
+ Drul_array<Offset> span_points;
+
+ Direction d = LEFT;
+ do
+ {
+ Offset z (robust_scm2double (ly_assoc_get (ly_symbol2scm ("X"),
+ bounds[d], SCM_BOOL_F), 0.0)
+ + commonx->relative_coordinate (commonx, X_AXIS),
+ robust_scm2double (ly_assoc_get (ly_symbol2scm ("Y"),
+ bounds[d], SCM_BOOL_F), 0.0));
+
+ span_points[d] = z;
+ }
+ while (flip (&d) != LEFT);
+
+ Offset dz = (span_points[RIGHT] - span_points[LEFT]);
+ Offset dz_dir = dz.direction ();
+ Drul_array<Real> gaps (0, 0);
+ Drul_array<bool> arrows (0, 0);
+ Drul_array<Stencil*> stencils (0,0);
+ do
+ {
+ gaps[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("padding"),
+ bounds[d], SCM_BOOL_F), 0.0);
+ arrows[d] = to_boolean (ly_assoc_get (ly_symbol2scm ("arrow"),
+ bounds[d], SCM_BOOL_F));
+ stencils[d] = unsmob_stencil (ly_assoc_get (ly_symbol2scm ("stencil"),
+ bounds[d], SCM_BOOL_F));
+
+ }
+ while (flip (&d) != LEFT);
+
+ if (gaps[LEFT] + gaps[RIGHT] > dz.length ())
+ {
+ return SCM_EOL;
+ }
+
+ Stencil line;
+ do
+ {
+ if (stencils[d])
+ {
+ Stencil s = stencils[d]->translated (span_points[d]);
+ SCM align = ly_assoc_get (ly_symbol2scm ("stencil-align-dir-y"),
+ bounds[d], SCM_BOOL_F);
+ SCM off = ly_assoc_get (ly_symbol2scm ("stencil-offset"),
+ bounds[d], SCM_BOOL_F);
+
+ if (scm_is_number (align))
+ s.align_to (Y_AXIS, scm_to_double (align));
+
+ /*
+ todo: should use font-size.
+ */
+ if (is_number_pair (off))
+ s.translate (ly_scm2offset (off));
+
+ line.add_stencil (s);
+ }
+ }
+ while (flip (&d) != LEFT);
+
+ do
+ {
+ if (stencils[d])
+ span_points[d] += dz_dir *
+ (stencils[d]->extent (X_AXIS)[-d] / dz_dir[X_AXIS]);
+
+
+ span_points[d] += -d * gaps[d] * dz.direction ();
+ }
+ while (flip (&d) != LEFT);
+
+ line.add_stencil (Line_interface::line (me,
+ span_points[LEFT],
+ span_points[RIGHT]));
+
+ line.add_stencil (Line_interface::arrows (me,
+ span_points[LEFT],
+ span_points[RIGHT],
+ arrows[LEFT],
+ arrows[RIGHT]));
+ Grob *commony = common_y (me);
+
+ line.translate (Offset (-me->relative_coordinate (commonx, X_AXIS),
+ -me->relative_coordinate (commony, Y_AXIS)));
+
+
+ return line.smobbed_copy ();
+}
+
+ADD_INTERFACE (New_line_spanner,
+ "Generic line drawn between two objects, e.g. for use with glissandi.\n"
+ "The property @code{style} can be @code{line}, "
+ "@code{dashed-line}, @code{trill}, \n"
+ "@code{dotted-line} or @code{zigzag}.\n"
+ "\n",
+
+ "extra-dy "
+ "gap "
+ "thickness "
+ "bound-details "
+ "left-bound-info "
+ "right-bound-info "
+ );
+
return buffer;
}
else
- programming_error ("Cannot find OpenType table.");
+ programming_error (_f ("Free type error: %s",
+ freetype_error_string (error_code).c_str ()
+ ));
return 0;
}
if (error_code == FT_Err_Unknown_File_Format)
error (_f ("unsupported font format: %s", str.c_str ()));
else if (error_code)
- error (_f ("unknown error: %d reading font file: %s", error_code,
- str.c_str ()));
+ error (_f ("error reading font file %s: %s",
+ str.c_str (),
+ freetype_error_string (error_code).c_str ()
+ ));
return face;
}
char name[len];
size_t code = FT_Get_Glyph_Name (face_, signed_idx, name, len);
if (code)
- warning (_f ("FT_Get_Glyph_Name() returned error: %u", unsigned (code)));
+ warning (_f ("FT_Get_Glyph_Name() Freetype error: %s",
+ freetype_error_string (code)));
SCM sym = ly_symbol2scm (name);
SCM alist = scm_hashq_ref (lily_character_table_, sym, SCM_BOOL_F);
char name[len];
size_t code = FT_Get_Glyph_Name (face_, i, name, len);
if (code)
- warning (_f ("FT_Get_Glyph_Name() returned error: %u", unsigned (code)));
+ warning (_f ("FT_Get_Glyph_Name() error: %s",
+ freetype_error_string (code).c_str ()));
*tail = scm_cons (scm_from_locale_string (name), SCM_EOL);
tail = SCM_CDRLOC (*tail);
Page_breaking::break_into_pieces (vsize start_break, vsize end_break, Line_division const &div)
{
vector<Break_position> chunks = chunk_list (start_break, end_break);
- assert (chunks.size () == div.size () + 1);
+ bool ignore_div = false;
+ if (chunks.size () != div.size () + 1)
+ {
+ programming_error ("did not find a valid page breaking configuration");
+ ignore_div = true;
+ assert (0);
+ }
for (vsize i = 0; i + 1 < chunks.size (); i++)
{
vsize end;
line_breaker_args (sys, chunks[i], chunks[i+1], &start, &end);
- vector<Column_x_positions> pos = line_breaking_[sys].solve (start, end, div[i]);
+ vector<Column_x_positions> pos = ignore_div
+ ? line_breaking_[sys].best_solution (start, end)
+ : line_breaking_[sys].solve (start, end, div[i]);
all_[sys].pscore_->root_system ()->break_into_pieces (pos);
}
}
{
int errorcode = FT_Get_Glyph_Name (ftface, pg, glyph_name, GLYPH_NAME_LEN);
if (errorcode)
- programming_error ("FT_Get_Glyph_Name returns error");
+ programming_error (_f ("FT_Get_Glyph_Name() error: %s",
+ freetype_error_string (errorcode).c_str()
+ ));
}
SCM char_id = SCM_EOL;
char *str = pango_font_description_to_string (pfd);
SCM scm_str = scm_from_locale_string (str);
g_free (str);
-
+ pango_font_description_free (pfd);
+
return find_pango_font (layout, scm_str, 1.0);
}
scm_seek (port, scm_long2num (off), scm_long2num (SEEK_SET));
SCM from = scm_ftell (port);
+ scm_set_port_line_x (port, scm_from_int (ps->start_location_.line_number () -1));
+ scm_set_port_column_x (port, scm_from_int (ps->start_location_.column_number () -1));
+
SCM answer = SCM_UNSPECIFIED;
SCM form = scm_read (port);
%type <scm> pitch_also_in_chords
%type <scm> post_events
%type <scm> property_operation
+%type <scm> property_path
%type <scm> scalar
%type <scm> script_abbreviation
%type <scm> simple_chord_elements
}
;
+
+property_path:
+ embedded_scm {
+ $$ = scm_cons ($1, SCM_EOL);
+ }
+ | property_path embedded_scm {
+ $$ = scm_cons ($2, $1);
+ }
+ ;
+
property_operation:
STRING '=' scalar {
$$ = scm_list_3 (ly_symbol2scm ("assign"),
$$ = scm_list_2 (ly_symbol2scm ("unset"),
scm_string_to_symbol ($2));
}
- | OVERRIDE simple_string embedded_scm '=' embedded_scm {
- $$ = scm_list_4 (ly_symbol2scm ("push"),
- scm_string_to_symbol ($2), $5, $3);
- }
- | OVERRIDE simple_string embedded_scm embedded_scm '=' embedded_scm {
- $$ = scm_list_5 (ly_symbol2scm ("push"),
- scm_string_to_symbol ($2), $6, $4, $3);
+ | OVERRIDE simple_string property_path '=' embedded_scm {
+ $$ = scm_append (scm_list_2 (scm_list_3 (ly_symbol2scm ("push"),
+ scm_string_to_symbol ($2), $5),
+ $3));
}
| REVERT simple_string embedded_scm {
$$ = scm_list_3 (ly_symbol2scm ("pop"),
;
simple_music_property_def:
- OVERRIDE context_prop_spec embedded_scm '=' scalar {
- $$ = scm_list_5 (scm_car ($2),
- ly_symbol2scm ("OverrideProperty"),
- scm_cadr ($2),
- $5, $3);
- }
- | OVERRIDE context_prop_spec embedded_scm embedded_scm '=' scalar {
- $$ = scm_list_n (scm_car ($2),
- ly_symbol2scm ("OverrideProperty"),
- scm_cadr ($2),
- $6, $4, $3, SCM_UNDEFINED);
+ OVERRIDE context_prop_spec property_path '=' scalar {
+ $$ = scm_append (scm_list_2 (scm_list_n (scm_car ($2),
+ ly_symbol2scm ("OverrideProperty"),
+ scm_cadr ($2),
+ $5, SCM_UNDEFINED),
+ $3));
}
| REVERT context_prop_spec embedded_scm {
$$ = scm_list_4 (scm_car ($2),
#include "international.hh"
#include "lily-version.hh"
#include "main.hh"
-#include "midi-item.hh"
+#include "midi-chunk.hh"
#include "midi-stream.hh"
#include "score.hh"
#include "string-convert.hh"
}
void
-Prob::internal_set_property (SCM sym, SCM val
-#ifndef NDEBUG
- , char const *file, int line, char const *fun
-#endif
- )
+Prob::internal_set_property (SCM sym, SCM val)
{
-#ifndef NDEBUG
- (void) file;
- (void) line;
- (void) fun;
-#endif
-
if (do_internal_type_checking_global)
type_check_assignment (sym, val);
#include "output-def.hh"
#include "dimensions.hh"
#include "pointer-group-interface.hh"
+#include "moment.hh"
void
Separating_group_spanner::find_rods (Item *r,
Separation_item::set_distance (Drul_array<Item*> (lb, r), padding);
}
- if (Separation_item::set_distance (Drul_array<Item *> (l, r), padding))
+ if (Separation_item::set_distance (Drul_array<Item *> (l, r), padding)
+ /*
+ This check is because grace notes are set very tight, and
+ the accidentals of main note may stick out so far to cover
+ a barline preceding the grace note.
+ */
+ && spanned_time_interval (l, r).length ().main_part_ > Rational (0))
break;
/*
-/*
- source.cc -- implement Sources
-
- source file of the LilyPond music typesetter
-
- (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
-*/
-
-#include "source.hh"
-
-#include "source-file.hh"
-#include "file-path.hh"
-
-Sources::Sources ()
-{
- path_ = 0;
-}
-
-
-Sources::Sources (Sources const &)
-{
- assert (false);
-}
-
-
-void
-Sources::set_path (File_path *f)
-{
- path_ = f;
-}
-
-/**
- open a file
-
- File_string the file to be opened, name might be changed if it is
- found in a search path.
-*/
-Source_file *
-Sources::get_file (string *file_string) //UGH
-{
- if (*file_string != "-" && path_)
- {
- string file_string_o = path_->find (*file_string);
- if ((file_string_o == "") && (*file_string != ""))
- return 0;
- *file_string = file_string_o;
- }
- Source_file *f = new Source_file (*file_string);
- add (f);
- return f;
-}
-
-void
-Sources::add (Source_file *sourcefile)
-{
- sourcefiles_.push_back (sourcefile);
-}
-
-Sources::~Sources ()
-{
- for (vsize i = 0; i < sourcefiles_.size (); i++)
- {
- sourcefiles_[i]->unprotect ();
- }
-}
-
--- /dev/null
+/*
+ source.cc -- implement Sources
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
+
+#include "sources.hh"
+
+#include "source-file.hh"
+#include "file-path.hh"
+
+Sources::Sources ()
+{
+ path_ = 0;
+}
+
+
+Sources::Sources (Sources const &)
+{
+ assert (false);
+}
+
+
+void
+Sources::set_path (File_path *f)
+{
+ path_ = f;
+}
+
+/**
+ open a file
+
+ File_string the file to be opened, name might be changed if it is
+ found in a search path.
+*/
+Source_file *
+Sources::get_file (string *file_string) //UGH
+{
+ if (*file_string != "-" && path_)
+ {
+ string file_string_o = path_->find (*file_string);
+ if ((file_string_o == "") && (*file_string != ""))
+ return 0;
+ *file_string = file_string_o;
+ }
+ Source_file *f = new Source_file (*file_string);
+ add (f);
+ return f;
+}
+
+void
+Sources::add (Source_file *sourcefile)
+{
+ sourcefiles_.push_back (sourcefile);
+}
+
+Sources::~Sources ()
+{
+ for (vsize i = 0; i < sourcefiles_.size (); i++)
+ {
+ sourcefiles_[i]->unprotect ();
+ }
+}
+
#include "stencil.hh"
#include "system.hh"
#include "warn.hh"
+#include "moment.hh"
Grob *
Spanner::clone () const
}
Interval_t<int>
-Spanner::spanned_rank_iv ()
+Spanner::spanned_rank_iv () const
{
Interval_t<int> iv (0, 0);
return iv;
}
+Interval_t<Moment>
+Spanner::spanned_time () const
+{
+ return spanned_time_interval (spanned_drul_[LEFT],
+ spanned_drul_[RIGHT]);
+}
+
+
Item *
Spanner::get_bound (Direction d) const
{
return dim_;
}
+void
+Stencil::rotate (Real a, Offset off)
+{
+ rotate_degrees (a *180/M_PI, off);
+}
+
/*
- * Rotate this stencil around the point [x, y]
+ Rotate this stencil around the point [x, y]
*/
void
-Stencil::rotate (Real a, Offset off)
+Stencil::rotate_degrees (Real a, Offset off)
{
const Real x_cen = extent (X_AXIS).center ();
const Real y_cen = extent (Y_AXIS).center ();
--- /dev/null
+/*
+ system-scheme.cc -- implement scheme bindings to System
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2007 Joe Neeman <joeneeman@gmail.com>
+*/
+
+#include "align-interface.hh"
+#include "pointer-group-interface.hh"
+#include "system.hh"
+
+
+LY_DEFINE (ly_system_print, "ly:system-print",
+ 1, 0, 0, (SCM system),
+ "Draw the system and return the prob containing its "
+ "stencil.")
+{
+ Grob *me = unsmob_grob (system);
+ System *me_system = dynamic_cast<System*> (me);
+ SCM_ASSERT_TYPE (me, system, SCM_ARG1, __FUNCTION__, "grob");
+
+ return me_system->get_paper_system ();
+}
+
+LY_DEFINE (ly_system_stretch, "ly:system-stretch",
+ 2, 0, 0, (SCM system, SCM amount_scm),
+ "Stretch the system vertically by the given amount. "
+ "This must be called before the system is drawn (for example "
+ "with ly:system-print).")
+{
+ Grob *me = unsmob_grob (system);
+ Real amount = robust_scm2double (amount_scm, 0.0);
+
+ extract_grob_set (me, "elements", elts);
+ for (vsize i = 0; i < elts.size (); i++)
+ if (Align_interface::has_interface (elts[i]))
+ {
+ Align_interface::stretch (elts[i], amount, Y_AXIS);
+ break;
+ }
+ return SCM_UNDEFINED;
+}
*/
#include "moment.hh"
+#include "real.hh"
+#include "interval.hh"
#include "interval.tcc"
return infty;
}
+
template<>
string
Interval_t<Rational>::T_to_string (Rational a)
}
template INTERVAL__INSTANTIATE (Rational);
+
+
+template<>
+Moment
+Interval_t<Moment>::infinity ()
+{
+ Moment infty;
+
+ infty.main_part_.set_infinite (1);
+ return infty;
+}
+
+
+template<>
+string
+Interval_t<Moment>::T_to_string (Moment a)
+{
+ return a.to_string ();
+}
+
+template INTERVAL__INSTANTIATE (Moment);
+
+template<>
+Real
+Interval_t<Real>::linear_combination (Real x) const
+{
+ Drul_array<Real> da (at (LEFT), at (RIGHT));
+ return ::linear_combination (da, x);
+}
x.add_point (stem->relative_coordinate (x_refpoint_, X_AXIS));
x.widen (staff_space / 20); // ugh.
Interval y;
- y.add_point (Stem::stem_end_position (stem) * staff_space * .5);
+ Real stem_end_position =
+ Stem::is_cross_staff (stem)
+ ? get_grob_direction (stem) * infinity_f
+ : Stem::stem_end_position (stem) * staff_space * .5;
+
+ y.add_point (stem_end_position);
Direction stemdir = get_grob_direction (stem);
y.add_point (Stem::head_positions (stem)[-stemdir]
GLYPH_NAME_LEN);
if (error)
{
- programming_error ("print_trailer(): FT_Get_Glyph_Name() returned error");
+ programming_error ("FT_Get_Glyph_Name(): error.");
glyph_name[0] = 0;
}
}
\consists "Figured_bass_position_engraver"
\consists "Script_row_engraver"
- \override VerticalAxisGroup #'minimum-Y-extent = #'(-3.5 . 3.5)
localKeySignature = #'()
createSpacing = ##t
ignoreFiguredBassRest = ##t
"Just like @code{GrandStaff} but with a forced distance between
the staves, so cross staff beaming and slurring can be used."
+ \override VerticalAxisGroup #'minimum-Y-extent = #'(-4 . 4)
\consists "Instrument_name_engraver"
instrumentName = #'()
%% No accidental in tablature !
\remove Accidental_engraver
+ \override Glissando #'extra-dy = #0.75
+ \override Glissando #'bound-details #'right = #`((attach-dir . ,LEFT)
+ (padding . 0.3))
+ \override Glissando #'bound-details #'left = #`((attach-dir . ,RIGHT)
+ (padding . 0.3))
\override Glissando #'extra-dy = #0.75
\override Glissando #'gap = #0.2
}
'quoted-voice-direction dir
'origin location))
-%% The following causes an error with guile 1.6.8 (guile 1.6.7 and 1.8.x are fine)
-#(use-modules (scm display-lily))
-
displayLilyMusic =
#(define-music-function (parser location music) (ly:music?)
(newline)
return str
conversions.append (((1,3,113), conv, 'LyricVoice -> LyricsVoice'))
+def regularize_id (str):
+ s = ''
+ lastx = ''
+ for x in str:
+ if x == '_':
+ lastx = x
+ continue
+ elif x in string.digits:
+ x = chr(ord (x) - ord ('0') +ord ('A'))
+ elif x not in string.letters:
+ x = 'x'
+ elif x in string.lowercase and lastx == '_':
+ x = string.upper (x)
+ s = s + x
+ lastx = x
+ return s
def conv (str):
- def regularize_id (str):
- s = ''
- lastx = ''
- for x in str:
- if x == '_':
- lastx = x
- continue
- elif x in string.digits:
- x = chr(ord (x) - ord ('0') +ord ('A'))
- elif x not in string.letters:
- x = 'x'
- elif x in string.lowercase and lastx == '_':
- x = string.upper (x)
- s = s + x
- lastx = x
- return s
+
def regularize_dollar_reference (match):
return regularize_id (match.group (1))
--- /dev/null
+(define-module (scm coverage))
+
+(use-modules (lily)
+ (ice-9 rdelim)
+ (ice-9 regex)
+ (ice-9 format))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define-public (coverage:show-all filter?)
+ (let*
+ ((keys
+ (filter filter?
+ (sort (map car (hash-table->alist coverage-table)) string<? ))))
+
+ (newline)
+ (for-each
+ (lambda (k)
+
+ (format #t "Coverage for file: ~a\n" k)
+ (display-coverage
+ k (hash-ref coverage-table k)
+ (format #f "~a.cov" (basename k))))
+ keys)))
+
+
+(define-public (coverage:enable)
+ (trap-set! memoize-symbol-handler record-coverage)
+ (trap-enable 'memoize-symbol)
+ (trap-enable 'traps))
+
+
+(define-public (coverage:disable)
+ (trap-set! memoize-symbol-handler #f)
+ (trap-disable 'memoize-symbol))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define coverage-table (make-hash-table 57))
+
+(define (read-lines port)
+ (string-split (read-delimited "" port) #\newline))
+
+(define (display-coverage file vec out-file)
+ (let*
+ ((lines (read-lines (open-file file "r")))
+ (format-str "~8@a: ~5@a:~a\n")
+ (out (if out-file (open-output-file out-file)
+ (current-output-port))))
+
+ (format out format-str "-" 0 (format #f "Source:~a" file))
+ (do
+ ((i 0 (1+ i))
+ (l lines (cdr l)))
+ ((or (null? l) ))
+
+ (format out format-str
+ (cond
+ ((and (< i (vector-length vec)) (vector-ref vec i)) "1")
+ ((and (string-contains file ".ly") (string-match "^[ \t]*%.*$" (car l)))
+ "-")
+ ((string-match "^[ \t]*[()'`,]*$" (car l))
+ "-")
+ ((string-match "^[ \t]*;.*$" (car l))
+
+ "-")
+ (else "0"))
+ (1+ i)
+ (car l)))))
+
+(define (record-coverage key cont exp env)
+ (let*
+ ((name (source-property exp 'filename))
+ (line (source-property exp 'line))
+ (vec (and name (hash-ref coverage-table name #f)))
+ (veclen (and vec (vector-length vec)))
+ (veccopy (lambda (src dst)
+ (vector-move-left! src 0 (vector-length src)
+ dst 0)
+ dst)))
+ (if (and line name)
+ (begin
+ (if (or (not vec) (>= line (vector-length vec)))
+ (set! vec
+ (hash-set! coverage-table name
+ (if vec
+ (veccopy vec (make-vector (1+ line) #f))
+ (make-vector (1+ line) #f)))))
+
+ (vector-set! vec line #t))
+ )))
+
+
+
+
+
"Dynamic line spanner"
'(avoid-slur))
+(ly:add-interface
+ 'dynamic-text-spanner-interface
+ "Dynamic text spanner"
+ '(text))
+
(ly:add-interface
'finger-interface
"A fingering instruction"
(before-line-breaking ,boolean? "Dummy property, used to trigger a callback function.")
(between-cols ,pair? "Where to attach a loose column to")
(bound-padding ,number? "The amount of padding to insert around spanner bounds.")
+ (bound-details ,list? "alist of properties for determining attachments of spanners to edges.")
(bracket-flare ,number-pair? "A pair of numbers specifying how
much edges of brackets should slant outward. Value 0.0 means straight
edges")
"The thickness of ledger lines: it is the
sum of 2 numbers. The first is the factor for line thickness, and the
second for staff space. Both contributions are added.")
+ (left-bound-info ,list? "alist of properties for determining attachments of spanners to edges.")
(left-padding ,ly:dimension? "The amount of space that is put
left to an object (eg. a group of accidentals).")
(length ,ly:dimension? "User override for the stem length of
(minimum-Y-extent ,number-pair? "See @code{minimum-X-extent}.")
(minimum-length ,ly:dimension? "Try to make a spanner at least
this long. This requires an appropriate callback for the
-@code{springs-and-rods} property.")
+@code{springs-and-rods} property. If added to a Tie, this sets the
+minimum distance between noteheads.")
(minimum-space ,ly:dimension? "Minimum distance that the victim
should move (after padding).")
(neutral-direction ,ly:dir? "Which direction to take in the
(remove-first ,boolean? "Remove the first staff of a orchestral score?")
(restore-first ,boolean? "Print a natural before the accidental.")
(rhythmic-location ,rhythmic-location? "Where (bar number, measure position) in the score.")
+ (right-bound-info ,list? "alist of properties for determining attachments of spanners to edges.")
(right-padding ,ly:dimension? "Space to insert on the right side of an object (eg. between note and its accidentals.)")
(rotation ,list? "Number of degrees to rotate this object, and what point
to rotate around. #'(45 0 0) means rotate 45 degrees around the center of this object.")
(DynamicTextSpanner
. (
- (stencil . ,ly:dynamic-text-spanner::print)
-
;; rather ugh with NCSB
;; (font-series . bold)
(font-shape . italic)
(style . dashed-line)
+ (bound-details . ((right . ((attach-dir . ,LEFT)
+ (Y . 0)
+ (padding . 0.75)
+ ))
+ (right-broken . ((attach-dir . ,RIGHT)
+ (padding . 0.0)
+ ))
+
+ (left . ((attach-dir . ,LEFT)
+ (Y . 0)
+ (stencil-offset . (0 . -0.5))
+ (padding . 0.5)
+ ))
+ (left-broken . ((attach-dir . ,RIGHT)
+
+ ;; make sure the - - - stays at reasonable
+ ;; distance from staff.
+ (text . " ")
+ ))
+ ))
+ (stencil . ,ly:new-line-spanner::print)
+ (left-bound-info . ,ly:new-line-spanner::calc-left-bound-info-and-text)
+ (right-bound-info . ,ly:new-line-spanner::calc-right-bound-info)
+
;; need to blend with dynamic texts.
(font-size . 1)
- (bound-padding . 0.75)
(dash-fraction . 0.2)
(dash-period . 3.0)
(meta . ((class . Spanner)
(interfaces . (font-interface
text-interface
- line-spanner-interface
+ new-line-spanner-interface
+ line-interface
dynamic-interface
dynamic-text-spanner-interface
spanner-interface))))))
(zigzag-width . 0.75)
(X-extent . #f)
(Y-extent . #f)
- (stencil . ,ly:line-spanner::print)
- (after-line-breaking . ,ly:line-spanner::after-line-breaking)
+ (bound-details . ((right . ((attach-dir . ,CENTER)
+ (padding . 1.5)
+ ))
+ (left . ((attach-dir . ,CENTER)
+ (padding . 1.5)
+ ))
+ ))
+ (stencil . ,ly:new-line-spanner::print)
+ (left-bound-info . ,ly:new-line-spanner::calc-left-bound-info)
+ (right-bound-info . ,ly:new-line-spanner::calc-right-bound-info)
(meta . ((class . Spanner)
(interfaces . (line-interface
unbreakable-spanner-interface
- line-spanner-interface))))))
+ new-line-spanner-interface))))))
(GraceSpacing
. (
(TrillSpanner
. (
- (stencil . ,ly:dynamic-text-spanner::print)
- (edge-text . ,(cons (make-musicglyph-markup "scripts.trill")
- ""))
+ (left-bound-info . ,ly:new-line-spanner::calc-left-bound-info)
+ (right-bound-info . ,ly:new-line-spanner::calc-right-bound-info)
+
+ (bound-details . ((left . ((text . ,(make-translate-scaled-markup
+ '(0.5 . -0.6)
+ (make-musicglyph-markup "scripts.trill")))
+ (Y . 0)
+ (padding . 0.25)
+ (attach-dir . ,LEFT)
+ ))
+ (right . ((Y . 0)))
+ ))
+
+ (stencil . ,ly:new-line-spanner::print)
+
(style . trill)
(staff-padding . 1.0)
(padding . 0.5)
(outside-staff-priority . 50)
(meta . ((class . Spanner)
(interfaces . (text-spanner-interface
- line-spanner-interface
+ new-line-spanner-interface
side-position-interface
font-interface))))))
(non-musical . #t)
(X-extent . #f)
(Y-extent . #f)
- (stencil . ,ly:line-spanner::print)
- (after-line-breaking . ,ly:line-spanner::after-line-breaking)
+ (bound-details . ((right . ((attach-dir . ,CENTER)
+ (padding . 1.5)
+ ))
+ (left . ((attach-dir . ,CENTER)
+ (padding . 1.5)
+ ))
+ ))
+ (stencil . ,ly:new-line-spanner::print)
+ (left-bound-info . ,ly:new-line-spanner::calc-left-bound-info)
+ (right-bound-info . ,ly:new-line-spanner::calc-right-bound-info)
(meta . ((class . Spanner)
- (interfaces . (line-spanner-interface
+ (interfaces . (new-line-spanner-interface
line-interface))))
))
?unit-count)))
;;; \clef
-(define clef-name-alist (map (lambda (name+vals)
- (cons (cdr name+vals)
- (car name+vals)))
- supported-clefs))
+(define clef-name-alist #f)
+(define-public (memoize-clef-names clefs)
+ "Initialize `clef-name-alist', if not already set."
+ (if (not clef-name-alist)
+ (set! clef-name-alist
+ (map (lambda (name+vals)
+ (cons (cdr name+vals)
+ (car name+vals)))
+ clefs))))
(define-extra-display-method ContextSpeccedMusic (expr parser)
"If `expr' is a clef change, return \"\\clef ...\"
;;; Display methods are stored in the `display-methods' property of each music
;;; type.
;;;
-;;; - `display-lily-music' can be called to display a music expression using
-;;; LilyPond notation. `music->lily-string' return a string describing a music
-;;; expression using LilyPond notation.
+;;; - `music->lily-string' return a string describing a music expression using
+;;; LilyPond notation. The special variables *indent*, *previous-duration*,
+;;; and *force-duration* influence the indentation level and the display of
+;;; music durations.
;;;
;;; - `with-music-match' can be used to destructure a music expression, extracting
;;; some interesting music properties.
music-type)))
(format #f "%{ expecting a music expression: ~a %}" expr)))
-(define*-public (display-lily-music expr parser #:key force-duration)
- (parameterize ((*indent* 0)
- (*previous-duration* (ly:make-duration 2))
- (*force-duration* force-duration))
- (display (music->lily-string expr parser))
- (newline)))
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Music pattern matching
;;;
;;; indentation
-(define *indent* (make-parameter 0))
+(define-public *indent* (make-parameter 0))
;;; set to #t to force duration printing
-(define *force-duration* (make-parameter #f))
+(define-public *force-duration* (make-parameter #f))
;;; last duration found
-(define *previous-duration* (make-parameter (ly:make-duration 2)))
+(define-public *previous-duration* (make-parameter (ly:make-duration 2)))
;;; Set to #t to force a line break with some kinds of expressions (eg sequential music)
(define *force-line-break* (make-parameter #t))
(string-append
"/" command " { /" fontname " " (ly:number->string scaling) " output-scale div selectfont } bind def\n"))
- (define (standard-tex-font? x)
- (or (equal? (substring x 0 2) "ms")
- (equal? (substring x 0 2) "cm")))
-
(define (font-load-command font)
(let* ((specced-font-name (ly:font-name font))
(fontname (if specced-font-name
(ops (ly:output-def-lookup paper 'output-scale))
(scaling (* ops magnification designsize)))
- ;; Bluesky pfbs have UPCASE names (sigh.)
- ;; FIXME - don't support Bluesky?
- (if (standard-tex-font? fontname)
- (set! fontname (string-upcase fontname)))
(if (equal? fontname "unknown")
(display (list font fontname)))
(define-font plain fontname scaling)))
(strict-infinity-checking #f "If yes, crash on encountering Inf/NaN.")
(separate-log-files #f "Output to FILE.log per file.")
(trace-memory-frequency #f "Record Scheme cell usage this many times per second, and dump to file.")
+ (trace-scheme-coverage #f "Record coverage of Scheme files")
(ttf-verbosity 0
"how much verbosity for TTF font embedding?")
(show-available-fonts #f
(srfi srfi-14)
(scm clip-region)
(scm memory-trace)
+ (scm coverage)
)
;; my display
;;; debugging evaluator is slower. This should
;;; have a more sensible default.
-(if (ly:get-option 'verbose)
+(if (or (ly:get-option 'verbose)
+ (ly:get-option 'trace-memory-frequencency)
+ (ly:get-option 'trace-scheme-coverage)
+ )
(begin
(ly:set-option 'protected-scheme-parsing #f)
(debug-enable 'debug)
(debug-enable 'backtrace)
(read-enable 'positions)))
+
+(if (ly:get-option 'trace-scheme-coverage)
+ (coverage:enable))
+
(define-public tex-backend?
(member (ly:output-backend) '("texstr" "tex")))
(let ((failed (lilypond-all files)))
+ (if (ly:get-option 'trace-scheme-coverage)
+ (begin
+ (coverage:show-all (lambda (f) (string-contains f "lilypond"))
+ )))
+
+
(if (pair? failed)
(begin
(ly:error (_ "failed files: ~S") (string-join failed))
(cdr arg)))))
;;
-;; typecheck, and throw an error when something amiss.
+;;
+;;
;;
(define (markup-thrower-typecheck arg)
+ "typecheck, and throw an error when something amiss.
+
+Uncovered - cheap-markup? is used."
+
(cond ((string? arg) #t)
((not (pair? arg))
(throw 'markup-format "Not a pair" arg))
(define-module (scm memory-trace))
+(use-modules (lily)
+ (ice-9 format))
-(use-modules (ice-9 format))
(define-public (mtrace:start-trace freq)
(set! usecond-interval (inexact->exact (/ 1000000 freq)))
(call-with-new-thread start-install-tracepoint))
(define continue-tracing #t)
(define busy-tracing #f)
(define trace-thread #f)
+(define start-time 0)
+(define start-memory 0)
(define trace-count 0)
(define usecond-interval 100000)
(pair? (cdr args))
(pair? (cadr args)))
(caadr args) #f))
-
+(define last-count 0)
(define (record-stack key continuation . args)
(if (eq? (current-thread) trace-thread)
#t ;; do nothing.
- (begin
+ (let*
+ ((cells (cdr (assoc 'total-cells-allocated (gc-stats))))
+ (proc (arg-procedure args))
+ (time (tms:utime (times)))
+ (stack (extract-trace continuation)))
+
(set! busy-tracing #t)
(trap-disable 'traps)
(trap-disable 'enter-frame)
+
(set! trace-count (1+ trace-count))
+ (ly:progress "<~a: ~a/~a>\n"
+ trace-count
+ (- time start-time)
+ (- cells last-count))
+ (set! last-count cells)
(set! trace-points
(cons (list
- (assoc 'total-cells-allocated (gc-stats))
- (cons 'stack (extract-trace continuation))
- (cons 'proc (arg-procedure args))
+ (cons 'cells cells)
+ (cons 'proc proc)
+ (cons 'stack stack)
+ (cons 'time time)
)
trace-points))
(define (start-install-tracepoint)
(set! trace-thread (current-thread))
+ (set! trace-points '())
+ (set! continue-tracing #t)
+ (set! trace-count 0)
+ (set! start-memory (cdr (assoc 'total-cells-allocated (gc-stats))))
+ (set! start-time (tms:utime (times)))
+
(install-tracepoint))
(define (install-tracepoint)
(install-tracepoint)))
(define-public (mtrace:dump-results base)
- (define out (open-output-file (format #f "~a.graph" base)))
- (define stacks-out (open-output-file (format #f "~a.stacks" base)))
- (define i 0)
- (define last-mem 0)
- (format out "# memory trace with ~a points\n" (length trace-points))
-
- (for-each
- (lambda (r)
- (let*
- ((mem (cdr (assoc 'total-cells-allocated r)))
- (proc (cdr (assoc 'proc r)))
- (stack (cdr (assoc 'stack r))))
-
- (format out "~a ~a\n" i mem)
- (if stack
- (begin
- (format stacks-out "~15a - delta-mem: ~15a - ~a \n" i
- (- mem last-mem) proc)
- (do
- ((j 0 (1+ j))
- (stack (cdr (assoc 'stack r)) stack))
- ((>= j (vector-length stack)))
-
- (format stacks-out "\t~a\n"
- (vector-ref stack j)))))
-
- (set! i (1+ i))
- (set! last-mem mem)
- ))
- (reverse trace-points)))
-
+ (let*
+ ((stacks-name (format #f "~a.stacks" base))
+ (graph-name (format #f "~a.graph" base))
+ (graph-out (open-output-file graph-name))
+ (stacks-out (open-output-file stacks-name))
+ (i 0)
+ (last-mem 0)
+ )
+
+ (ly:progress "Memory statistics to ~a and ~a..."
+ stacks-name graph-name)
+ (format graph-out "# memory trace with ~a points\n" (length trace-points))
+ (for-each
+ (lambda (r)
+ (let*
+ ((mem (- (cdr (assoc 'cells r)) start-memory))
+ (proc (cdr (assoc 'proc r)))
+ (stack (cdr (assoc 'stack r)))
+ (time (- (cdr (assoc 'time r)) start-time)))
+
+ (format graph-out "~a ~a\n" time mem)
+ (if stack
+ (begin
+ (format stacks-out "~5a t = ~5a - delta-mem: ~15a - ~a \n" i
+ time
+ (- mem last-mem) proc)
+ (do
+ ((j 0 (1+ j))
+ (stack (cdr (assoc 'stack r)) stack))
+ ((>= j (vector-length stack)))
+
+ (format stacks-out "\t~a\n"
+ (vector-ref stack j)))))
+
+ (set! i (1+ i))
+ (set! last-mem mem)
+ ))
+ (reverse trace-points))))
(define (test-graph . rest)
trace))
-
-
-
-
(newline)
obj)
+;;;
+;;; Scheme music expression --> Lily-syntax-using string translator
+;;;
+(use-modules (srfi srfi-39)
+ (scm display-lily))
+
+(define*-public (display-lily-music expr parser #:key force-duration)
+ "Display the music expression using LilyPond syntax"
+ (memoize-clef-names supported-clefs)
+ (parameterize ((*indent* 0)
+ (*previous-duration* (ly:make-duration 2))
+ (*force-duration* force-duration))
+ (display (music->lily-string expr parser))
+ (newline)))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-public (shift-one-duration-log music shift dot)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; warn for bare chords at start.
-(define (has-request-chord elts)
- (reduce (lambda (x y) (or x y)) #f
- (map (lambda (x)
- (equal? (ly:music-property x 'name) 'RequestChord))
- elts)))
(define-public (ly:music-message music msg)
(let ((ip (ly:music-property music 'origin)))
(ly:input-message ip msg)
(ly:warning msg))))
-(define (check-start-chords music)
- "Check music expression for a Simultaneous_music containing notes\n(ie. Request_chords),
-without context specification. Called from parser."
- (let ((es (ly:music-property music 'elements))
- (e (ly:music-property music 'element))
- (name (ly:music-property music 'name)))
- (cond ((equal? name "Context_specced_music") #t)
- ((equal? name "Simultaneous_music")
- (if (has-request-chord es)
- (ly:music-message music "Starting score with a chord.\nInsert an explicit \\context before chord")
- (map check-start-chords es)))
- ((equal? name "SequentialMusic")
- (if (pair? es)
- (check-start-chords (car es))))
- (else (if (ly:music? e) (check-start-chords e)))))
- music)
-
-
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; setting stuff for grace context.
setcolor
setrotation
text
- zigzag-line))
+ ))
(use-modules (guile)
;; ice-9 format uses a lot of memory
;; using simple-format almost halves lilypond cell usage
-(define format simple-format)
-
-(define (escape-parentheses s)
- (regexp-substitute/global #f "(^|[^\\])([\\(\\)])" s 'pre 1 "\\" 2 'post))
(define (str4 num)
(if (or (nan? num) (inf? num))
(ly:number->string num)))
(define (number-pair->string4 numpair)
- (string-append (str4 (car numpair))
- " "
- (str4 (cdr numpair))))
+ (ly:format "~4l" numpair))
(define (numbers->string4 numlist)
(string-join (map str4 numlist) " "))
-;; FIXME: lily-def
-(define-public (ps-string-def prefix key val)
- (format #f "/ ~a~a (~a) def\n"
- prefix
- (symbol->string key)
- (escape-parentheses val)))
-
-(define (ps-number-def prefix key val)
- (let ((s (if (integer? val)
- (ly:number->string val)
- (ly:number->string (exact->inexact val)))))
- (format #f "/~a~a ~a def\n"
- prefix
- (symbol->string key) s)))
-
-
;;;
;;; Lily output interface, PostScript implementation --- cleanup and docme
;;;
;; two beziers
(define (bezier-sandwich lst thick)
- (format #f "~a ~a draw_bezier_sandwich"
- (string-join (map number-pair->string4 lst) " ")
- (str4 thick)))
+ (ly:format "~l ~4f draw_bezier_sandwich"
+ (map number-pair->string4 lst)
+ thick))
(define (char font i)
- (format #f "~a (\\~a) show"
+ (ly:format "~a (\\~a) show"
(ps-font-command font)
(ly:inexact->string i 8)))
(define (circle radius thick fill)
- (format #f
- "~a ~a ~a draw_circle"
+ (ly:format
+ "~a ~4f ~4f draw_circle"
(if fill
"true"
"false")
- (str4 radius) (str4 thick)))
+ radius thick))
(define (dashed-line thick on off dx dy phase)
- (format #f "~a ~a ~a [ ~a ~a ] ~a draw_dashed_line"
- (str4 dx)
- (str4 dy)
- (str4 thick)
- (str4 on)
- (str4 off)
- (str4 phase)
-
- ))
+ (ly:format "~4f ~4f ~4f [ ~4f ~4f ] ~4f draw_dashed_line"
+ dx
+ dy
+ thick
+ on
+ off
+ phase))
;; what the heck is this interface ?
(define (dashed-slur thick on off l)
- (format #f "~a ~a [ ~a ~a ] 0 draw_dashed_slur"
+ (ly:format "~l ~4f [ ~4f ~4f ] 0 draw_dashed_slur"
(let ((control-points (append (cddr l) (list (car l) (cadr l)))))
- (string-join (map number-pair->string4 control-points) " "))
- (str4 thick)
- (str4 on)
- (str4 off)))
+ (map number-pair->string4 control-points))
+ thick
+ on
+ off))
(define (dot x y radius)
- (format #f " ~a draw_dot"
- (numbers->string4 (list radius x y))))
+ (ly:format " ~4l draw_dot" (list radius x y)))
(define (draw-line thick x1 y1 x2 y2)
- (format #f "~a ~a ~a ~a ~a draw_line"
- (str4 (- x2 x1))
- (str4 (- y2 y1))
- (str4 x1)
- (str4 y1)
- (str4 thick)))
+ (ly:format "~4f ~4f ~4f ~4f ~4f draw_line"
+ (- x2 x1) (- y2 y1)
+ x1 y1 thick))
(define (embedded-ps string)
string)
(define (glyph-spec w x y g)
(let ((prefix (if (string? g) "/" "")))
- (format #f "~a ~a ~a~a"
- (str4 (+ w x))
- (str4 y)
- prefix g)))
+ (ly:format "~4f ~4f ~a~a"
+ (+ w x) y
+ prefix g)))
- (format #f
- (if cid?
+ (ly:format
+ (if cid?
"/~a /CIDFont findresource ~a output-scale div scalefont setfont
~a
~a print_glyphs"
(if (and (< 0 (interval-length x-ext))
(< 0 (interval-length y-ext)))
- (format #f "~a ~a ~a ~a (textedit://~a:~a:~a:~a) mark_URI\n"
- (str4 (+ (car offset) (car x-ext)))
- (str4 (+ (cdr offset) (car y-ext)))
- (str4 (+ (car offset) (cdr x-ext)))
- (str4 (+ (cdr offset) (cdr y-ext)))
-
- ;; TODO
- ;;full escaping.
-
- ;; backslash is interpreted by GS.
- (ly:string-substitute "\\" "/"
- (ly:string-substitute " " "%20" file))
- (cadr location)
- (caddr location)
- (cadddr location))
+ (ly:format "~4f ~4f ~4f ~4f (textedit://~a:~a:~a:~a) mark_URI\n"
+ (+ (car offset) (car x-ext))
+ (+ (cdr offset) (car y-ext))
+ (+ (car offset) (cdr x-ext))
+ (+ (cdr offset) (cdr y-ext))
+
+ ;; TODO
+ ;;full escaping.
+
+ ;; backslash is interpreted by GS.
+ (ly:string-substitute "\\" "/"
+ (ly:string-substitute " " "%20" file))
+ (cadr location)
+ (caddr location)
+ (cadddr location))
"")))))
-(define (lily-def key val)
- (let ((prefix "lilypondlayout"))
- (if (string=?
- (substring key 0 (min (string-length prefix) (string-length key)))
- prefix)
- (format "/~a { ~a } bind def\n" key val)
- (format "/~a (~a) def\n" key val))))
(define (named-glyph font glyph)
- (format #f "~a /~a glyphshow " ;;Why is there a space at the end?
- (ps-font-command font)
- glyph))
+ (ly:format "~a /~a glyphshow " ;;Why is there a space at the end?
+ (ps-font-command font)
+ glyph))
(define (no-origin)
"")
(define (placebox x y s)
- (format #f
-"~a ~a moveto
-~a\n"
- (str4 x)
- (str4 y)
- s))
+ (ly:format
+"~4f ~4f moveto
+~a\n" x y s))
(define (polygon points blot-diameter filled?)
- (format #f "~a ~a ~a ~a draw_polygon"
- (if filled? "true" "false")
- (numbers->string4 points)
- (number->string (- (/ (length points) 2) 1))
- (str4 blot-diameter)))
+ (ly:format "~a ~4l ~a ~4f draw_polygon"
+ (if filled? "true" "false")
+ points
+ (- (/ (length points) 2) 1)
+ blot-diameter))
(define (repeat-slash width slope beam-thickness)
(define (euclidean-length x y)
(let ((x-width (euclidean-length beam-thickness (/ beam-thickness slope)))
(height (* width slope)))
- (format #f "~a draw_repeat_slash"
- (numbers->string4 (list x-width width height)))))
+ (ly:format "~4l draw_repeat_slash"
+ (list x-width width height))))
(define (round-filled-box left right bottom top blotdiam)
(width (- right (+ halfblot x)))
(y (- halfblot bottom))
(height (- top (+ halfblot y))))
- (format #f "~a draw_round_box"
- (numbers->string4
- (list width height x y blotdiam)))))
+ (ly:format "~4l draw_round_box"
+ (list width height x y blotdiam))))
;; save current color on stack and set new color
(define (setcolor r g b)
- (format #f "gsave ~a setrgbcolor\n"
- (numbers->string4 (list r g b))))
+ (ly:format "gsave ~4l setrgbcolor\n"
+ (list r g b)))
;; restore color from stack
(define (resetcolor) "grestore \n")
;; rotation around given point
(define (setrotation ang x y)
- (format #f "gsave ~a translate ~a rotate ~a translate\n"
- (numbers->string4 (list x y))
- (number->string ang)
- (numbers->string4 (list (* -1 x) (* -1 y)))))
+ (ly:format "gsave ~4l translate ~a rotate ~4l translate\n"
+ (list x y)
+ ang
+ (list (* -1 x) (* -1 y))))
(define (resetrotation ang x y)
"grestore ")
"\n unknown\n")
(define (url-link url x y)
- (format #f "~a ~a ~a ~a (~a) mark_URI"
- (car x)
- (car y)
- (cdr x)
- (cdr y)
- url))
+ (ly:format "~a ~a ~a ~a (~a) mark_URI"
+ (car x)
+ (car y)
+ (cdr x)
+ (cdr y)
+ url))
(define (utf-8-string pango-font-description string)
(ly:warning (_ "utf-8-string encountered in PS backend")))
-
-(define (zigzag-line centre? zzw zzh thick dx dy)
- (format #f "~a ~a ~a ~a 0 0 ~a ~a draw_zigzag_line"
- (if centre? "true" "false")
- (str4 zzw)
- (str4 zzh)
- (str4 thick)
- (str4 dx)
- (str4 dy)))
-
-
(define (path thickness exps)
(define (convert-path-exps exps)
(if (pair? exps)
)
;; WARNING: this is a vulnerability: a user can output arbitrary PS code here.
- (cons (format #f
- "~a ~a "
- (string-join (map (lambda (x) (format #f "~a " x)) args) " ")
+ (cons (ly:format
+ "~l ~a "
+ args
head)
(convert-path-exps (drop rest arity))))
'()))
- (format #f
- "1 setlinecap ~a setlinewidth\n~a stroke"
+ (ly:format
+ "1 setlinecap ~a setlinewidth\n~l stroke"
thickness
- (string-join (convert-path-exps exps) " ")))
+ (convert-path-exps exps) ))
dashed-slur
named-glyph
dashed-line
- zigzag-line
comment
repeat-slash
placebox
(define (dashed-line thick on off dx dy phase)
(embedded-ps (list 'dashed-line thick on off dx dy phase)))
-(define (zigzag-line centre? zzw zzh thick dx dy)
- (embedded-ps (list 'zigzag-line centre? zzw zzh thick dx dy)))
-
(define (embedded-ps expr)
(let ((ps-string
(with-output-to-string
(string-append "\\special{src:"
(line-column-location location) "}")
""))
- ""))
\ No newline at end of file
+ ""))
(define-public (gulp-file file-name . max-size)
(ly:gulp-file file-name (if (pair? max-size) (car max-size))))
-(define BOUNDING-BOX-RE
- "^%%BoundingBox: (-?[0-9]+) (-?[0-9]+) (-?[0-9]+) (-?[0-9]+)")
-
-(define (unused-found-broken-get-bbox file-name)
- (let* ((bbox (string-append file-name ".bbox"))
- ;; -sOutputFile does not work with bbox?
- (cmd (format #t "gs\
- -sDEVICE=bbox\
- -q\
- -dNOPAUSE\
- ~S\
- -c showpage\
- -c quit 2>~S"
- file-name bbox))
- (status (system cmd))
- (s (gulp-file bbox 10240))
- (m (string-match BOUNDING_BOX_RE s)))
-
- (if m
- (list->vector
- (map (lambda (x) (string->number (car x))) (vector->list m)))
- #f)))
-
-
;; copy of ly:system. ly:* not available via lilypond-ps2png.scm
(define (my-system be-verbose exit-on-error cmd)
(define status 0)
(input (if (ly:stream-event? cause) (ly:event-property cause 'origin) #f))
(location (if (ly:input-location? input) (ly:input-file-line-char-column input) '()))
+ ;; todo: use stencil extent if available.
(x-ext (ly:grob-extent grob system-grob X))
(y-ext (ly:grob-extent grob system-grob Y))
)
(numer . ,(car (ly:duration-factor d)))
(denom . ,(cdr (ly:duration-factor d))))))
-(define (musicxml-pitch->xml-node p)
- (make <xml-node>
- #:name 'pitch
- #:children
- (list
- (make <xml-node>
- #:name 'step
- #:value (list-ref '("C" "D" "E" "F" "G" "A" "B")
- (ly:pitch-notename p)))
- (make <xml-node>
- #:name 'octave
- #:value (number->string (ly:pitch-octave p))))))
-
(define (pitch->xml-node p)
(make <xml-node>
#:name 'pitch
;;
;; (display (dtd-header) port)
- (define pitch->xml-node musicxml-pitch->xml-node)
(define duration->xml-node musicxml-duration->xml-node)
(display (open-tag 'music '((type . score)) '()) port)