def _make_time_signature_context_block( font_size=3, minimum_distance=10, padding=4, ): from abjad.tools import layouttools from abjad.tools import lilypondfiletools assert isinstance(font_size, (int, float)) assert isinstance(padding, (int, float)) context_block = lilypondfiletools.ContextBlock( type_='Engraver_group', name='TimeSignatureContext', ) context_block.consists_commands.append('Axis_group_engraver') context_block.consists_commands.append('Time_signature_engraver') override(context_block).time_signature.X_extent = (0, 0) override(context_block).time_signature.X_offset = schemetools.Scheme( 'ly:self-alignment-interface::x-aligned-on-self') override(context_block).time_signature.Y_extent = (0, 0) override(context_block).time_signature.break_align_symbol = False override(context_block).time_signature.break_visibility = \ schemetools.Scheme('end-of-line-invisible') override(context_block).time_signature.font_size = font_size override(context_block).time_signature.self_alignment_X = \ schemetools.Scheme('center') spacing_vector = layouttools.make_spacing_vector( 0, minimum_distance, padding, 0, ) override(context_block).vertical_axis_group.default_staff_staff_spacing = \ spacing_vector return context_block
def configure_lilypond_file(lilypond_file): r'''Configures LilyPond file. ''' lilypond_file._global_staff_size = 8 context_block = lilypondfiletools.ContextBlock( source_context_name=r'Staff \RemoveEmptyStaves', ) override(context_block).vertical_axis_group.remove_first = True lilypond_file.layout_block.items.append(context_block) slash_separator = indicatortools.LilyPondCommand('slashSeparator') lilypond_file.paper_block.system_separator_markup = slash_separator bottom_margin = lilypondfiletools.LilyPondDimension(0.5, 'in') lilypond_file.paper_block.bottom_margin = bottom_margin top_margin = lilypondfiletools.LilyPondDimension(0.5, 'in') lilypond_file.paper_block.top_margin = top_margin left_margin = lilypondfiletools.LilyPondDimension(0.75, 'in') lilypond_file.paper_block.left_margin = left_margin right_margin = lilypondfiletools.LilyPondDimension(0.5, 'in') lilypond_file.paper_block.right_margin = right_margin paper_width = lilypondfiletools.LilyPondDimension(5.25, 'in') lilypond_file.paper_block.paper_width = paper_width paper_height = lilypondfiletools.LilyPondDimension(7.25, 'in') lilypond_file.paper_block.paper_height = paper_height lilypond_file.header_block.composer = markuptools.Markup('Arvo Pärt') title = 'Cantus in Memory of Benjamin Britten (1980)' lilypond_file.header_block.title = markuptools.Markup(title)
def make_floating_time_signature_lilypond_file(music=None): r'''Makes floating time signature LilyPond file. .. container:: example :: >>> score = Score() >>> time_signature_context = scoretools.Context( ... context_name='TimeSignatureContext', ... ) >>> durations = [(2, 8), (3, 8), (4, 8)] >>> measures = scoretools.make_spacer_skip_measures(durations) >>> time_signature_context.extend(measures) >>> score.append(time_signature_context) >>> staff = Staff() >>> staff.append(Measure((2, 8), "c'8 ( d'8 )")) >>> staff.append(Measure((3, 8), "e'8 ( f'8 g'8 )")) >>> staff.append(Measure((4, 8), "fs'4 ( e'8 d'8 )")) >>> score.append(staff) >>> lilypond_file = \ ... lilypondfiletools.make_floating_time_signature_lilypond_file( ... score ... ) :: >>> print(format(lilypond_file)) # doctest: +SKIP % 2014-01-07 18:22 \version "2.19.0" \language "english" #(set-default-paper-size "letter" 'portrait) #(set-global-staff-size 12) \header {} \layout { \accidentalStyle forget indent = #0 ragged-right = ##t \context { \name TimeSignatureContext \type Engraver_group \consists Axis_group_engraver \consists Time_signature_engraver \override TimeSignature #'X-extent = #'(0 . 0) \override TimeSignature #'X-offset = #ly:self-alignment-interface::x-aligned-on-self \override TimeSignature #'Y-extent = #'(0 . 0) \override TimeSignature #'break-align-symbol = ##f \override TimeSignature #'break-visibility = #end-of-line-invisible \override TimeSignature #'font-size = #1 \override TimeSignature #'self-alignment-X = #center \override VerticalAxisGroup #'default-staff-staff-spacing = #'((basic-distance . 0) (minimum-distance . 12) (padding . 6) (stretchability . 0)) } \context { \Score \remove Bar_number_engraver \accepts TimeSignatureContext \override Beam #'breakable = ##t \override SpacingSpanner #'strict-grace-spacing = ##t \override SpacingSpanner #'strict-note-spacing = ##t \override SpacingSpanner #'uniform-stretching = ##t \override TupletBracket #'bracket-visibility = ##t \override TupletBracket #'minimum-length = #3 \override TupletBracket #'padding = #2 \override TupletBracket #'springs-and-rods = #ly:spanner::set-spacing-rods \override TupletNumber #'text = #tuplet-number::calc-fraction-text autoBeaming = ##f proportionalNotationDuration = #(ly:make-moment 1 32) tupletFullLength = ##t } \context { \StaffGroup } \context { \Staff \remove Time_signature_engraver } \context { \RhythmicStaff \remove Time_signature_engraver } } \paper { left-margin = #20 system-system-spacing = #'((basic-distance . 0) (minimum-distance . 0) (padding . 12) (stretchability . 0)) } \score { \new Score << \new TimeSignatureContext { { \time 2/8 s1 * 1/4 } { \time 3/8 s1 * 3/8 } { \time 4/8 s1 * 1/2 } } \new Staff { { \time 2/8 c'8 ( d'8 ) } { \time 3/8 e'8 ( f'8 g'8 ) } { \time 4/8 fs'4 ( e'8 d'8 ) } } >> } :: >>> show(lilypond_file) # doctest: +SKIP Makes LilyPond file. Wraps `music` in LilyPond ``\score`` block. Adds LilyPond ``\header``, ``\layout``, ``\paper`` and ``\score`` blocks to LilyPond file. Defines layout settings for custom ``\TimeSignatureContext``. (Note that you must create and populate an Abjad context with name equal to ``'TimeSignatureContext'`` in order for ``\TimeSignatureContext`` layout settings to apply.) Applies many file, layout and paper settings. Returns LilyPond file. ''' from abjad.tools import layouttools from abjad.tools import lilypondfiletools lilypond_file = lilypondfiletools.make_basic_lilypond_file(music=music) lilypond_file.default_paper_size = 'letter', 'portrait' lilypond_file.global_staff_size = 12 lilypond_file.paper_block.left_margin = 20 vector = layouttools.make_spacing_vector(0, 0, 12, 0) lilypond_file.paper_block.system_system_spacing = vector #lilypond_file.layout_block.indent = 0 lilypond_file.layout_block.ragged_right = True command = indicatortools.LilyPondCommand('accidentalStyle forget') lilypond_file.layout_block.items.append(command) block = _make_time_signature_context_block(font_size=1, padding=6) lilypond_file.layout_block.items.append(block) context_block = lilypondfiletools.ContextBlock( source_context_name='Score', ) lilypond_file.layout_block.items.append(context_block) context_block.accepts_commands.append('TimeSignatureContext') context_block.remove_commands.append('Bar_number_engraver') override(context_block).beam.breakable = True override(context_block).spacing_spanner.strict_grace_spacing = True override(context_block).spacing_spanner.strict_note_spacing = True override(context_block).spacing_spanner.uniform_stretching = True override(context_block).tuplet_bracket.bracket_visibility = True override(context_block).tuplet_bracket.padding = 2 scheme = schemetools.Scheme('ly:spanner::set-spacing-rods') override(context_block).tuplet_bracket.springs_and_rods = scheme override(context_block).tuplet_bracket.minimum_length = 3 scheme = schemetools.Scheme('tuplet-number::calc-fraction-text') override(context_block).tuplet_number.text = scheme set_(context_block).autoBeaming = False moment = schemetools.SchemeMoment((1, 24)) set_(context_block).proportionalNotationDuration = moment set_(context_block).tupletFullLength = True # provided as a stub position for user customization context_block = lilypondfiletools.ContextBlock( source_context_name='StaffGroup', ) lilypond_file.layout_block.items.append(context_block) context_block = lilypondfiletools.ContextBlock( source_context_name='Staff', ) lilypond_file.layout_block.items.append(context_block) context_block.remove_commands.append('Time_signature_engraver') context_block = lilypondfiletools.ContextBlock( source_context_name='RhythmicStaff', ) lilypond_file.layout_block.items.append(context_block) context_block.remove_commands.append('Time_signature_engraver') return lilypond_file
def make_ligeti_example_lilypond_file(music=None): r'''Makes Ligeti example LilyPond file. Returns LilyPond file. ''' lilypond_file = lilypondfiletools.make_basic_lilypond_file( music=music, default_paper_size=('a4', 'letter'), global_staff_size=14, ) lilypond_file.layout_block.indent = 0 lilypond_file.layout_block.ragged_right = True lilypond_file.layout_block.merge_differently_dotted = True lilypond_file.layout_block.merge_differently_headed = True context_block = lilypondfiletools.ContextBlock( source_context_name='Score', ) lilypond_file.layout_block.items.append(context_block) context_block.remove_commands.append('Bar_number_engraver') context_block.remove_commands.append('Default_bar_line_engraver') context_block.remove_commands.append('Timing_translator') override(context_block).beam.breakable = True override(context_block).glissando.breakable = True override(context_block).note_column.ignore_collision = True override(context_block).spacing_spanner.uniform_stretching = True override(context_block).text_script.staff_padding = 4 override(context_block).text_spanner.breakable = True override(context_block).tuplet_bracket.bracket_visibility = True override(context_block).tuplet_bracket.minimum_length = 3 override(context_block).tuplet_bracket.padding = 2 scheme = schemetools.Scheme('ly:spanner::set-spacing-rods') override(context_block).tuplet_bracket.springs_and_rods = scheme scheme = schemetools.Scheme('tuplet-number::calc-fraction-text') override(context_block).tuplet_number.text = scheme set_(context_block).autoBeaming = False moment = schemetools.SchemeMoment((1, 12)) set_(context_block).proportionalNotationDuration = moment set_(context_block).tupletFullLength = True context_block = lilypondfiletools.ContextBlock( source_context_name='Staff', ) lilypond_file.layout_block.items.append(context_block) # LilyPond CAUTION: Timing_translator must appear # before Default_bar_line_engraver! context_block.consists_commands.append('Timing_translator') context_block.consists_commands.append('Default_bar_line_engraver') scheme = schemetools.Scheme("'numbered") override(context_block).time_signature.style = scheme context_block = lilypondfiletools.ContextBlock( source_context_name='RhythmicStaff', ) lilypond_file.layout_block.items.append(context_block) # LilyPond CAUTION: Timing_translator must appear # before Default_bar_line_engraver! context_block.consists_commands.append('Timing_translator') context_block.consists_commands.append('Default_bar_line_engraver') scheme = schemetools.Scheme("'numbered") override(context_block).time_signature.style = scheme override(context_block).vertical_axis_group.minimum_Y_extent = (-2, 4) context_block = lilypondfiletools.ContextBlock( source_context_name='Voice', ) lilypond_file.layout_block.items.append(context_block) context_block.remove_commands.append('Forbid_line_break_engraver') return lilypond_file
def make_reference_manual_lilypond_file(music=None, **kwargs): r'''Makes reference manual LilyPond file. >>> score = Score([Staff('c d e f')]) >>> lilypond_file = \ ... documentationtools.make_reference_manual_lilypond_file(score) .. doctest:: >>> print(format(lilypond_file)) # doctest: +SKIP \version "2.19.15" \language "english" <BLANKLINE> #(set-global-staff-size 12) <BLANKLINE> \header { tagline = ##f } <BLANKLINE> \layout { indent = #0 ragged-right = ##t \context { \Score \remove Bar_number_engraver \override SpacingSpanner.strict-grace-spacing = ##t \override SpacingSpanner.strict-note-spacing = ##t \override SpacingSpanner.uniform-stretching = ##t \override TupletBracket.bracket-visibility = ##t \override TupletBracket.minimum-length = #3 \override TupletBracket.padding = #2 \override TupletBracket.springs-and-rods = #ly:spanner::set-spacing-rods \override TupletNumber.text = #tuplet-number::calc-fraction-text proportionalNotationDuration = #(ly:make-moment 1 24) tupletFullLength = ##t } } <BLANKLINE> \paper { left-margin = 1\in } <BLANKLINE> \score { \new Score << \new Staff { c4 d4 e4 f4 } >> } Returns LilyPond file. ''' from abjad.tools import lilypondfiletools from abjad.tools import schemetools assert hasattr(music, '__illustrate__') lilypond_file = music.__illustrate__(**kwargs) blocks = [ _ for _ in lilypond_file.items if isinstance(_, lilypondfiletools.Block) ] header_block, layout_block, paper_block = None, None, None for block in blocks: if block.name == 'header': header_block = block elif block.name == 'layout': layout_block = block elif block.name == 'paper': paper_block = block # paper if paper_block is None: paper_block = lilypondfiletools.Block(name='paper') lilypond_file.items.insert(0, paper_block) paper_block.left_margin = lilypondfiletools.LilyPondDimension(1, 'in') # layout if layout_block is None: layout_block = lilypondfiletools.Block(name='layout') lilypond_file.items.insert(0, layout_block) # TODO: following line does nothing; must assign to paper_block instead #lilypond_file.line_width = lilypondfiletools.LilyPondDimension(6, 'in') layout_block.indent = 0 layout_block.ragged_right = True # score context context_block = lilypondfiletools.ContextBlock( source_context_name='Score', ) context_block.remove_commands.append('Bar_number_engraver') override(context_block).spacing_spanner.strict_grace_spacing = True override(context_block).spacing_spanner.strict_note_spacing = True override(context_block).spacing_spanner.uniform_stretching = True override(context_block).tuplet_bracket.bracket_visibility = True override(context_block).tuplet_bracket.padding = 2 scheme = schemetools.Scheme('ly:spanner::set-spacing-rods') override(context_block).tuplet_bracket.springs_and_rods = scheme override(context_block).tuplet_bracket.minimum_length = 3 scheme = schemetools.Scheme('tuplet-number::calc-fraction-text') override(context_block).tuplet_number.text = scheme moment = schemetools.SchemeMoment((1, 24)) set_(context_block).proportionalNotationDuration = moment set_(context_block).tupletFullLength = True layout_block.items.append(context_block) # header if header_block is None: header_block = lilypondfiletools.Block(name='header') lilypond_file.items.insert(0, header_block) header_block.tagline = markuptools.Markup('""') # etc lilypond_file._date_time_token = None lilypond_file._global_staff_size = 12 return lilypond_file
def make_text_alignment_example_lilypond_file(music=None): r'''Makes text-alignment example LilyPond file. >>> score = Score([Staff('c d e f')]) >>> lilypond_file = documentationtools.make_text_alignment_example_lilypond_file(score) .. doctest:: >>> print(format(lilypond_file)) # doctest: +SKIP % Abjad revision 5651 % 2012-05-19 10:04 \version "2.15.37" \language "english" #(set-global-staff-size 18) \layout { indent = #0 ragged-right = ##t \context { \Score \remove Bar_number_engraver \remove Default_bar_line_engraver \override Clef #'transparent = ##t \override SpacingSpanner #'strict-grace-spacing = ##t \override SpacingSpanner #'strict-note-spacing = ##t \override SpacingSpanner #'uniform-stretching = ##t \override TextScript #'staff-padding = #4 proportionalNotationDuration = #(ly:make-moment 1 32) } } \paper { bottom-margin = #10 left-margin = #10 line-width = #150 system-system-spacing = #'( (basic-distance . 0) (minimum-distance . 0) (padding . 15) (stretchability . 0)) } \score { \new Score << \new Staff { c4 d4 e4 f4 } >> } Returns LilyPond file. ''' from abjad.tools import layouttools from abjad.tools import lilypondfiletools from abjad.tools import schemetools lilypond_file = lilypondfiletools.make_basic_lilypond_file(music=music) lilypond_file.global_staff_size = 18 lilypond_file.layout_block.indent = 0 lilypond_file.layout_block.ragged_right = True context_block = lilypondfiletools.ContextBlock( source_context_name='Score', ) lilypond_file.layout_block.items.append(context_block) context_block.remove_commands.append('Bar_number_engraver') context_block.remove_commands.append('Default_bar_line_engraver') override(context_block).clef.transparent = True override(context_block).spacing_spanner.strict_grace_spacing = True override(context_block).spacing_spanner.strict_note_spacing = True override(context_block).spacing_spanner.uniform_stretching = True override(context_block).text_script.staff_padding = 4 override(context_block).time_signature.transparent = True moment = schemetools.SchemeMoment((1, 32)) set_(context_block).proportionalNotationDuration = moment lilypond_file.paper_block.bottom_margin = 10 lilypond_file.paper_block.left_margin = 10 lilypond_file.paper_block.line_width = 150 vector = layouttools.make_spacing_vector(0, 0, 15, 0) lilypond_file.paper_block.system_system_spacing = vector return lilypond_file
def make_reference_manual_lilypond_file(music=None, **kwargs): r'''Makes reference manual LilyPond file. >>> score = Score([Staff('c d e f')]) >>> lilypond_file = \ ... documentationtools.make_reference_manual_lilypond_file(score) .. doctest:: >>> print(format(lilypond_file)) # doctest: +SKIP \version "2.19.15" \language "english" <BLANKLINE> #(set-global-staff-size 12) <BLANKLINE> \header { tagline = \markup {} } <BLANKLINE> \layout { indent = #0 ragged-right = ##t \context { \Score \remove Bar_number_engraver \override SpacingSpanner #'strict-grace-spacing = ##t \override SpacingSpanner #'strict-note-spacing = ##t \override SpacingSpanner #'uniform-stretching = ##t \override TupletBracket #'bracket-visibility = ##t \override TupletBracket #'minimum-length = #3 \override TupletBracket #'padding = #2 \override TupletBracket #'springs-and-rods = #ly:spanner::set-spacing-rods \override TupletNumber #'text = #tuplet-number::calc-fraction-text proportionalNotationDuration = #(ly:make-moment 1 24) tupletFullLength = ##t } } <BLANKLINE> \paper { left-margin = 1\in } <BLANKLINE> \score { \new Score << \new Staff { c4 d4 e4 f4 } >> } Returns LilyPond file. ''' from abjad.tools import lilypondfiletools from abjad.tools import schemetools assert '__illustrate__' in dir(music) lilypond_file = music.__illustrate__(**kwargs) # header lilypond_file.header_block.tagline = markuptools.Markup('""') # layout lilypond_file.layout_block.indent = 0 lilypond_file.line_width = lilypondfiletools.LilyPondDimension(6, 'in') lilypond_file.layout_block.ragged_right = True # paper lilypond_file.paper_block.left_margin = \ lilypondfiletools.LilyPondDimension(1, 'in') # score context context_block = lilypondfiletools.ContextBlock( source_context_name='Score', ) context_block.remove_commands.append('Bar_number_engraver') override(context_block).spacing_spanner.strict_grace_spacing = True override(context_block).spacing_spanner.strict_note_spacing = True override(context_block).spacing_spanner.uniform_stretching = True override(context_block).tuplet_bracket.bracket_visibility = True override(context_block).tuplet_bracket.padding = 2 scheme = schemetools.Scheme('ly:spanner::set-spacing-rods') override(context_block).tuplet_bracket.springs_and_rods = scheme override(context_block).tuplet_bracket.minimum_length = 3 scheme = schemetools.Scheme('tuplet-number::calc-fraction-text') override(context_block).tuplet_number.text = scheme moment = schemetools.SchemeMoment((1, 24)) set_(context_block).proportionalNotationDuration = moment set_(context_block).tupletFullLength = True lilypond_file.layout_block.items.append(context_block) # etc lilypond_file.file_initial_system_comments[:] = [] lilypond_file.global_staff_size = 12 return lilypond_file