abjad.lilypondfile
|
LilyPond file block. |
|
LilyPond file. |
- class abjad.lilypondfile.Block(name: str | None = None, items: list = <factory>)[source]
LilyPond file block.
Use strings to add contents to a block:
>>> string = r"""right-margin = 2\cm ... left-margin = 2\cm""" >>> block = abjad.Block("paper", items=[string]) >>> string = abjad.lilypond(block) >>> print(string) \paper { right-margin = 2\cm left-margin = 2\cm }
Define a context block like this:
>>> string = r"""\Staff ... \name FluteStaff ... \type Engraver_group ... \alias Staff ... \remove Forbid_line_break_engraver ... \consists Horizontal_bracket_engraver ... \accepts FluteUpperVoice ... \accepts FluteLowerVoice ... \override Beam.positions = #'(-4 . -4) ... \override Stem.stem-end-position = -6 ... autoBeaming = ##f ... tupletFullLength = ##t ... \accidentalStyle dodecaphonic""" >>> block = abjad.Block("context", items=[string]) >>> string = abjad.lilypond(block) >>> print(string) \context { \Staff \name FluteStaff \type Engraver_group \alias Staff \remove Forbid_line_break_engraver \consists Horizontal_bracket_engraver \accepts FluteUpperVoice \accepts FluteLowerVoice \override Beam.positions = #'(-4 . -4) \override Stem.stem-end-position = -6 autoBeaming = ##f tupletFullLength = ##t \accidentalStyle dodecaphonic }
Define an anonymous block like this:
>>> string = r"""command-1 ... command-2 ... command-3""" >>> block = abjad.Block("", items=[string]) >>> string = abjad.lilypond(block) >>> print(string) { command-1 command-2 command-3 }
Markup formats like this:
>>> block = abjad.Block("score", items=[abjad.Markup(r"\markup foo")]) >>> string = abjad.lilypond(block) >>> print(string) \score { \markup foo }
>>> staff = abjad.Staff("c'4 d' e' f'") >>> block = abjad.Block("score") >>> block.items.append("<<") >>> block.items.append(r'{ \include "layout.ly" }') >>> block.items.append(staff) >>> block.items.append(">>") >>> lilypond_file = abjad.LilyPondFile( ... lilypond_language_token=False, ... lilypond_version_token=False, ... ) >>> lilypond_file.items.append(block) >>> string = abjad.lilypond(lilypond_file) >>> print(string) \score { << { \include "layout.ly" } \new Staff { c'4 d'4 e'4 f'4 } >> }
- class abjad.lilypondfile.LilyPondFile(items: list = <factory>, lilypond_language_token: bool | str = True, lilypond_version_token: bool | str = True, tag: ~abjad.tag.Tag | None = None)[source]
LilyPond file.
>>> staff = abjad.Staff("c'8 d'8 e'8 f'8") >>> lilypond_file = abjad.LilyPondFile( ... items=[ ... r'\include "abjad.ily"', ... """#(set-default-paper-size "a5" 'portrait)""", ... "#(set-global-staff-size 16)", ... staff, ... ], ... )
>>> abjad.show(lilypond_file)
>>> string = abjad.lilypond(lilypond_file) >>> print(string) \version "2.25.26" \language "english" \include "abjad.ily" #(set-default-paper-size "a5" 'portrait) #(set-global-staff-size 16) \new Staff { c'8 d'8 e'8 f'8 }
get_tag
([site])Gets tag.