Esempio n. 1
0
    def __call__(self):
        r'''Calls string quartet score template.

        Returns score.
        '''

        # make first violin voice and staff
        first_violin_voice = scoretools.Voice(name='First Violin Voice')
        first_violin_staff = scoretools.Staff([first_violin_voice],
                                              name='First Violin Staff')
        clef = indicatortools.Clef('treble')
        attach(clef, first_violin_staff)
        violin = instrumenttools.Violin()
        attach(violin, first_violin_staff)

        # make second violin voice and staff
        second_violin_voice = scoretools.Voice(name='Second Violin Voice')
        second_violin_staff = scoretools.Staff([second_violin_voice],
                                               name='Second Violin Staff')
        clef = indicatortools.Clef('treble')
        attach(clef, second_violin_staff)
        violin = instrumenttools.Violin()
        attach(violin, second_violin_staff)

        # make viola voice and staff
        viola_voice = scoretools.Voice(name='Viola Voice')
        viola_staff = scoretools.Staff([viola_voice], name='Viola Staff')
        clef = indicatortools.Clef('alto')
        attach(clef, viola_staff)
        viola = instrumenttools.Viola()
        attach(viola, viola_staff)

        # make cello voice and staff
        cello_voice = scoretools.Voice(name='Cello Voice')
        cello_staff = scoretools.Staff([cello_voice], name='Cello Staff')
        clef = indicatortools.Clef('bass')
        attach(clef, cello_staff)
        cello = instrumenttools.Cello()
        attach(cello, cello_staff)

        # make string quartet staff group
        string_quartet_staff_group = scoretools.StaffGroup(
            [
                first_violin_staff,
                second_violin_staff,
                viola_staff,
                cello_staff,
            ],
            name='String Quartet Staff Group',
        )

        # make string quartet score
        string_quartet_score = scoretools.Score(
            [string_quartet_staff_group],
            name='String Quartet Score',
        )

        # return string quartet score
        return string_quartet_score
Esempio n. 2
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
Esempio n. 3
0
    def make_spanner_score_02(self):
        r'''Make 200-note voice with durated complex beam spanner
        on every 20 notes.

        ::

            2.12 (r9710) initialization:        250,954 function calls
            2.12 (r9724) initialization:        248,717 function calls

            2.12 (r9703) LilyPond format:       495,768 function calls
            2.12 (r9710) LilyPond format:       496,572 function calls
            2.12 (r9724) LilyPond format:       511,471 function calls

        '''
        from abjad.tools import scoretools
        from abjad.tools import sequencetools
        from abjad.tools import spannertools
        from abjad.tools import topleveltools
        voice = scoretools.Voice(200 * scoretools.Note("c'16"))
        for part in sequencetools.partition_sequence_by_counts(
                voice[:],
            [20],
                cyclic=True,
        ):
            beam = spannertools.DuratedComplexBeam()
            topleveltools.attach(beam, part)
        return voice
Esempio n. 4
0
    def _construct_simultaneous_music(self, music):
        def is_separator(x):
            if isinstance(x, lilypondparsertools.LilyPondEvent):
                if x.name == 'VoiceSeparator':
                    return True
            return False

        from abjad.tools import lilypondparsertools
        container = scoretools.Container()
        container.is_simultaneous = True
        # check for voice separators
        groups = []
        for value, group in itertools.groupby(music, is_separator):
            if not value:
                groups.append(list(group))
        # without voice separators
        if 1 == len(groups):
            #assert all(isinstance(x, scoretools.Context) for x in groups[0])
            container.extend(groups[0])
        # with voice separators
        else:
            for group in groups:
                container.append(
                    scoretools.Voice(
                        self._construct_sequential_music(group)[:]))
        return container
Esempio n. 5
0
    def __call__(self):
        staves = []
        for index in range(self.staff_count):
            number = index + 1
            voice = scoretools.Voice(name='Voice {}'.format(number))
            staff = scoretools.Staff([voice], name='Staff {}'.format(number))
            clef = indicatortools.Clef('bass')
            attach(clef, staff)
            cello = instrumenttools.Cello(
                instrument_name='Cello {}'.format(number),
                short_instrument_name='Vc. {}'.format(number),
            )
            attach(cello, staff)
            override(staff).stem.stemlet_length = 2
            override(staff).beam.damping = '+inf.0'
            staves.append(staff)

        windungen_staff_group = scoretools.StaffGroup(
            staves,
            name='Windungen Staff Group',
        )

        windungen_score = scoretools.Score(
            [windungen_staff_group],
            name='Windungen Score',
        )

        return windungen_score
Esempio n. 6
0
    def make_bound_hairpin_score_03(self):
        r'''Make 200-note voice with p-to-f bound crescendo spanner
        on every 100 notes.

        ::

            2.12 (r9726) initialization:        267,417 function calls

            2.12 (r9726) LilyPond format:       116,534 function calls

        '''
        from abjad.tools import indicatortools
        from abjad.tools import scoretools
        from abjad.tools import sequencetools
        from abjad.tools import spannertools
        from abjad.tools import topleveltools
        voice = scoretools.Voice(200 * scoretools.Note("c'16"))
        for part in sequencetools.partition_sequence_by_counts(
                voice[:],
            [100],
                cyclic=True,
        ):
            crescendo = spannertools.Crescendo()
            topleveltools.attach(crescendo, part)
            dynamic = indicatortools.Dynamic('p')
            topleveltools.attach(dynamic, part[0])
            dynamic = indicatortools.Dynamic('r')
            topleveltools.attach(dynamic, part[-1])
        return voice
Esempio n. 7
0
 def _split_at_measure_boundaries(
     selections,
     meters,
     use_messiaen_style_ties=False,
 ):
     from abjad.tools import metertools
     from abjad.tools import scoretools
     from abjad.tools import sequencetools
     from abjad.tools.topleveltools import inspect_
     from abjad.tools.topleveltools import mutate
     meters = [metertools.Meter(_) for _ in meters]
     durations = [durationtools.Duration(_) for _ in meters]
     music = sequencetools.flatten_sequence(selections)
     assert isinstance(music, list), repr(music)
     total_duration = sum(durations)
     music_duration = sum(inspect_(_).get_duration() for _ in music)
     assert total_duration == music_duration
     voice = scoretools.Voice(music)
     mutate(voice[:]).split(
         durations=durations,
         tie_split_notes=True,
         use_messiaen_style_ties=use_messiaen_style_ties,
     )
     selections = list(voice[:])
     return selections
Esempio n. 8
0
    def make_spanner_score_03(self):
        r'''Make 200-note voice with durated complex beam spanner
        on every 100 notes.

        ::

            2.12 (r9710) initialization:        251,606 function calls
            2.12 (r9724) initialization:        249,369 function calls

            2.12 (r9703) LilyPond format:       509,752 function calls
            2.12 (r9710) LilyPond format:       510,556 function calls
            2.12 (r9724) LilyPond format:       525,463 function calls

        '''
        from abjad.tools import scoretools
        from abjad.tools import sequencetools
        from abjad.tools import spannertools
        from abjad.tools import topleveltools
        voice = scoretools.Voice(200 * scoretools.Note("c'16"))
        for part in sequencetools.partition_sequence_by_counts(
                voice[:],
            [100],
                cyclic=True,
        ):
            beam = spannertools.DuratedComplexBeam()
            topleveltools.attach(beam, part)
        return voice
Esempio n. 9
0
    def make_spanner_score_01(self):
        r'''Make 200-note voice with durated complex beam spanner
        on every 4 notes.

        ::

            2.12 (r9710) initialization:        248,654 function calls
            2.12 (r9724) initialization:        248,660 function calls

            2.12 (r9703) LilyPond format:       425,848 function calls
            2.12 (r9710) LilyPond format:       426,652 function calls
            2.12 (r9724) LilyPond format:       441,884 function calls

        '''
        from abjad.tools import scoretools
        from abjad.tools import sequencetools
        from abjad.tools import spannertools
        from abjad.tools import topleveltools
        voice = scoretools.Voice(200 * scoretools.Note("c'16"))
        for part in sequencetools.partition_sequence_by_counts(
                voice[:],
            [4],
                cyclic=True,
        ):
            beam = spannertools.DuratedComplexBeam()
            topleveltools.attach(beam, part)
        return voice
Esempio n. 10
0
    def make_hairpin_score_03(self):
        r'''Make 200-note voice with crescendo spanner on every 100 notes.

        ::

            2.12 (r9726) initialization:        249,363 function calls
            2.12 (r9726) initialization:        249,363 function calls

            2.12 (r9726) LilyPond format:       133,898 function calls
            2.12 (r9728) LilyPond format:       128,948 function calls

        '''
        from abjad.tools import scoretools
        from abjad.tools import sequencetools
        from abjad.tools import spannertools
        from abjad.tools import topleveltools
        voice = scoretools.Voice(200 * scoretools.Note("c'16"))
        for part in sequencetools.partition_sequence_by_counts(
                voice[:],
            [100],
                cyclic=True,
        ):
            crescendo = spannertools.Crescendo()
            topleveltools.attach(crescendo, part)
        return voice
Esempio n. 11
0
def make_desordre_cell(pitches):
    '''The function constructs and returns a *Désordre cell*.
    `pitches` is a list of numbers or, more generally, pitch tokens.
    '''

    notes = [scoretools.Note(pitch, (1, 8)) for pitch in pitches]
    beam = spannertools.Beam()
    attach(beam, notes)
    slur = spannertools.Slur()
    attach(slur, notes)
    clef = indicatortools.Dynamic('f')
    attach(clef, notes[0])
    dynamic = indicatortools.Dynamic('p')
    attach(dynamic, notes[1])

    # make the lower voice
    lower_voice = scoretools.Voice(notes)
    lower_voice.name = 'RH Lower Voice'
    command = indicatortools.LilyPondCommand('voiceTwo')
    attach(command, lower_voice)
    n = int(math.ceil(len(pitches) / 2.))
    chord = scoretools.Chord([pitches[0], pitches[0] + 12], (n, 8))
    articulation = indicatortools.Articulation('>')
    attach(articulation, chord)

    # make the upper voice
    upper_voice = scoretools.Voice([chord])
    upper_voice.name = 'RH Upper Voice'
    command = indicatortools.LilyPondCommand('voiceOne')
    attach(command, upper_voice)

    # combine them together
    container = scoretools.Container([lower_voice, upper_voice])
    container.is_simultaneous = True

    # make all 1/8 beats breakable
    leaves = select(lower_voice).by_leaf()
    for leaf in leaves[:-1]:
        bar_line = indicatortools.BarLine('')
        attach(bar_line, leaf)

    return container
Esempio n. 12
0
    def __call__(self):
        r'''Calls two-staff piano score template.

        Returns score.
        '''

        # make RH voice and staff
        rh_voice = scoretools.Voice(name='RH Voice')
        rh_staff = scoretools.Staff(
            [rh_voice],
            name='RH Staff',
            )
        clef = indicatortools.Clef('treble')
        attach(clef, rh_staff)

        # make LH voice and staff
        lh_voice = scoretools.Voice(name='LH Voice')
        lh_staff = scoretools.Staff(
            [lh_voice],
            name='LH Staff',
            )
        clef = indicatortools.Clef('bass')
        attach(clef, lh_staff)

        # make piano staff
        staff_group = scoretools.StaffGroup(
            [rh_staff, lh_staff],
            context_name='PianoStaff',
            name='Piano Staff',
            )
        piano = instrumenttools.Piano()
        attach(piano, staff_group)

        # make two-staf piano score
        two_staff_piano_score = scoretools.Score(
            [staff_group],
            name='Two-Staff Piano Score',
            )

        # return two-staff piano score
        return two_staff_piano_score
Esempio n. 13
0
    def __call__(self):
        '''Calls score template.

        ::

            >>> score = template()

        ::

            >>> print(format(score))
            \context Score = "Grouped Staves Score" <<
                \context StaffGroup = "Grouped Staves Staff Group" <<
                    \context Staff = "Staff 1" {
                        \context Voice = "Voice 1" {
                        }
                    }
                    \context Staff = "Staff 2" {
                        \context Voice = "Voice 2" {
                        }
                    }
                    \context Staff = "Staff 3" {
                        \context Voice = "Voice 3" {
                        }
                    }
                    \context Staff = "Staff 4" {
                        \context Voice = "Voice 4" {
                        }
                    }
                >>
            >>

        Returns score.
        '''
        staves = []
        for index in range(self.staff_count):
            number = index + 1
            voice = scoretools.Voice(name='Voice {}'.format(number))
            staff = scoretools.Staff([voice], name='Staff {}'.format(number))
            staves.append(staff)
            self.context_name_abbreviations['v{}'.format(number)] = voice.name
        grouped_rhythmic_staves_staff_group = scoretools.StaffGroup(
            staves,
            name='Grouped Staves Staff Group',
        )
        grouped_rhythmic_staves_score = scoretools.Score(
            [grouped_rhythmic_staves_staff_group],
            name='Grouped Staves Score',
        )
        return grouped_rhythmic_staves_score
 def _split_at_measure_boundaries(
     selections,
     meters,
     use_messiaen_style_ties=False,
 ):
     from abjad.tools import metertools
     from abjad.tools import scoretools
     from abjad.tools import sequencetools
     from abjad.tools.topleveltools import inspect_
     from abjad.tools.topleveltools import mutate
     from abjad.tools.topleveltools import select
     meters = [metertools.Meter(_) for _ in meters]
     durations = [durationtools.Duration(_) for _ in meters]
     selections = sequencetools.flatten_sequence(selections)
     assert isinstance(selections, list), repr(selections)
     meter_duration = sum(durations)
     music_duration = sum(inspect_(_).get_duration() for _ in selections)
     if not meter_duration == music_duration:
         message = 'Duration of meters is {!s}'
         message += ' but duration of selections is {!s}:'
         message = message.format(meter_duration, music_duration)
         message += '\nmeters: {}.'.format(meters)
         message += '\nmusic: {}.'.format(selections)
         raise Exception(message)
     voice = scoretools.Voice(selections)
     mutate(voice[:]).split(
         durations=durations,
         tie_split_notes=True,
         use_messiaen_style_ties=use_messiaen_style_ties,
     )
     #raise Exception(voice)
     #selections = list(voice[:])
     #return selections
     components = mutate(voice).eject_contents()
     component_durations = [inspect_(_).get_duration() for _ in components]
     parts = sequencetools.partition_sequence_by_weights(
         component_durations,
         weights=durations,
         allow_part_weights=Exact,
     )
     part_lengths = [len(_) for _ in parts]
     parts = sequencetools.partition_sequence_by_counts(
         components,
         counts=part_lengths,
         overhang=Exact,
     )
     selections = [select(_) for _ in parts]
     return selections
Esempio n. 15
0
    def make_score_00(self):
        r'''Make 200-note voice (with nothing else).

        ::

            2.12 (r9710) initialization:        156,821 function calls
            2.12 (r9726) initialization:        156,827 function calls

            2.12 (r9703) LilyPond format:        99,127 function calls
            2.12 (r9710) LilyPond format:       100,126 function calls
            2.12 (r9726) LilyPond format:       105,778 function calls

        '''
        from abjad.tools import scoretools
        voice = scoretools.Voice(200 * scoretools.Note("c'16"))
        return voice
Esempio n. 16
0
    def from_selections(cls, selections, time_signatures=None):
        r'''Makes a selection of measures from `selections`.

        Returns selections.
        '''
        from abjad.tools import scoretools
        assert len(selections)
        if not time_signatures:
            time_signatures = [_.get_duration() for _ in selections]
        assert len(selections) == len(time_signatures)
        assert [_.get_duration() for _ in selections] == \
            [durationtools.Duration(_) for _ in time_signatures]
        measures = scoretools.make_spacer_skip_measures(time_signatures)
        temporary_voice = scoretools.Voice(measures)
        mutate(temporary_voice).replace_measure_contents(selections)
        temporary_voice[:] = []
        return measures
Esempio n. 17
0
    def _notate(
        self,
        attach_tempos=True,
        attack_point_optimizer=None,
        grace_handler=None,
    ):
        voice = scoretools.Voice()

        # generate the first
        beat = self.items[0]
        components = beat.q_grid(beat.beatspan)
        if attach_tempos:
            attachment_target = components[0]
            leaves = select(attachment_target).by_leaf()
            if isinstance(attachment_target, scoretools.Container):
                attachment_target = leaves[0]
            tempo = copy.copy(beat.tempo)
            attach(tempo, attachment_target)
        voice.extend(components)

        # generate the rest pairwise, comparing tempi
        for beat_one, beat_two in \
            sequencetools.iterate_sequence_nwise(self.items):
            components = beat_two.q_grid(beat_two.beatspan)
            if (beat_two.tempo != beat_one.tempo) and attach_tempos:
                attachment_target = components[0]
                leaves = select(attachment_target).by_leaf()
                if isinstance(attachment_target, scoretools.Container):
                    attachment_target = leaves[0]
                tempo = copy.copy(beat_two.tempo)
                attach(tempo, attachment_target)
            voice.extend(components)

        # apply logical ties, pitches, grace containers
        self._notate_leaves(
            grace_handler=grace_handler,
            voice=voice,
        )

        # partition logical ties in voice
        attack_point_optimizer(voice)

        return voice
Esempio n. 18
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
Esempio n. 19
0
    def _notate(
        self,
        attach_tempos=True,
        attack_point_optimizer=None,
        grace_handler=None,
    ):
        voice = scoretools.Voice()

        # generate the first
        q_target_measure = self.items[0]
        measure = scoretools.Measure(q_target_measure.time_signature)
        for beat in q_target_measure.beats:
            measure.extend(beat.q_grid(beat.beatspan))
        if attach_tempos:
            tempo = copy.copy(q_target_measure.tempo)
            attach(tempo, measure)
        voice.append(measure)

        # generate the rest pairwise, comparing tempi
        for q_target_measure_one, q_target_measure_two in \
            sequencetools.iterate_sequence_nwise(self.items):
            measure = scoretools.Measure(q_target_measure_two.time_signature)
            for beat in q_target_measure_two.beats:
                measure.extend(beat.q_grid(beat.beatspan))
            if (q_target_measure_two.tempo != q_target_measure_one.tempo) \
                and attach_tempos:
                tempo = copy.copy(q_target_measure_two.tempo)
                attach(tempo, measure)
            voice.append(measure)

        # apply logical ties, pitches, grace containers
        self._notate_leaves(
            grace_handler=grace_handler,
            voice=voice,
        )

        # partition logical ties in each measure
        for measure in voice:
            attack_point_optimizer(measure)

        return voice
Esempio n. 20
0
    def make_spanner_score_09(self):
        r'''Make 200-note voice with (vanilla) beam spanner on every 100 notes.

        ::

            2.12 (r9724) initialization:        249,339 function calls

            2.12 (r9703) LilyPond format:       121,497 function calls
            2.12 (r9724) LilyPond format:       128,494 function calls

        '''
        from abjad.tools import scoretools
        from abjad.tools import sequencetools
        from abjad.tools import spannertools
        from abjad.tools import topleveltools
        voice = scoretools.Voice(200 * scoretools.Note("c'16"))
        for part in sequencetools.partition_sequence_by_counts(
                voice[:],
            [100],
                cyclic=True,
        ):
            beam = spannertools.Beam()
            topleveltools.attach(beam, part)
        return voice
Esempio n. 21
0
    def make_spanner_score_05(self):
        r'''Make 200-note voice with slur spanner on every 20 notes.

        ::

            2.12 (r9724) initialization:        248,567 function calls

            2.12 (r9703) LilyPond format:       122,177 function calls
            2.12 (r9724) LilyPond format:       107,486 function calls

        '''
        from abjad.tools import scoretools
        from abjad.tools import sequencetools
        from abjad.tools import spannertools
        from abjad.tools import topleveltools
        voice = scoretools.Voice(200 * scoretools.Note("c'16"))
        for part in sequencetools.partition_sequence_by_counts(
                voice[:],
            [20],
                cyclic=True,
        ):
            slur = spannertools.Slur()
            topleveltools.attach(slur, part)
        return voice
Esempio n. 22
0
    def __call__(self):
        r'''Calls score template.

        ..  container:: example

            **Example 1.** Call first template:

            ::

                >>> score_1 = template_1()

            ::

                >>> print(format(score_1))
                \context Score = "Grouped Rhythmic Staves Score" <<
                    \context StaffGroup = "Grouped Rhythmic Staves Staff Group" <<
                        \context RhythmicStaff = "Staff 1" {
                            \context Voice = "Voice 1" {
                            }
                        }
                        \context RhythmicStaff = "Staff 2" {
                            \context Voice = "Voice 2" {
                            }
                        }
                        \context RhythmicStaff = "Staff 3" {
                            \context Voice = "Voice 3" {
                            }
                        }
                        \context RhythmicStaff = "Staff 4" {
                            \context Voice = "Voice 4" {
                            }
                        }
                    >>
                >>

        ..  container:: example

            **Example 2.** Call second template:

            ::

                >>> score_2 = template_2()

            ::

                >>> print(format(score_2))
                \context Score = "Grouped Rhythmic Staves Score" <<
                    \context StaffGroup = "Grouped Rhythmic Staves Staff Group" <<
                        \context RhythmicStaff = "Staff 1" <<
                            \context Voice = "Voice 1-1" {
                            }
                            \context Voice = "Voice 1-2" {
                            }
                        >>
                        \context RhythmicStaff = "Staff 2" {
                            \context Voice = "Voice 2" {
                            }
                        }
                        \context RhythmicStaff = "Staff 3" <<
                            \context Voice = "Voice 3-1" {
                            }
                            \context Voice = "Voice 3-2" {
                            }
                        >>
                    >>
                >>

        Returns score.
        '''
        staves = []
        if isinstance(self.staff_count, int):
            for index in range(self.staff_count):
                number = index + 1
                name = 'Voice {}'.format(number)
                voice = scoretools.Voice(name=name)
                name = 'Staff {}'.format(number)
                staff = scoretools.Staff([voice], name=name)
                staff.context_name = 'RhythmicStaff'
                staves.append(staff)
                key = 'v{}'.format(number)
                self.context_name_abbreviations[key] = voice.name
        elif isinstance(self.staff_count, list):
            for staff_index, voice_count in enumerate(self.staff_count):
                staff_number = staff_index + 1
                name = 'Staff {}'.format(staff_number)
                staff = scoretools.Staff(name=name)
                staff.context_name = 'RhythmicStaff'
                assert 1 <= voice_count
                for voice_index in range(voice_count):
                    voice_number = voice_index + 1
                    if voice_count == 1:
                        voice_identifier = str(staff_number)
                    else:
                        voice_identifier = '{}-{}'.format(
                            staff_number, voice_number)
                        staff.is_simultaneous = True
                    name = 'Voice {}'.format(voice_identifier)
                    voice = scoretools.Voice(name=name)
                    staff.append(voice)
                    key = 'v{}'.format(voice_identifier)
                    self.context_name_abbreviations[key] = voice.name
                staves.append(staff)
        if self.with_clefs:
            for staff in staves:
                attach(indicatortools.Clef('percussion'), staff)
        grouped_rhythmic_staves_staff_group = scoretools.StaffGroup(
            staves,
            name='Grouped Rhythmic Staves Staff Group',
        )
        grouped_rhythmic_staves_score = scoretools.Score(
            [grouped_rhythmic_staves_staff_group],
            name='Grouped Rhythmic Staves Score',
        )
        return grouped_rhythmic_staves_score
Esempio n. 23
0
    def __call__(self):
        '''Calls score template.

        Returns LilyPond file.
        '''

        # make bell voice and staff
        bell_voice = scoretools.Voice(name='Bell Voice')
        bell_staff = scoretools.Staff([bell_voice], name='Bell Staff')
        clef = indicatortools.Clef('treble')
        attach(clef, bell_staff)
        bells = instrumenttools.Instrument(
            instrument_name='Campana in La',
            short_instrument_name='Camp.',
            pitch_range='[C4, C6]',
        )
        attach(bells, bell_staff)
        tempo = indicatortools.Tempo((1, 4), (112, 120))
        attach(tempo, bell_staff)
        time_signature = indicatortools.TimeSignature((6, 4))
        attach(time_signature, bell_staff)

        # make first violin voice and staff
        first_violin_voice = scoretools.Voice(name='First Violin Voice')
        first_violin_staff = scoretools.Staff(
            [first_violin_voice],
            name='First Violin Staff',
        )
        clef = indicatortools.Clef('treble')
        attach(clef, first_violin_staff)
        violin = instrumenttools.Violin(
            instrument_name_markup=markuptools.Markup('Violin I'),
            short_instrument_name_markup=markuptools.Markup('Vl. I'),
        )
        attach(violin, first_violin_staff)

        # make second violin voice and staff
        second_violin_voice = scoretools.Voice(name='Second Violin Voice')
        second_violin_staff = scoretools.Staff(
            [second_violin_voice],
            name='Second Violin Staff',
        )
        clef = indicatortools.Clef('treble')
        attach(clef, second_violin_staff)
        violin = instrumenttools.Violin(
            instrument_name_markup=markuptools.Markup('Violin II'),
            short_instrument_name_markup=markuptools.Markup('Vl. II'),
        )
        attach(violin, second_violin_staff)

        # make viola voice and staff
        viola_voice = scoretools.Voice(name='Viola Voice')
        viola_staff = scoretools.Staff([viola_voice], name='Viola Staff')
        clef = indicatortools.Clef('alto')
        attach(clef, viola_staff)
        viola = instrumenttools.Viola()
        attach(viola, viola_staff)

        # make cello voice and staff
        cello_voice = scoretools.Voice(name='Cello Voice')
        cello_staff = scoretools.Staff([cello_voice], name='Cello Staff')
        clef = indicatortools.Clef('bass')
        attach(clef, cello_staff)
        cello = instrumenttools.Cello()
        attach(cello, cello_staff)

        # make bass voice and staff
        bass_voice = scoretools.Voice(name='Bass Voice')
        bass_staff = scoretools.Staff([bass_voice], name='Bass Staff')
        clef = indicatortools.Clef('bass')
        attach(clef, bass_staff)
        contrabass = instrumenttools.Contrabass(
            short_instrument_name_markup=markuptools.Markup('Cb.'), )
        attach(contrabass, bass_staff)

        # make strings staff group
        strings_staff_group = scoretools.StaffGroup(
            [
                first_violin_staff,
                second_violin_staff,
                viola_staff,
                cello_staff,
                bass_staff,
            ],
            name='Strings Staff Group',
        )

        # make score
        score = scoretools.Score([
            bell_staff,
            strings_staff_group,
        ],
                                 name='Pärt Cantus Score')

        # return Pärt Cantus score
        return score
Esempio n. 24
0
 def _make_performer_staff_group(
     self,
     clef_name=None,
     instrument=None,
     number=None,
 ):
     if number is not None:
         name = '{} {}'.format(
             instrument.instrument_name.title(),
             number,
         )
     else:
         name = instrument.instrument_name.title()
     pitch_range = instrument.pitch_range
     staff_group = scoretools.StaffGroup(
         context_name='StringPerformerStaffGroup',
         name='{} Staff Group'.format(name),
     )
     tag_name = name.replace(' ', '')
     tag_string = "tag #'{}".format(tag_name)
     tag_command = indicatortools.LilyPondCommand(
         tag_string,
         'before',
     )
     attach(tag_command, staff_group)
     if self.split_hands:
         lh_voice = scoretools.Voice(
             context_name='FingeringVoice',
             name='{} Fingering Voice'.format(name),
         )
         abbreviation = lh_voice.name.lower().replace(' ', '_')
         self.voice_name_abbreviations[abbreviation] = lh_voice.name
         lh_staff = scoretools.Staff(
             [lh_voice],
             context_name='FingeringStaff',
             name='{} Fingering Staff'.format(name),
         )
         lh_staff.is_simultaneous = True
         attach(pitch_range, lh_staff)
         attach(indicatortools.Clef(clef_name), lh_staff)
         rh_voice = scoretools.Voice(
             context_name='BowingVoice',
             name='{} Bowing Voice'.format(name),
         )
         abbreviation = rh_voice.name.lower().replace(' ', '_')
         self.voice_name_abbreviations[abbreviation] = rh_voice.name
         rh_staff = scoretools.Staff(
             [rh_voice],
             context_name='BowingStaff',
             name='{} Bowing Staff'.format(name),
         )
         rh_staff.is_simultaneous = True
         staff_group.extend([rh_staff, lh_staff])
     else:
         lh_voice = scoretools.Voice(
             context_name='FingeringVoice',
             name='{} Voice'.format(name),
         )
         lh_staff = scoretools.Staff(
             [lh_voice],
             context_name='FingeringStaff',
             name='{} Staff'.format(name),
         )
         lh_staff.is_simultaneous = True
         attach(pitch_range, lh_staff)
         attach(indicatortools.Clef(clef_name), lh_staff)
         staff_group.append(lh_staff)
     return staff_group, tag_name