예제 #1
0
def make_page(direc, main_staff, drone_staff, inst):
    mfn = inst['name'] + '_main.ly'
    dfn = inst['name'] + '_drone.ly'

    main_group = st.StaffGroup([main_staff])
    drone_group = st.StaffGroup([drone_staff])
    for group in [main_group, drone_group]:
        tlt.override(group).system_start_bracket.collapse_height = 2000

    score1 = st.Score([main_group])
    score2 = st.Score([drone_group])
    for score in [score1, score2]:
        tlt.override(score).staff_grouper.staffgroup_staff_spacing = \
            scht.SchemeAssociativeList(('basic-distance', 30), ('padding', 1))
        tlt.override(score).bar_line.allow_span_bar = False
        tlt.override(score).system_start_bar.collapse_height = 2000

    mf = lyft.make_basic_lilypond_file(score1)
    df = lyft.make_basic_lilypond_file(score2)

    for fn, lf in zip([mfn, dfn], [mf, df]):
        lf.header_block.composer = "Danny Clarke"
        lf.header_block.instrument = scht.Scheme(inst['name'], quoting="'")
        with open(direc + '/' + fn, 'w+') as f:
            f.write(format(lf))
    return mfn, dfn
def insert_expr_into_lilypond_file(expr, tagline=False):
    r'''Inserts `expr` into LilyPond file.

    Returns LilyPond file.
    '''
    from abjad.tools import contexttools

    if isinstance(expr, lilypondfiletools.LilyPondFile):
        lilypond_file = expr
    elif isinstance(expr, contexttools.Context):
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(expr)
        lilypond_file._is_temporary = True
    else:
        lilypond_file = lilypondfiletools.make_basic_lilypond_file()
        score_block = lilypondfiletools.ScoreBlock()
        score_block.append(expr)
        # NOTE: don't quite understand the logic here.
        # why append a score_block and then set the score_block attribute
        # to the same thing?
        lilypond_file.append(score_block)
        #lilypond_file.score = score_block
        lilypond_file.score_block = score_block
        lilypond_file._is_temporary = True
    if not tagline:
        try:
            lilypond_file.header_block.tagline = markuptools.Markup('""')
        except:
            pass
    return lilypond_file
예제 #3
0
파일: Segment.py 프로젝트: ajyoon/abjad
    def __illustrate__(self, **kwargs):
        r'''Illustrates segment.

        Returns LilyPond file.
        '''
        from abjad.tools import durationtools
        from abjad.tools import indicatortools
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        from abjad.tools import scoretools
        from abjad.tools import schemetools
        from abjad.tools.topleveltools import attach
        from abjad.tools.topleveltools import override
        from abjad.tools.topleveltools import select
        from abjad.tools.topleveltools import set_
        notes = []
        for item in self:
            note = scoretools.Note(item, durationtools.Duration(1, 8))
            notes.append(note)
        voice = scoretools.Voice(notes)
        staff = scoretools.Staff([voice])
        score = scoretools.Score([staff])
        score.add_final_bar_line()
        override(score).bar_line.transparent = True
        override(score).bar_number.stencil = False
        override(score).beam.stencil = False
        override(score).flag.stencil = False
        override(score).stem.stencil = False
        override(score).time_signature.stencil = False
        string = 'override Score.BarLine.transparent = ##f'
        command = indicatortools.LilyPondCommand(string, format_slot='after')
        last_leaf = select().by_leaf()(score)[-1][-1]
        attach(command, last_leaf)
        moment = schemetools.SchemeMoment((1, 12))
        set_(score).proportional_notation_duration = moment
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(
            global_staff_size=12,
            music=score,
            )
        if 'title' in kwargs:
            title = kwargs.get('title') 
            if not isinstance(title, markuptools.Markup):
                title = markuptools.Markup(title)
            lilypond_file.header_block.title = title
        if 'subtitle' in kwargs:
            markup = markuptools.Markup(kwargs.get('subtitle'))
            lilypond_file.header_block.subtitle = markup
        command = indicatortools.LilyPondCommand('accidentalStyle forget')
        lilypond_file.layout_block.items.append(command)
        lilypond_file.layout_block.indent = 0
        string = 'markup-system-spacing.padding = 8'
        command = indicatortools.LilyPondCommand(string, prefix='')
        lilypond_file.paper_block.items.append(command)
        string = 'system-system-spacing.padding = 10'
        command = indicatortools.LilyPondCommand(string, prefix='')
        lilypond_file.paper_block.items.append(command)
        string = 'top-markup-spacing.padding = 4'
        command = indicatortools.LilyPondCommand(string, prefix='')
        lilypond_file.paper_block.items.append(command)
        return lilypond_file
예제 #4
0
    def __call__(self, configurations_by_class):
        r'''Calls gallery-maker.

        Returns LilyPond file.
        '''
        lilypond_file = lilypondfiletools.make_basic_lilypond_file()
        lilypond_file.items.remove(lilypond_file.header_block)
        lilypond_file.items.remove(lilypond_file.layout_block)
        lilypond_file.items.remove(lilypond_file.paper_block)
        lilypond_file.items.remove(lilypond_file.score_block)
        for class_ in configurations_by_class:
            configurations = configurations_by_class[class_]
            for i, configuration in enumerate(configurations):
                configuration_number = i + 1
                score_blocks = self._configuration_to_score_blocks(
                    configuration,
                    configuration_number,
                )
                first_score_block = score_blocks[0]
                lilypond_file.items.extend(score_blocks)
                string = r'\pageBreak'
                lilypond_file.items.append(string)
        assert lilypond_file.items[-1] == string
        lilypond_file.items.pop(-1)
        lilypond_file.includes.append('stylesheet.ily')
        return lilypond_file
예제 #5
0
    def __illustrate__(self):
        r'''Illustrates markup.

        ..  container:: example

            ::

                >>> string = r'\bold { allegro ma non troppo }'
                >>> markup = Markup(string)
                >>> show(markup) # doctest: +SKIP

            ..  doctest::

                >>> lilypond_file = markup.__illustrate__()
                >>> markup = lilypond_file.items[-1]
                >>> print(format(markup))
                \markup {
                    \bold
                        {
                            allegro
                            ma
                            non
                            troppo
                        }
                    }

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        lilypond_file = lilypondfiletools.make_basic_lilypond_file()
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        lilypond_file.items.append(self)
        return lilypond_file
예제 #6
0
 def __illustrate__(self):
     score = self()
     time_signatures = [
         (3, 4), (7, 8), (2, 4), (5, 16),
         (4, 4), (6, 8), (5, 4), (3, 8),
         (3, 4), (7, 8), (2, 4), (5, 16),
         ]
     for voice in iterate(score).by_class(scoretools.Voice):
         for pair in time_signatures:
             rest = scoretools.MultimeasureRest(1)
             attach(Multiplier(pair), rest)
             voice.append(rest)
     for pair in time_signatures:
         skip = scoretools.Skip(1)
         attach(Multiplier(pair), skip)
         score['Time Signature Context'].append(skip)
         attach(
             indicatortools.TimeSignature(pair),
             skip,
             scope=scoretools.Score,
             )
     module = importlib.import_module(type(self).__module__)
     score_path = pathlib.Path(module.__file__).parent.parent
     stylesheet_path = score_path.joinpath('stylesheets', 'stylesheet.ily')
     stylesheet_path = stylesheet_path.resolve()
     lilypond_file = lilypondfiletools.make_basic_lilypond_file(
         score,
         includes=[str(stylesheet_path)],
         use_relative_includes=True,
         )
     return lilypond_file
예제 #7
0
    def __illustrate__(self):
        r'''Illustrates pitch segment.

        ::

            >>> named_pitch_segment = pitchtools.PitchSegment(
            ...     ['bf,', 'aqs', "fs'", "g'", 'bqf', "g'"],
            ...     item_class=NamedPitch,
            ...     )
            >>> show(named_pitch_segment) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import durationtools
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        from abjad.tools import pitchtools
        from abjad.tools import scoretools
        from abjad.tools import spannertools
        from abjad.tools.topleveltools import attach
        from abjad.tools.topleveltools import iterate
        from abjad.tools.topleveltools import override
        named_pitches = [pitchtools.NamedPitch(x) for x in self]
        notes = scoretools.make_notes(named_pitches, [1])
        score, treble_staff, bass_staff = \
            scoretools.make_piano_sketch_score_from_leaves(notes)
        for leaf in iterate(score).by_class(scoretools.Leaf):
            attach(durationtools.Multiplier(1, 8), leaf)
        override(score).rest.transparent = True
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        return lilypond_file
예제 #8
0
    def __illustrate__(self, **kwargs):
        r'''Illustrates segment.

        Returns LilyPond file.
        '''
        from abjad.tools import durationtools
        from abjad.tools import indicatortools
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        from abjad.tools import scoretools
        from abjad.tools import schemetools
        from abjad.tools.topleveltools import attach
        from abjad.tools.topleveltools import override
        from abjad.tools.topleveltools import select
        from abjad.tools.topleveltools import set_
        notes = []
        for item in self:
            note = scoretools.Note(item, durationtools.Duration(1, 8))
            notes.append(note)
        voice = scoretools.Voice(notes)
        staff = scoretools.Staff([voice])
        score = scoretools.Score([staff])
        score.add_final_bar_line()
        override(score).bar_line.transparent = True
        override(score).bar_number.stencil = False
        override(score).beam.stencil = False
        override(score).flag.stencil = False
        override(score).stem.stencil = False
        override(score).time_signature.stencil = False
        string = 'override Score.BarLine.transparent = ##f'
        command = indicatortools.LilyPondCommand(string, format_slot='after')
        last_leaf = select().by_leaf()(score)[-1][-1]
        attach(command, last_leaf)
        moment = schemetools.SchemeMoment((1, 12))
        set_(score).proportional_notation_duration = moment
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(
            global_staff_size=12,
            music=score,
        )
        if 'title' in kwargs:
            title = kwargs.get('title')
            if not isinstance(title, markuptools.Markup):
                title = markuptools.Markup(title)
            lilypond_file.header_block.title = title
        if 'subtitle' in kwargs:
            markup = markuptools.Markup(kwargs.get('subtitle'))
            lilypond_file.header_block.subtitle = markup
        command = indicatortools.LilyPondCommand('accidentalStyle forget')
        lilypond_file.layout_block.items.append(command)
        lilypond_file.layout_block.indent = 0
        string = 'markup-system-spacing.padding = 8'
        command = indicatortools.LilyPondCommand(string, prefix='')
        lilypond_file.paper_block.items.append(command)
        string = 'system-system-spacing.padding = 10'
        command = indicatortools.LilyPondCommand(string, prefix='')
        lilypond_file.paper_block.items.append(command)
        string = 'top-markup-spacing.padding = 4'
        command = indicatortools.LilyPondCommand(string, prefix='')
        lilypond_file.paper_block.items.append(command)
        return lilypond_file
예제 #9
0
    def __illustrate__(self):
        r'''Attempts to illustrate selection.

        Evaluates the storage format of the selection (to sever any references
        to the source score from which the selection was taken). Then tries to
        wrap the result in a staff; in the case that notes of only C4 are found
        then sets the staff context name to ``'RhythmicStaff'``. If this works
        then the staff is wrapped in a LilyPond file and the file is returned.
        If this doesn't work then the method raises an exception.

        The idea is that the illustration should work for simple selections of
        that represent an essentially contiguous snippet of a single voice of
        music.

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        from abjad.tools import pitchtools
        from abjad.tools import scoretools
        from abjad.tools.topleveltools import mutate
        music = mutate(self).copy()
        staff = scoretools.Staff(music)
        found_different_pitch = False
        for pitch in pitchtools.list_named_pitches_in_expr(staff):
            if pitch != pitchtools.NamedPitch("c'"):
                found_different_pitch = True
                break
        if not found_different_pitch:
            staff.context_name = 'RhythmicStaff'
        score = scoretools.Score([staff])
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        return lilypond_file
예제 #10
0
파일: Markup.py 프로젝트: jefftrevino/abjad
    def __illustrate__(self):
        r"""Illustrates markup.

        ..  container:: example

            ::

                >>> string = r'\bold { allegro ma non troppo }'
                >>> markup = Markup(string)
                >>> show(markup) # doctest: +SKIP

            ..  doctest::

                >>> lilypond_file = markup.__illustrate__()
                >>> markup = lilypond_file.items[-1]
                >>> print(format(markup))
                \markup {
                    \bold
                        {
                            allegro
                            ma
                            non
                            troppo
                        }
                    }

        Returns LilyPond file.
        """
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools

        lilypond_file = lilypondfiletools.make_basic_lilypond_file()
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        lilypond_file.items.append(self)
        return lilypond_file
예제 #11
0
파일: Selection.py 프로젝트: DnMllr/abjad
    def __illustrate__(self):
        r'''Attempts to illustrate selection.

        Evaluates the storage format of the selection (to sever any references
        to the source score from which the selection was taken). Then tries to
        wrap the result in a staff; in the case that notes of only C4 are found
        then sets the staff context name to ``'RhythmicStaff'``. If this works
        then the staff is wrapped in a LilyPond file and the file is returned.
        If this doesn't work then the method raises an exception.

        The idea is that the illustration should work for simple selections of
        that represent an essentially contiguous snippet of a single voice of
        music.

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        from abjad.tools import pitchtools
        from abjad.tools import scoretools
        from abjad.tools.topleveltools import mutate
        music = mutate(self).copy()
        staff = scoretools.Staff(music)
        found_different_pitch = False
        for pitch in pitchtools.list_named_pitches_in_expr(staff):
            if pitch != pitchtools.NamedPitch("c'"):
                found_different_pitch = True
                break
        if not found_different_pitch:
            staff.context_name = 'RhythmicStaff'
        score = scoretools.Score([staff])
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        return lilypond_file
예제 #12
0
 def _gallery_input_to_lilypond_file(self):
     from abjad.tools import lilypondfiletools
     from abjad.tools import markuptools
     lilypond_file = lilypondfiletools.make_basic_lilypond_file()
     lilypond_file.items.remove(lilypond_file.score_block)
     title_markup = self._make_gallery_title_markup()
     lilypond_file.header_block.title = title_markup
     markups = []
     scores = []
     for block in self._gallery_input_blocks:
         score = self._gallery_input_block_to_score(block)
         if not inspect(score).is_well_formed():
             message = 'score is not well-formed: {!r}.'
             message = message.format(score)
             message += '\n'
             message += inspect(score).tabulate_well_formedness_violations()
             raise Exception(message)
         scores.append(score)
         markup = block._to_markup(type(self))
         markups.append(markup)
     for markup, score in zip(markups, scores):
         lilypond_file.items.append(markup)
         lilypond_file.items.append(score)
     lilypond_file.default_paper_size = ('letter', 'portrait')
     lilypond_file.global_staff_size = 10
     lilypond_file.use_relative_includes = True
     stylesheet_path = os.path.join(
         '..', '..', '..', 
         'stylesheets', 
         'gallery-layout.ly',
         )
     lilypond_file.file_initial_user_includes.append(stylesheet_path)
     lilypond_file.paper_block.tagline = markuptools.Markup('')
     return lilypond_file
예제 #13
0
 def _make_lilypond_file(self):
     template = templatetools.TwoStaffPianoScoreTemplate()
     score = template()
     self._score = score
     self._add_time_signature_context(score)
     rh_voice = score['RH Voice']
     lh_voice = score['LH Voice']
     self._populate_rhythms(rh_voice, self.rh_rhythm_maker)
     self._populate_rhythms(lh_voice, self.lh_rhythm_maker)
     self._populate_pitches(rh_voice, self.rh_pitch_range)
     self._populate_pitches(lh_voice, self.lh_pitch_range)
     stylesheet_path = os.path.join(
         '..',
         '..',
         'stylesheets',
         'stylesheet.ily',
         )
     lilypond_file = lilypondfiletools.make_basic_lilypond_file(
         music=score,
         includes=(
             stylesheet_path,
             ),
         use_relative_includes=True,
         )
     return lilypond_file
예제 #14
0
    def __call__(self, configurations_by_class):
        r'''Calls gallery-maker.

        Returns LilyPond file.
        '''
        lilypond_file = lilypondfiletools.make_basic_lilypond_file()
        lilypond_file.items.remove(lilypond_file.header_block)
        lilypond_file.items.remove(lilypond_file.layout_block)
        lilypond_file.items.remove(lilypond_file.paper_block)
        lilypond_file.items.remove(lilypond_file.score_block)
        for class_ in configurations_by_class:
            configurations = configurations_by_class[class_]
            for i, configuration in enumerate(configurations):
                configuration_number = i + 1
                score_blocks = self._configuration_to_score_blocks(
                    configuration,
                    configuration_number,
                    )
                first_score_block = score_blocks[0]
                lilypond_file.items.extend(score_blocks)
                string = r'\pageBreak'
                lilypond_file.items.append(string)
        assert lilypond_file.items[-1] == string
        lilypond_file.items.pop(-1)
        lilypond_file.includes.append('stylesheet.ily')
        return lilypond_file
예제 #15
0
파일: PitchSegment.py 프로젝트: odub/abjad
    def __illustrate__(self):
        r'''Illustrates pitch segment.

        ::

            >>> named_pitch_segment = pitchtools.PitchSegment(
            ...     ['bf,', 'aqs', "fs'", "g'", 'bqf', "g'"],
            ...     item_class=NamedPitch,
            ...     )
            >>> show(named_pitch_segment) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import durationtools
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        from abjad.tools import pitchtools
        from abjad.tools import scoretools
        from abjad.tools.topleveltools import attach
        from abjad.tools.topleveltools import iterate
        from abjad.tools.topleveltools import override
        named_pitches = [pitchtools.NamedPitch(x) for x in self]
        notes = scoretools.make_notes(named_pitches, [1])
        score, treble_staff, bass_staff = \
            scoretools.make_piano_sketch_score_from_leaves(notes)
        for leaf in iterate(score).by_class(scoretools.Leaf):
            attach(durationtools.Multiplier(1, 8), leaf)
        override(score).rest.transparent = True
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        return lilypond_file
예제 #16
0
    def new(
        cls,
        music=None,
        date_time_token=None,
        default_paper_size=None,
        comments=None,
        includes=None,
        global_staff_size=None,
        lilypond_language_token=None,
        lilypond_version_token=None,
        use_relative_includes=None,
        ):
        r'''Makes basic LilyPond file.

        Return LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(
            music=music,
            date_time_token=date_time_token,
            default_paper_size=default_paper_size,
            comments=comments,
            includes=includes,
            global_staff_size=global_staff_size,
            lilypond_language_token=lilypond_language_token,
            lilypond_version_token=lilypond_version_token,
            use_relative_includes=use_relative_includes,
            )
        lilypond_file.header_block.tagline = False
        return lilypond_file
예제 #17
0
    def new(
        cls,
        music=None,
        date_time_token=None,
        default_paper_size=None,
        comments=None,
        includes=None,
        global_staff_size=None,
        lilypond_language_token=None,
        lilypond_version_token=None,
        use_relative_includes=None,
    ):
        r'''Makes basic LilyPond file.

        Return LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(
            music=music,
            date_time_token=date_time_token,
            default_paper_size=default_paper_size,
            comments=comments,
            includes=includes,
            global_staff_size=global_staff_size,
            lilypond_language_token=lilypond_language_token,
            lilypond_version_token=lilypond_version_token,
            use_relative_includes=use_relative_includes,
        )
        lilypond_file.header_block.tagline = False
        return lilypond_file
예제 #18
0
    def __illustrate__(self):
        r'''Illustrates component.

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(self)
        lilypond_file.header_block.tagline = False
        return lilypond_file
예제 #19
0
파일: Component.py 프로젝트: ajyoon/abjad
    def __illustrate__(self):
        r'''Illustrates component.

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(self)
        lilypond_file.header_block.tagline = False
        return lilypond_file
예제 #20
0
    def __illustrate__(self):
        r'''Illustrates pitch range.

        ::

            >>> show(pitch_range) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import durationtools
        from abjad.tools import lilypondfiletools
        from abjad.tools import indicatortools
        from abjad.tools import markuptools
        from abjad.tools import pitchtools
        from abjad.tools import scoretools
        from abjad.tools import spannertools
        from abjad.tools.topleveltools import attach
        from abjad.tools.topleveltools import iterate
        from abjad.tools.topleveltools import override
        start_pitch_clef = pitchtools.suggest_clef_for_named_pitches(
            self.start_pitch)
        stop_pitch_clef = pitchtools.suggest_clef_for_named_pitches(
            self.stop_pitch)
        start_note = scoretools.Note(self.start_pitch, 1)
        stop_note = scoretools.Note(self.stop_pitch, 1)
        glissando = spannertools.Glissando()
        if start_pitch_clef == stop_pitch_clef:
            if start_pitch_clef == indicatortools.Clef('bass'):
                bass_staff = scoretools.Staff()
                attach(indicatortools.Clef('bass'), bass_staff)
                bass_staff.extend([start_note, stop_note])
                attach(glissando, bass_staff.select_leaves())
                score = scoretools.Score([bass_staff])
            else:
                treble_staff = scoretools.Staff()
                attach(indicatortools.Clef('treble'), treble_staff)
                treble_staff.extend([start_note, stop_note])
                attach(glissando, treble_staff.select_leaves())
                score = scoretools.Score([treble_staff])
        else:
            result = scoretools.make_empty_piano_score()
            score, treble_staff, bass_staff = result
            bass_staff.extend([start_note, stop_note])
            treble_staff.extend(scoretools.Skip(1) * 2)
            attach(glissando, bass_staff.select_leaves())
            attach(indicatortools.StaffChange(treble_staff), bass_staff[1])
        for leaf in iterate(score).by_class(scoretools.Leaf):
            attach(durationtools.Multiplier(1, 4), leaf)
        override(score).bar_line.stencil = False
        override(score).span_bar.stencil = False
        override(score).glissando.thickness = 2
        override(score).time_signature.stencil = False
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        return lilypond_file
예제 #21
0
 def _insert_expr_into_lilypond_file(expr, tagline=False):
     from abjad.tools import lilypondfiletools
     from abjad.tools import scoretools
     if isinstance(expr, lilypondfiletools.LilyPondFile):
         lilypond_file = expr
     elif isinstance(expr, scoretools.Context):
         lilypond_file = lilypondfiletools.make_basic_lilypond_file(expr)
         lilypond_file._is_temporary = True
     else:
         lilypond_file = lilypondfiletools.make_basic_lilypond_file()
         score_block = lilypondfiletools.Block(name='score')
         score_block.items.append(expr)
         lilypond_file.items.append(score_block)
         lilypond_file.score_block = score_block
         lilypond_file._is_temporary = True
     if not tagline:
         try:
             lilypond_file.header_block.tagline = markuptools.Markup('""')
         except:
             pass
     return lilypond_file
예제 #22
0
 def __call__(
     self,
     segment_metadata=None,
     previous_segment_metadata=None,
     ):
     score = self.score_template()
     score['Example Voice'].extend("c'4 ( d'4 e'4 f'4 )")
     lilypond_file = lilypondfiletools.make_basic_lilypond_file(
         score,
         includes=['../../stylesheets/stylesheet.ily'],
         )
     return lilypond_file, segment_metadata
예제 #23
0
def make_lilypond_file(tuplet_duration, row_count, column_count):
    r'''Makes LilyPond file.
    '''

    score = abjad.demos.ferneyhough.make_score(
        tuplet_duration,
        row_count,
        column_count,
    )
    abjad.demos.ferneyhough.configure_score(score)
    lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
    abjad.demos.ferneyhough.configure_lilypond_file(lilypond_file)
    return lilypond_file
예제 #24
0
 def _insert_expr_into_lilypond_file(expr, tagline=False):
     from abjad.tools import lilypondfiletools
     from abjad.tools import markuptools
     from abjad.tools import scoretools
     if isinstance(expr, lilypondfiletools.LilyPondFile):
         lilypond_file = expr
     elif isinstance(expr, scoretools.Context):
         lilypond_file = lilypondfiletools.make_basic_lilypond_file(expr)
         lilypond_file._is_temporary = True
     else:
         lilypond_file = lilypondfiletools.make_basic_lilypond_file()
         score_block = lilypondfiletools.Block(name='score')
         score_block.items.append(expr)
         lilypond_file.items.append(score_block)
         lilypond_file.score_block = score_block
         lilypond_file._is_temporary = True
     if not tagline:
         try:
             lilypond_file.header_block.tagline = markuptools.Markup('""')
         except:
             pass
     return lilypond_file
예제 #25
0
def make_lilypond_file(tuplet_duration, row_count, column_count):
    r'''Makes LilyPond file.
    '''

    score = abjad.demos.ferneyhough.make_score(
        tuplet_duration,
        row_count,
        column_count,
        )
    abjad.demos.ferneyhough.configure_score(score)
    lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
    abjad.demos.ferneyhough.configure_lilypond_file(lilypond_file)
    return lilypond_file
예제 #26
0
    def __illustrate__(self):
        r'''Illustrates tempo inventory.

        ::

            >>> show(inventory) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import durationtools
        from abjad.tools import lilypondfiletools
        from abjad.tools import indicatortools
        from abjad.tools import markuptools
        from abjad.tools import pitchtools
        from abjad.tools import scoretools
        from abjad.tools import spannertools
        from abjad.tools.topleveltools import attach
        from abjad.tools.topleveltools import iterate
        from abjad.tools.topleveltools import override
        from abjad.tools.topleveltools import new
        staff = scoretools.Staff()
        score = scoretools.Score([staff])
        time_signature = indicatortools.TimeSignature((2, 4))
        attach(time_signature, staff)
        # the zero note avoids a lilypond spacing problem:
        # score-initial tempo indications slip to the left
        zero_note = scoretools.Note("c'2")
        staff.append(zero_note)
        command = indicatortools.LilyPondCommand('break')
        attach(command, zero_note)
        for tempo in self.items:
            note = scoretools.Note("c'2")
            attach(tempo, note)
            staff.append(note)
            command = indicatortools.LilyPondCommand('break')
            attach(command, note)
        override(score).bar_line.transparent = True
        override(score).bar_number.stencil = False
        override(score).clef.stencil = False
        override(score).note_head.no_ledgers = True
        override(score).note_head.transparent = True
        override(score).staff_symbol.transparent = True
        override(score).stem.transparent = True
        override(score).time_signature.stencil = False
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
        lilypond_file.layout_block.indent = 0
        lilypond_file.layout_block.ragged_right = True
        lilypond_file.items.remove(lilypond_file['paper'])
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        return lilypond_file
예제 #27
0
 def _make_music(self):
     template = templatetools.TwoStaffPianoScoreTemplate()
     score = template()
     self._score = score
     self._add_time_signature_context(score)
     rh_voice = score['RH Voice']
     lh_voice = score['LH Voice']
     self._populate_rhythms(rh_voice, self.rh_rhythm_maker)
     self._populate_rhythms(lh_voice, self.lh_rhythm_maker)
     self._populate_pitches(rh_voice, self.rh_pitch_range)
     self._populate_pitches(lh_voice, self.lh_pitch_range)
     lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
     self._configure_lilypond_file(lilypond_file)
     return lilypond_file
예제 #28
0
 def _make_lilypond_file(self):
     template = templatetools.TwoStaffPianoScoreTemplate()
     score = template()
     self._score = score
     self._add_time_signature_context(score)
     rh_voice = score['RH Voice']
     lh_voice = score['LH Voice']
     self._populate_rhythms(rh_voice, self.rh_rhythm_maker)
     self._populate_rhythms(lh_voice, self.lh_rhythm_maker)
     self._populate_pitches(rh_voice, self.rh_pitch_range)
     self._populate_pitches(lh_voice, self.lh_pitch_range)
     lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
     self._configure_lilypond_file(lilypond_file)
     return lilypond_file
예제 #29
0
    def __illustrate__(self):
        r'''Illustrates tempo inventory.

        ::

            >>> show(inventory) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import durationtools
        from abjad.tools import lilypondfiletools
        from abjad.tools import indicatortools
        from abjad.tools import markuptools
        from abjad.tools import pitchtools
        from abjad.tools import scoretools
        from abjad.tools import spannertools
        from abjad.tools.topleveltools import attach
        from abjad.tools.topleveltools import iterate
        from abjad.tools.topleveltools import override
        from abjad.tools.topleveltools import new
        staff = scoretools.Staff()
        score = scoretools.Score([staff])
        time_signature = indicatortools.TimeSignature((2, 4))
        attach(time_signature, staff)
        # the zero note avoids a lilypond spacing problem:
        # score-initial tempo indications slip to the left
        zero_note = scoretools.Note("c'2")
        staff.append(zero_note)
        command = indicatortools.LilyPondCommand('break')
        attach(command, zero_note)
        for tempo in self.items:
            note = scoretools.Note("c'2")
            attach(tempo, note)
            staff.append(note)
            command = indicatortools.LilyPondCommand('break')
            attach(command, note)
        override(score).bar_line.transparent = True
        override(score).bar_number.stencil = False
        override(score).clef.stencil = False
        override(score).note_head.no_ledgers = True
        override(score).note_head.transparent = True
        override(score).staff_symbol.transparent = True
        override(score).stem.transparent = True
        override(score).time_signature.stencil = False
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
        lilypond_file.layout_block.indent = 0
        lilypond_file.layout_block.ragged_right = True
        lilypond_file.items.remove(lilypond_file['paper'])
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        return lilypond_file
예제 #30
0
    def __illustrate__(self):
        r'''Illustrates articulation.

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        from abjad.tools import scoretools
        from abjad.tools import topleveltools
        note = scoretools.Note("c'4")
        articulation = copy.copy(self)
        topleveltools.attach(articulation, note)
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(note)
        lilypond_file.header_block.tagline = False
        return lilypond_file
예제 #31
0
    def __illustrate__(self):
        r'''Illustrates articulation.

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        from abjad.tools import scoretools
        from abjad.tools import topleveltools
        note = scoretools.Note("c'4")
        articulation = copy.copy(self)
        topleveltools.attach(articulation, note)
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(note)
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        return lilypond_file
예제 #32
0
    def __illustrate__(self, format_specification=''):
        r'''Formats time signature inventory.

        ::

            >>> show(inventory) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        from abjad.tools import scoretools
        measures = scoretools.make_spacer_skip_measures(self)
        staff = scoretools.RhythmicStaff(measures)
        score = scoretools.Score([staff])
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
        return lilypond_file
예제 #33
0
def make_part_lilypond_file():
    r'''Makes Pärt LilyPond file.
    '''
    score_template = abjad.demos.part.PartCantusScoreTemplate()
    score = score_template()
    abjad.demos.part.add_bell_music_to_score(score)
    abjad.demos.part.add_string_music_to_score(score)
    abjad.demos.part.apply_bowing_marks(score)
    abjad.demos.part.apply_dynamics(score)
    abjad.demos.part.apply_expressive_marks(score)
    abjad.demos.part.apply_page_breaks(score)
    abjad.demos.part.apply_rehearsal_marks(score)
    abjad.demos.part.apply_final_bar_lines(score)
    abjad.demos.part.configure_score(score)
    lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
    abjad.demos.part.configure_lilypond_file(lilypond_file)
    return lilypond_file
예제 #34
0
    def __illustrate__(self, format_specification=''):
        r'''Formats time signature inventory.

        ::

            >>> show(inventory) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        from abjad.tools import scoretools
        measures = scoretools.make_spacer_skip_measures(self)
        staff = scoretools.Staff(measures)
        staff.context_name = 'RhythmicStaff'
        score = scoretools.Score([staff])
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
        return lilypond_file
예제 #35
0
 def __illustrate__(self, scale=None, target_timespan=None, **kwargs):
     target_timespan = target_timespan or timespantools.Timespan(0, 16)
     assert isinstance(target_timespan, timespantools.Timespan)
     assert 0 < target_timespan.duration
     scale = scale or 1.5
     music_specifiers = collections.OrderedDict([
         ('A', 'A music'),
         ('B', 'B music'),
         ('C', 'C music'),
         ('D', 'D music'),
         ('E', 'E music'),
         ('F', 'F music'),
         ('G', 'G music'),
         ('H', 'H music'),
         ('I', 'I music'),
         ('J', 'J music'),
         ])
     timespan_inventory = self(
         layer=0,
         music_specifiers=music_specifiers,
         target_timespan=target_timespan,
         )
     ti_lilypond_file = timespan_inventory.__illustrate__(
         key='voice_name',
         range_=target_timespan,
         scale=scale,
         )
     ti_markup = ti_lilypond_file.items[-1]
     offset_counter = metertools.OffsetCounter(timespan_inventory)
     oc_lilypond_file = offset_counter.__illustrate__(
         range_=target_timespan,
         scale=scale,
         )
     oc_markup = oc_lilypond_file.items[-1]
     lilypond_file = lilypondfiletools.make_basic_lilypond_file(
         default_paper_size=['tabloid', 'landscape'],
         date_time_token=False,
         )
     lilypond_file.items.extend([
         ti_markup,
         markuptools.Markup.null().pad_around(2),
         oc_markup,
         ])
     lilypond_file.header_block.tagline = False
     return lilypond_file
예제 #36
0
def make_mozart_lilypond_file():
    r'''Makes Mozart LilyPond file.
    '''

    score = abjad.demos.mozart.make_mozart_score()
    lily = lilypondfiletools.make_basic_lilypond_file(
        music=score,
        global_staff_size=12,
        )
    title = markuptools.Markup(r'\bold \sans "Ein Musikalisches Wuerfelspiel"')
    composer = schemetools.Scheme("W. A. Mozart (maybe?)")
    lily.header_block.title = title
    lily.header_block.composer = composer
    lily.layout_block.ragged_right = True
    lily.paper_block.markup_system_spacing = schemetools.SchemeAssociativeList(
        ('basic_distance', 8),
        )
    lily.paper_block.paper_width = 180
    return lily
    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()
예제 #38
0
    def __illustrate__(self, **kwargs):
        r'''Illustrates pitch-class tree.

        Returns LilyPond file.
        '''
        from abjad import abjad_configuration
        from abjad.tools import indicatortools
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        from abjad.tools import scoretools
        from abjad.tools.topleveltools import override
        voice = scoretools.Voice()
        staff = scoretools.Staff([voice])
        score = scoretools.Score([staff])
        stylesheet = os.path.join(
            abjad_configuration.abjad_directory,
            'stylesheets',
            'rhythm-letter-16.ily',
            )
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(
            music=score,
            includes=[stylesheet],
            )
        voice.consists_commands.append('Horizontal_bracket_engraver')
        leaf_list_stack = []
        self._bracket_inner_nodes(leaf_list_stack, self, voice)
        score.add_final_bar_line()
        override(score).bar_line.stencil = False
        override(score).flag.stencil = False
        override(score).stem.stencil = False
        override(score).text_script.staff_padding = 3
        override(score).time_signature.stencil = False
        if 'title' in kwargs:
            markup = markuptools.Markup(kwargs.get('title'))
            lilypond_file.header_block.title = markup
        if 'subtitle' in kwargs:
            markup = markuptools.Markup(kwargs.get('subtitle'))
            lilypond_file.header_block.subtitle = markup
        command = indicatortools.LilyPondCommand('accidentalStyle forget')
        lilypond_file.layout_block.items.append(command)
        return lilypond_file
예제 #39
0
    def __illustrate__(self):
        r'''Illustrates markup inventory.

        ..  container:: example

            ::

                >>> inventory = markuptools.MarkupInventory(['foo', 'bar'])
                >>> show(inventory) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        lilypond_file = lilypondfiletools.make_basic_lilypond_file()
        for name in ('layout', 'paper', 'score'):
            block = lilypond_file[name]
            lilypond_file.items.remove(block)
        lilypond_file.header_block.tagline = False
        for item in self:
            lilypond_file.items.append(item)
        return lilypond_file
예제 #40
0
    def __illustrate__(self):
        r'''Illustrates markup inventory.

        ..  container:: example

            ::

                >>> inventory = markuptools.MarkupInventory(['foo', 'bar'])
                >>> show(inventory) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        lilypond_file = lilypondfiletools.make_basic_lilypond_file()
        for name in ('layout', 'paper', 'score'):
            block = lilypond_file[name]
            lilypond_file.items.remove(block)
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        for item in self:
            lilypond_file.items.append(item)
        return lilypond_file
def save_composition(name: str, agent_name: str, composition: CompositionEnvironment, out_dir: str):
    score = Score()
    staff_group = scoretools.StaffGroup([], context_name='StaffGroup')

    for voice in composition.voices + composition.given_voices:
        staff = Staff([voice])
        if voice.name == "cantus":
            attach(Clef("alto"), staff)
        attach(composition.composition_parameters.scale.key_signature, staff)

        staff_group.append(staff)
    tempo = Tempo(Duration(4, 4), 60)
    attach(tempo, staff_group[0])
    score.append(staff_group)
    score.add_final_bar_line()

    lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
    lilypond_file.header_block.composer = markuptools.Markup(agent_name)
    lilypond_file.header_block.title = markuptools.Markup(name)
    lilypond_file.header_block.tagline = markuptools.Markup()

    midi_block = lilypondfiletools.Block(name="midi")
    context_block = lilypondfiletools.Block(name="context")
    channel_mapping = lilypondfiletools.Block(name="score")

    # channel_mapping.midiChannelMapping = "instrument"
    # context_block.items.append(channel_mapping)
    # midi_block.items.append(context_block)

    lilypond_file.score_block.items.append(midi_block)
    layout_block = lilypondfiletools.Block(name="layout")
    lilypond_file.score_block.items.append(layout_block)

    filename = name + ".ly"
    if not os.path.exists(out_dir):
        os.makedirs(out_dir)
    out_path = os.path.join(out_dir, filename)
    with open(out_path, mode="w") as f:
        f.write(format(lilypond_file))
예제 #42
0
    def __illustrate__(self, **kwargs):
        r'''Illustrates pitch-class tree.

        Returns LilyPond file.
        '''
        from abjad import abjad_configuration
        from abjad.tools import indicatortools
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        from abjad.tools import scoretools
        from abjad.tools.topleveltools import override
        voice = scoretools.Voice()
        staff = scoretools.Staff([voice])
        score = scoretools.Score([staff])
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
        stylesheet = os.path.join(
            abjad_configuration.abjad_directory,
            'stylesheets',
            'rhythm-letter-16.ily',
            )
        lilypond_file.file_initial_user_includes.append(stylesheet)
        voice.consists_commands.append('Horizontal_bracket_engraver')
        leaf_list_stack = []
        self._bracket_inner_nodes(leaf_list_stack, self, voice)
        score.add_final_bar_line()
        override(score).bar_line.stencil = False
        override(score).flag.stencil = False
        override(score).stem.stencil = False
        override(score).text_script.staff_padding = 3
        override(score).time_signature.stencil = False
        if 'title' in kwargs:
            markup = markuptools.Markup(kwargs.get('title'))
            lilypond_file.header_block.title = markup
        if 'subtitle' in kwargs:
            markup = markuptools.Markup(kwargs.get('subtitle'))
            lilypond_file.header_block.subtitle = markup
        command = indicatortools.LilyPondCommand('accidentalStyle forget')
        lilypond_file.layout_block.items.append(command)
        return lilypond_file
예제 #43
0
 def _make_lilypond_file(self):
     template = templatetools.TwoStaffPianoScoreTemplate()
     score = template()
     self._score = score
     self._add_time_signature_context(score)
     rh_voice = score['RH Voice']
     lh_voice = score['LH Voice']
     self._populate_rhythms(rh_voice, self.rh_rhythm_maker)
     self._populate_rhythms(lh_voice, self.lh_rhythm_maker)
     self._populate_pitches(rh_voice, self.rh_pitch_range)
     self._populate_pitches(lh_voice, self.lh_pitch_range)
     stylesheet_path = os.path.join(
         '..',
         '..',
         'stylesheets',
         'stylesheet.ily',
     )
     lilypond_file = lilypondfiletools.make_basic_lilypond_file(
         music=score,
         includes=(stylesheet_path, ),
         use_relative_includes=True,
     )
     return lilypond_file
예제 #44
0
    def __illustrate__(self):
        r'''Illustrates clef inventory.

        ::

            >>> show(inventory) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        from abjad.tools import scoretools
        staff = scoretools.Staff()
        for clef in self:
            rest = scoretools.Rest((1, 8))
            clef = copy.copy(clef)
            attach(clef, rest)
            staff.append(rest)
        override(staff).clef.full_size_change = True
        override(staff).rest.transparent = True
        override(staff).time_signature.stencil = False
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(staff)
        lilypond_file.header_block.tagline = False
        return lilypond_file
예제 #45
0
    def __illustrate__(self):
        r'''Illustrates pitch.

        Returns LilyPond file.
        '''
        from abjad.tools import durationtools
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        from abjad.tools import pitchtools
        from abjad.tools import scoretools
        from abjad.tools.topleveltools import attach
        from abjad.tools.topleveltools import override
        pitch = pitchtools.NamedPitch(self)
        note = scoretools.Note(pitch, 1)
        attach(durationtools.Multiplier(1, 4), note)
        clef = pitchtools.suggest_clef_for_named_pitches([pitch])
        staff = scoretools.Staff()
        attach(clef, staff)
        staff.append(note)
        override(staff).time_signature.stencil = False
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(staff)
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        return lilypond_file
예제 #46
0
파일: Pitch.py 프로젝트: adorsk/abjad
    def __illustrate__(self):
        r'''Illustrates pitch.

        Returns LilyPond file.
        '''
        from abjad.tools import durationtools
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        from abjad.tools import pitchtools
        from abjad.tools import scoretools
        from abjad.tools.topleveltools import attach
        from abjad.tools.topleveltools import override
        pitch = pitchtools.NamedPitch(self)
        note = scoretools.Note(pitch, 1)
        attach(durationtools.Multiplier(1, 4), note)
        clef = pitchtools.suggest_clef_for_named_pitches([pitch])
        staff = scoretools.Staff()
        attach(clef, staff)
        staff.append(note)
        override(staff).time_signature.stencil = False
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(staff)
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        return lilypond_file
예제 #47
0
    def __illustrate__(self):
        r'''Illustrates clef inventory.

        ::

            >>> show(inventory) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        from abjad.tools import scoretools
        staff = scoretools.Staff()
        for clef in self:
            rest = scoretools.Rest((1, 8))
            clef = copy.copy(clef)
            attach(clef, rest)
            staff.append(rest)
        override(staff).clef.full_size_change = True
        override(staff).rest.transparent = True
        override(staff).time_signature.stencil = False
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(staff)
        lilypond_file.header_block.tagline = False
        return lilypond_file
예제 #48
0
파일: make_ly_file.py 프로젝트: odub/vln
def make_ly_file(content):
    """
    Returns a LilyPondFile instance with configuration for the piece.

    >>> from abjad import *
    >>> make_ly_file("c'4")
    <LilyPondFile(4)>
    """
    lilypond_file = lilypondfiletools.make_basic_lilypond_file(content)
    includes_path = os.path.join(
        vln.__path__[0],
        'ly',
        'includes.ly',
    )
    duration_line_voice_context = lilypondfiletools.ContextBlock('Voice')
    override(duration_line_voice_context).glissando.breakable = False
    override(duration_line_voice_context).glissando.stencil = schemetools.Scheme(
        '(flat-gliss #\'0.23)',
        verbatim=True,
    )
    override(duration_line_voice_context).stem.stencil = False
    lilypond_file.layout_block.items.append(duration_line_voice_context)
    lilypond_file.file_initial_user_includes.append(includes_path)
    return lilypond_file
예제 #49
0
 def __call__(
     self,
     segment_metadata=None,
     previous_segment_metadata=None,
     ):
     score = self.score_template()
     violin_measures = self._make_measures(
         self.time_signatures,
         self.violin_rhythm_maker,
         self.violin_pitches,
         self.violin_seed,
         )
     score['Violin Voice'].extend(violin_measures)
     viola_measures = self._make_measures(
         self.time_signatures,
         self.viola_rhythm_maker,
         self.viola_pitches,
         self.viola_seed,
         )
     score['Viola Voice'].extend(viola_measures)
     cello_measures = self._make_measures(
         self.time_signatures,
         self.cello_rhythm_maker,
         self.cello_pitches,
         self.cello_seed,
         )
     score['Cello Voice'].extend(cello_measures)
     if self.is_last_segment:
         score.add_final_bar_line('|.', to_each_voice=True)
     else:
         score.add_final_bar_line('||', to_each_voice=True)
     lilypond_file = lilypondfiletools.make_basic_lilypond_file(
         score,
         includes=['../../stylesheets/stylesheet.ily'],
         )
     return lilypond_file, segment_metadata
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_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 lilypondfiletools
    from abjad.tools import schemetools

    lilypond_file = lilypondfiletools.make_basic_lilypond_file(
        music=music,
        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 = schemetools.make_spacing_vector(0, 0, 15, 0)
    lilypond_file.paper_block.system_system_spacing = vector

    return lilypond_file
예제 #52
0
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
예제 #53
0
def make_piano_sketch_score_from_leaves(leaves, lowest_treble_pitch=None):
    r'''Make piano sketch score from `leaves`:

    ::

        >>> notes = scoretools.make_notes(
        ...     [-12, -10, -8, -7, -5, 0, 2, 4, 5, 7],
        ...     [(1, 16)],
        ...     )
        >>> score, treble_staff, bass_staff = \
        ...     scoretools.make_piano_sketch_score_from_leaves(notes)

    ..  doctest::

        >>> print(format(score))
        \new Score \with {
            \override BarLine #'stencil = ##f
            \override BarNumber #'transparent = ##t
            \override SpanBar #'stencil = ##f
            \override TimeSignature #'stencil = ##f
        } <<
            \new PianoStaff <<
                \context Staff = "treble" {
                    \clef "treble"
                    r16
                    r16
                    r16
                    r16
                    r16
                    c'16
                    d'16
                    e'16
                    f'16
                    g'16
                }
                \context Staff = "bass" {
                    \clef "bass"
                    c16
                    d16
                    e16
                    f16
                    g16
                    r16
                    r16
                    r16
                    r16
                    r16
                }
            >>
        >>

    ::

        >>> show(score) # doctest: +SKIP

    When ``lowest_treble_pitch=None`` set to B3.

    Make time signatures and bar numbers transparent.

    Do not print bar lines or span bars.

    Returns score, treble staff, bass staff.
    '''
    from abjad.tools import indicatortools
    from abjad.tools import layouttools
    from abjad.tools import lilypondfiletools
    from abjad.tools import markuptools
    from abjad.tools import pitchtools
    from abjad.tools import scoretools

    if lowest_treble_pitch is None:
        lowest_treble_pitch = pitchtools.NamedPitch('b')

    # make and configure score
    score, treble_staff, bass_staff = \
        scoretools.make_piano_score_from_leaves(leaves, lowest_treble_pitch)
    override(score).time_signature.stencil = False
    override(score).bar_number.transparent = True
    override(score).bar_line.stencil = False
    override(score).span_bar.stencil = False

    # make and configure lily file
    lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
    lilypond_file.layout_block.indent = 0
    lilypond_file.paper_block.tagline = markuptools.Markup('')

    # return score, treble staff, bass staff
    return score, treble_staff, bass_staff
예제 #54
0
    def __illustrate__(self):
        r'''Illustrates metric modulation.

        ..  container:: example

            ::

                >>> metric_modulation = indicatortools.MetricModulation(
                ...     left_rhythm=Tuplet((2, 3), "c'4"),
                ...     right_rhythm=Note("c'4."),
                ...     )
                >>> show(metric_modulation) # doctest: +SKIP

            ..  doctest::

                >>> lilypond_file = metric_modulation.__illustrate__()
                >>> metric_modulation = lilypond_file.items[-1]
                >>> print(format(metric_modulation))
                \markup {
                    \scale
                        #'(0.75 . 0.75)
                        \score
                            {
                                \new Score \with {
                                    \override SpacingSpanner #'spacing-increment = #0.5
                                    proportionalNotationDuration = ##f
                                } <<
                                    \new RhythmicStaff \with {
                                        \remove Time_signature_engraver
                                        \remove Staff_symbol_engraver
                                        \override Stem #'direction = #up
                                        \override Stem #'length = #5
                                        \override TupletBracket #'bracket-visibility = ##t
                                        \override TupletBracket #'direction = #up
                                        \override TupletBracket #'padding = #1.25
                                        \override TupletBracket #'shorten-pair = #'(-1 . -1.5)
                                        \override TupletNumber #'text = #tuplet-number::calc-fraction-text
                                        tupletFullLength = ##t
                                    } {
                                        \tweak #'edge-height #'(0.7 . 0)
                                        \times 2/3 {
                                            c'4
                                        }
                                    }
                                >>
                                \layout {
                                    indent = #0
                                    ragged-right = ##t
                                }
                            }
                    =
                    \hspace
                        #-0.5
                    \scale
                        #'(0.75 . 0.75)
                        \score
                            {
                                \new Score \with {
                                    \override SpacingSpanner #'spacing-increment = #0.5
                                    proportionalNotationDuration = ##f
                                } <<
                                    \new RhythmicStaff \with {
                                        \remove Time_signature_engraver
                                        \remove Staff_symbol_engraver
                                        \override Stem #'direction = #up
                                        \override Stem #'length = #5
                                        \override TupletBracket #'bracket-visibility = ##t
                                        \override TupletBracket #'direction = #up
                                        \override TupletBracket #'padding = #1.25
                                        \override TupletBracket #'shorten-pair = #'(-1 . -1.5)
                                        \override TupletNumber #'text = #tuplet-number::calc-fraction-text
                                        tupletFullLength = ##t
                                    } {
                                        c'4.
                                    }
                                >>
                                \layout {
                                    indent = #0
                                    ragged-right = ##t
                                }
                            }
                    }

        Returns LilyPond file.
        '''
        from abjad.tools import lilypondfiletools
        from abjad.tools import markuptools
        lilypond_file = lilypondfiletools.make_basic_lilypond_file()
        lilypond_file.header_block.tagline = False
        lilypond_file.items.append(self._get_markup())
        return lilypond_file
예제 #55
0
    def __illustrate__(self):
        r'''Illustrates pitch range inventory.

        ::

            >>> show(inventory) # doctest: +SKIP

        Returns LilyPond file.
        '''
        from abjad.tools import durationtools
        from abjad.tools import lilypondfiletools
        from abjad.tools import indicatortools
        from abjad.tools import markuptools
        from abjad.tools import pitchtools
        from abjad.tools import scoretools
        from abjad.tools import spannertools
        from abjad.tools.topleveltools import attach
        from abjad.tools.topleveltools import iterate
        from abjad.tools.topleveltools import override
        start_note_clefs = []
        stop_note_clefs = []
        for pitch_range in self.items:
            start_note_clef = indicatortools.Clef.from_selection(
                pitch_range.start_pitch)
            start_note_clefs.append(start_note_clef)
            stop_note_clef = indicatortools.Clef.from_selection(
                pitch_range.stop_pitch)
            stop_note_clefs.append(stop_note_clef)
        if start_note_clefs == stop_note_clefs:
            clef = start_note_clefs[0]
            staff = scoretools.Staff()
            attach(clef, staff)
            score = scoretools.Score([staff])
            for pitch_range in self.items:
                start_note = scoretools.Note(pitch_range.start_pitch, 1)
                stop_note = scoretools.Note(pitch_range.stop_pitch, 1)
                notes = [start_note, stop_note]
                glissando = spannertools.Glissando()
                staff.extend(notes)
                attach(glissando, notes)
        else:
            result = scoretools.make_empty_piano_score()
            score, treble_staff, bass_staff = result
            for pitch_range in self.items:
                start_note = scoretools.Note(pitch_range.start_pitch, 1)
                start_note_clef = indicatortools.Clef.from_selection(
                    pitch_range.start_pitch)
                stop_note = scoretools.Note(pitch_range.stop_pitch, 1)
                stop_note_clef = indicatortools.Clef.from_selection(
                    pitch_range.stop_pitch)
                notes = [start_note, stop_note]
                glissando = spannertools.Glissando()
                skips = 2 * scoretools.Skip(1)
                treble_clef = indicatortools.Clef('treble')
                bass_clef = indicatortools.Clef('bass')
                if start_note_clef == stop_note_clef == treble_clef:
                    treble_staff.extend(notes)
                    bass_staff.extend(skips)
                elif start_note_clef == stop_note_clef == bass_clef:
                    bass_staff.extend(notes)
                    treble_staff.extend(skips)
                else:
                    assert start_note_clef == bass_clef
                    assert stop_note_clef == treble_clef
                    bass_staff.extend(notes)
                    treble_staff.extend(skips)
                    staff_change = indicatortools.StaffChange(treble_staff)
                    attach(staff_change, stop_note)
                attach(glissando, notes)
        for leaf in iterate(score).by_class(scoretools.Leaf):
            multiplier = durationtools.Multiplier(1, 4)
            attach(multiplier, leaf)
        override(score).bar_line.stencil = False
        override(score).span_bar.stencil = False
        override(score).glissando.thickness = 2
        override(score).time_signature.stencil = False
        lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
        lilypond_file.items.remove(lilypond_file['layout'])
        lilypond_file.items.remove(lilypond_file['paper'])
        lilypond_file.header_block.tagline = markuptools.Markup('""')
        return lilypond_file