1. LilyPond files

1.1. Making LilyPond files

Make a basic LilyPond file with the lilypondfiletools package:

>>> staff = Staff("c'4 d'4 e'4 f'4")
>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file(staff)
>>> lilypond_file
LilyPondFile(comments=(), date_time_token=DateTimeToken(date_string='2016-10-22 15:22'), includes=(), items=[<Block(name='header')>, <Block(name='layout')>, <Block(name='paper')>, <Block(name='score')>], lilypond_language_token=LilyPondLanguageToken(), lilypond_version_token=LilyPondVersionToken(version_string='2.19.44'))
>>> print(format(lilypond_file))
% 2016-10-22 15:22

\version "2.19.44"
\language "english"

\header {}

\layout {}

\paper {}

\score {
    \new Staff {
        c'4
        d'4
        e'4
        f'4
    }
}
>>> show(lilypond_file)

1.2. Getting header, layout and paper blocks

Basic LilyPond files also come equipped with header, layout and paper blocks:

>>> lilypond_file.header_block
<Block(name='header')>
>>> lilypond_file.layout_block
<Block(name='layout')>
>>> lilypond_file.paper_block
<Block(name='paper')>

1.3. Setting global staff size and default paper size

A LilyPondFile’s global staff size and default paper size are immutable. Set them during instantiation, or by templating a new LilyPondFile via new():

Via templating:

>>> lilypond_file = new(
...     lilypond_file,
...     global_staff_size=14,
...     default_paper_size=('A7', 'portrait'),
...     )

When instantiating:

>>> lilypond_file = lilypondfiletools.make_basic_lilypond_file(
...     staff,
...     global_staff_size=14,
...     default_paper_size=('A7', 'portrait'),
...     )
>>> print(format(lilypond_file))
% 2016-10-22 15:22

\version "2.19.44"
\language "english"

#(set-default-paper-size "A7" 'portrait)
#(set-global-staff-size 14)

\header {}

\layout {}

\paper {}

\score {
    \new Staff {
        c'4
        d'4
        e'4
        f'4
    }
}
>>> show(lilypond_file)

1.4. Setting title, subtitle and composer information

Use the LilyPond file header block to set title, subtitle and composer information:

>>> lilypond_file.header_block.title = markuptools.Markup('Missa sexti tonus')
>>> lilypond_file.header_block.composer = markuptools.Markup('Josquin')
>>> print(format(lilypond_file))
% 2016-10-22 15:22

\version "2.19.44"
\language "english"

#(set-default-paper-size "A7" 'portrait)
#(set-global-staff-size 14)

\header {
    composer = \markup { Josquin }
    title = \markup { "Missa sexti tonus" }
}

\layout {}

\paper {}

\score {
    \new Staff {
        c'4
        d'4
        e'4
        f'4
    }
}
>>> show(lilypond_file)