def apply_additional_layout(lilypond_file): r'''Configure multiple-voice rhythmic staves in `lilypond_file`. Operates in place and returns none. ''' # configure multiple-voice rhythmic staves for staff in iterationtools.iterate_staves_in_expr(lilypond_file.score_block[0]): if staff.is_simultaneous: assert len(staff) == 2 voice_1 = staff[0] voice_1.override.note_head.Y_offset = 0.5 voice_1.override.stem.direction = Up voice_2 = staff[1] voice_2.override.note_head.Y_offset = -0.5 voice_2.override.stem.direction = Down spacing_vector = layouttools.make_spacing_vector(0, 0, 6, 0) staff.override.vertical_axis_group.staff_staff_spacing = spacing_vector # provide more space between staves with pitched notes for staff in iterationtools.iterate_staves_in_expr(lilypond_file.score_block[0]): if not isinstance(staff, stafftools.RhythmicStaff): for context_block in lilypond_file.layout_block.context_blocks: if context_block.context_name == 'StaffGroup': staff_group_context_block = context_block break else: raise Exception('no staff group context block found.') spacing_vector = layouttools.make_spacing_vector(0, 0, 6, 0) context_block.override.vertical_axis_group.staff_staff_spacing = spacing_vector break
def _make_time_signature_context_block( font_size=3, minimum_distance=12, 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 _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 test_layouttools_make_spacing_vector_01(): spacing_vector = layouttools.make_spacing_vector(0, 0, 12, 0) assert spacing_vector == schemetools.SchemeVector( schemetools.SchemePair('basic-distance', 0), schemetools.SchemePair('minimum-distance', 0), schemetools.SchemePair('padding', 12), schemetools.SchemePair('stretchability', 0))
def make_asset_stylesheet(self, package_name): r"""Makes asset stylesheet. Returns none. """ stylesheet = lilypondfiletools.make_basic_lilypond_file() stylesheet.pop() stylesheet.file_initial_system_comments = [] stylesheet.default_paper_size = "letter", "portrait" stylesheet.global_staff_size = 14 stylesheet.layout_block.indent = 0 stylesheet.layout_block.ragged_right = True stylesheet.paper_block.markup_system_spacing = layouttools.make_spacing_vector(0, 0, 12, 0) stylesheet.paper_block.system_system_spacing = layouttools.make_spacing_vector(0, 0, 10, 0) stylesheet_file_path = os.path.join( self.asset_storehouse_packagesystem_path_in_built_in_asset_library, package_name, "stylesheet.ly" ) stylesheet_file_pointer = file(stylesheet_file_path, "w") stylesheet_file_pointer.write(stylesheet.format) stylesheet_file_pointer.close()
def apply_additional_layout(lilypond_file): r'''Configures multiple-voice rhythmic staves in `lilypond_file`. Operates in place. Returns none. ''' from abjad.tools import layouttools from abjad.tools import lilypondfiletools from abjad.tools import scoretools from abjad.tools import topleveltools # configure multiple-voice rhythmic staves for staff in topleveltools.iterate( lilypond_file.score_block.items[0]).by_class(scoretools.Staff): if staff.is_simultaneous: assert len(staff) == 2 voice_1 = staff[0] topleveltools.override(voice_1).note_head.Y_offset = 0.5 topleveltools.override(voice_1).stem.direction = Up voice_2 = staff[1] topleveltools.override(voice_2).note_head.Y_offset = -0.5 topleveltools.override(voice_2).stem.direction = Down spacing_vector = layouttools.make_spacing_vector(0, 0, 6, 0) manager = topleveltools.override(staff) manager.vertical_axis_group.staff_staff_spacing = spacing_vector # provide more space between staves with pitched notes for staff in topleveltools.iterate( lilypond_file.score_block.items[0]).by_class(scoretools.Staff): if not (isinstance(staff, scoretools.Staff) and staff.context_name == 'RhythmicStaff'): for item in lilypond_file.layout_block.items: if isinstance(item, lilypondfiletools.ContextBlock): if item.source_context_name == 'StaffGroup': break else: message = 'no staff group context block found.' raise Exception(message) spacing_vector = layouttools.make_spacing_vector(0, 0, 6, 0) manager = topleveltools.override(item) manager.vertical_axis_group.staff_staff_spacing = spacing_vector break
def apply_additional_layout(lilypond_file): r'''Configures multiple-voice rhythmic staves in `lilypond_file`. Operates in place. Returns none. ''' from abjad.tools import layouttools from abjad.tools import lilypondfiletools from abjad.tools import scoretools from abjad.tools import topleveltools # configure multiple-voice rhythmic staves for staff in topleveltools.iterate(lilypond_file.score_block.items[0] ).by_class(scoretools.Staff): if staff.is_simultaneous: assert len(staff) == 2 voice_1 = staff[0] topleveltools.override(voice_1).note_head.Y_offset = 0.5 topleveltools.override(voice_1).stem.direction = Up voice_2 = staff[1] topleveltools.override(voice_2).note_head.Y_offset = -0.5 topleveltools.override(voice_2).stem.direction = Down spacing_vector = layouttools.make_spacing_vector(0, 0, 6, 0) manager = topleveltools.override(staff) manager.vertical_axis_group.staff_staff_spacing = spacing_vector # provide more space between staves with pitched notes for staff in topleveltools.iterate( lilypond_file.score_block.items[0]).by_class(scoretools.Staff): if not (isinstance(staff, scoretools.Staff) and staff.context_name == 'RhythmicStaff'): for item in lilypond_file.layout_block.items: if isinstance(item, lilypondfiletools.ContextBlock): if item.source_context_name == 'StaffGroup': break else: message = 'no staff group context block found.' raise Exception(message) spacing_vector = layouttools.make_spacing_vector(0, 0, 6, 0) manager = topleveltools.override(item) manager.vertical_axis_group.staff_staff_spacing = spacing_vector break
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, 32)) 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_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
markuptools.Markup(r'\bold { %s }' % cur_group, 'up')(leaf) cur_group += 1 bar_line = score.add_double_bar() spanner = spannertools.Spanner(voice.leaves) spanner.override.staff.bar_line.stencil = False score.override.bar_number.transparent = True scheme_function = schemetools.SchemeFunction('custom-horizontal-bracket-alignment-callback') score.override.horizontal_bracket.stencil = scheme_function score.override.time_signature.stencil = False score.override.stem.transparent = True score.override.beam.transparent = True score.override.horizontal_bracket.staff_padding = 3 score.override.text_script.staff_padding = 2 score.override.text_script.color = 'blue' contexttools.set_accidental_style_on_sequential_contexts_in_expr(score, 'forget') lilypond_file.default_paper_size = 'letter', 'portrait' lilypond_file.global_staff_size = 16 lilypond_file.file_initial_user_includes.append("/Users/trevorbaca/Documents/other/baca/scm/baca.scm") lilypond_file.header_block.title = 'Turquoise PCs' lilypond_file.header_block.subtitle = '(Las manos mágicas)' lilypond_file.layout_block.indent = 0 lilypond_file.layout_block.ragged_bottom = True lilypond_file.layout_block.ragged_last = True lilypond_file.paper_block.system_system_spacing = layouttools.make_spacing_vector(0, 0, 7, 0) lilypond_file.paper_block.markup_system_spacing = layouttools.make_spacing_vector(0, 0, 7, 0) #show(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_time_signature_context_block( font_size=3, minimum_distance=12, padding=4, ): r'''Make time signature context block: :: >>> context_block = lilypondfiletools.make_time_signature_context_block() .. doctest:: >>> f(context_block) # doctest: +SKIP \context { \type Engraver_group \name TimeSignatureContext \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 = #3 \override TimeSignature #'self-alignment-X = #center \override VerticalAxisGroup #'default-staff-staff-spacing = #'( (basic-distance . 0) (minimum-distance . 0) (padding . 4) (stretchability . 0)) } Returns context block. ''' 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() context_block.type = 'Engraver_group' context_block.engraver_consists.append('Axis_group_engraver') context_block.engraver_consists.append('Time_signature_engraver') context_block.name = 'TimeSignatureContext' context_block.override.time_signature.X_extent = (0, 0) context_block.override.time_signature.X_offset = schemetools.Scheme( 'ly:self-alignment-interface::x-aligned-on-self') context_block.override.time_signature.Y_extent = (0, 0) context_block.override.time_signature.break_align_symbol = False context_block.override.time_signature.break_visibility = \ schemetools.Scheme('end-of-line-invisible') context_block.override.time_signature.font_size = font_size context_block.override.time_signature.self_alignment_X = \ schemetools.Scheme('center') spacing_vector = layouttools.make_spacing_vector( 0, minimum_distance, padding, 0, ) context_block.override.vertical_axis_group.default_staff_staff_spacing = \ spacing_vector return context_block
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_floating_time_signature_lilypond_file(music=None): r'''Make floating time signature LilyPond file from `music`. Function creates a basic LilyPond file. Function then applies many layout settings. View source here for the complete inventory of settings applied. Returns LilyPond file object. ''' 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 lilypond_file.paper_block.system_system_spacing = \ layouttools.make_spacing_vector(0, 0, 12, 0) lilypond_file.layout_block.indent = 0 lilypond_file.layout_block.ragged_right = True lilypond_file.layout_block.append( marktools.LilyPondCommandMark('accidentalStyle forget')) time_signature_context_block = \ lilypondfiletools.make_time_signature_context_block( font_size=1, padding=6) lilypond_file.layout_block.context_blocks.append( time_signature_context_block) context_block = lilypondfiletools.ContextBlock() lilypond_file.layout_block.context_blocks.append(context_block) lilypond_file.score = context_block context_block.context_name = 'Score' context_block.accepts.append('TimeSignatureContext') context_block.engraver_removals.append('Bar_number_engraver') context_block.override.beam.breakable = True context_block.override.spacing_spanner.strict_grace_spacing = True context_block.override.spacing_spanner.strict_note_spacing = True context_block.override.spacing_spanner.uniform_stretching = True context_block.override.tuplet_bracket.bracket_visibility = True context_block.override.tuplet_bracket.padding = 2 context_block.override.tuplet_bracket.springs_and_rods = \ schemetools.Scheme( 'ly:spanner::set-spacing-rods') context_block.override.tuplet_bracket.minimum_length = 3 context_block.override.tuplet_number.text = \ schemetools.Scheme('tuplet-number::calc-fraction-text') context_block.set.autoBeaming = False context_block.set.proportionalNotationDuration = \ schemetools.SchemeMoment((1, 32)) context_block.set.tupletFullLength = True # provided as a stub position for user customization context_block = lilypondfiletools.ContextBlock() lilypond_file.layout_block.context_blocks.append(context_block) context_block.context_name = 'StaffGroup' context_block = lilypondfiletools.ContextBlock() lilypond_file.layout_block.context_blocks.append(context_block) context_block.context_name = 'Staff' context_block.engraver_removals.append('Time_signature_engraver') context_block = lilypondfiletools.ContextBlock() lilypond_file.layout_block.context_blocks.append(context_block) context_block.context_name = 'RhythmicStaff' context_block.engraver_removals.append('Time_signature_engraver') return lilypond_file