Esempio n. 1
0
    def append_voices(self, staves):
        """Method to append voices to instrument staves."""
        voice_count = self.voice_count
        voices = []

        # create voices
        for i in range(sum(voice_count)):
            if voice_count == 1:
                voice_name = self.name + "_Voice"
            else:
                voice_name = self.name + "_Voice_" + str(i + 1)
            voices.append(abjad.Voice(name=voice_name, tag=self.tag))
            print("creating Voice:", voice_name)
            # will be there lyrics for that voice?
            if self.lyrics_target is not None:
                if voice_name == self.lyrics_target:
                    context = abjad.Context(
                        lilypond_type="Lyrics",
                        name=voice_name + "_Lyrics",
                        tag=self.tag,
                    )
                    voices.append(context)
                    print("creating Context: ", context.name)

        # append voices
        if self.lyrics_target is not None:
            voice_count[0] += 1
        for i, number_of_voices_in_each_staff in enumerate(voice_count):
            if number_of_voices_in_each_staff >= 1:
                staves[i].simultaneous = True
            for n in range(number_of_voices_in_each_staff):
                if i == 0:
                    staves[i].append(voices[n])
                if i >= 1:
                    staves[i].append(voices[n + sum(voice_count[:i])])
def test_scoretools_Context___setattr___01():
    r'''Slots constrain context attributes.
    '''

    context = abjad.Context([])

    assert pytest.raises(AttributeError, "context.foo = 'bar'")
Esempio n. 3
0
 def _make_global_context(self):
     site = "abjad.ScoreTemplate._make_global_context()"
     tag = abjad.Tag(site)
     global_rests = abjad.Context(
         lilypond_type="GlobalRests", name="Global_Rests", tag=tag,
     )
     global_skips = abjad.Context(
         lilypond_type="GlobalSkips", name="Global_Skips", tag=tag,
     )
     global_context = abjad.Context(
         [global_rests, global_skips],
         lilypond_type="GlobalContext",
         simultaneous=True,
         name="Global_Context",
         tag=tag,
     )
     return global_context
def test_Context___setattr___01():
    """
    Slots constrain context attributes.
    """

    context = abjad.Context([])

    assert pytest.raises(AttributeError, "context.foo = 'bar'")
Esempio n. 5
0
def test_Context___setattr___01():
    """
    Slots constrain context attributes.
    """

    context = abjad.Context([])

    with pytest.raises(AttributeError):
        context.foo = "bar"
Esempio n. 6
0
def make_empty_score():
    tag = baca.tags.function_name(inspect.currentframe())
    global_context = baca.score.make_global_context()
    cello_music_voice = abjad.Voice(name="Cello.Music", tag=tag)
    cello_music_staff = abjad.Staff([cello_music_voice],
                                    name="Cello.Staff",
                                    tag=tag)
    music_context = abjad.Context(
        [cello_music_staff],
        lilypond_type="MusicContext",
        name="MusicContext",
        tag=tag,
    )
    score = abjad.Score([global_context, music_context], name="Score", tag=tag)
    baca.score.assert_lilypond_identifiers(score)
    baca.score.assert_unique_context_names(score)
    # baca.score.assert_matching_custom_context_names(score)
    return score
Esempio n. 7
0
def make_empty_score():
    tag = baca.tags.function_name(inspect.currentframe())
    global_context = baca.score.make_global_context()
    violin_music_voice = abjad.Voice(name="Violin.Music", tag=tag)
    violin_music_staff = abjad.Staff(
        [violin_music_voice],
        name="Violin.Staff",
        tag=tag,
    )
    piano_rh_music_voice = abjad.Voice(name="Piano.RH.Music", tag=tag)
    piano_rh_music_staff = abjad.Staff(
        [piano_rh_music_voice],
        name="Piano.RH.Staff",
        tag=tag,
    )
    piano_lh_music_voice = abjad.Voice(name="Piano.LH.Music", tag=tag)
    piano_lh_music_staff = abjad.Staff(
        [piano_lh_music_voice],
        name="Piano.LH.Staff",
        tag=tag,
    )
    piano_staff_group = abjad.StaffGroup(
        [piano_rh_music_staff, piano_lh_music_staff],
        lilypond_type="PianoStaff",
        name="PianoStaff",
        tag=tag,
    )
    music_context = abjad.Context(
        [violin_music_staff, piano_staff_group],
        lilypond_type="MusicContext",
        simultaneous=True,
        name="MusicContext",
        tag=tag,
    )
    score = abjad.Score([global_context, music_context], name="Score", tag=tag)
    baca.score.assert_lilypond_identifiers(score)
    baca.score.assert_unique_context_names(score)
    # baca.score.assert_matching_custom_context_names(score)
    return score
Esempio n. 8
0
    def __call__(self):
        r'''Calls string orchestra template.

        Returns score.
        '''
        import abjad

        ### TAGS ###

        tag_names = []

        ### SCORE ###

        staff_group = abjad.StaffGroup(name='Outer Staff Group', )

        score = abjad.Score(
            [staff_group],
            name='Score',
        )

        ### VIOLINS ###

        if self.violin_count:
            clef_name = 'treble'
            if self.use_percussion_clefs:
                clef_name = 'percussion'
            instrument = abjad.Violin()
            instrument_count = self.violin_count
            instrument_staff_group, instrument_tag_names = \
                self._make_instrument_staff_group(
                    clef_name=clef_name,
                    count=instrument_count,
                    instrument=instrument,
                    )
            staff_group.append(instrument_staff_group)
            tag_names.extend(instrument_tag_names)

        ### VIOLAS ###

        if self.viola_count:
            clef_name = 'alto'
            if self.use_percussion_clefs:
                clef_name = 'percussion'
            instrument = abjad.Viola()
            instrument_count = self.viola_count
            instrument_staff_group, instrument_tag_names = \
                self._make_instrument_staff_group(
                    clef_name=clef_name,
                    count=instrument_count,
                    instrument=instrument,
                    )
            staff_group.append(instrument_staff_group)
            tag_names.extend(instrument_tag_names)

        ### CELLOS ###

        if self.cello_count:
            clef_name = 'bass'
            if self.use_percussion_clefs:
                clef_name = 'percussion'
            instrument = abjad.Cello()
            instrument_count = self.cello_count
            instrument_staff_group, instrument_tag_names = \
                self._make_instrument_staff_group(
                    clef_name=clef_name,
                    count=instrument_count,
                    instrument=instrument,
                    )
            staff_group.append(instrument_staff_group)
            tag_names.extend(instrument_tag_names)

        ### BASSES ###

        if self.contrabass_count:
            clef_name = 'bass_8'
            if self.use_percussion_clefs:
                clef_name = 'percussion'
            instrument = abjad.Contrabass()
            instrument_count = self.contrabass_count
            instrument_staff_group, instrument_tag_names = \
                self._make_instrument_staff_group(
                    clef_name=clef_name,
                    count=instrument_count,
                    instrument=instrument,
                    )
            staff_group.append(instrument_staff_group)
            tag_names.extend(instrument_tag_names)

        ### TIME SIGNATURE CONTEXT ###

        global_context = abjad.Context(
            name='GlobalContext',
            lilypond_type='GlobalContext',
        )
        instrument_tags = ' '.join(tag_names)
        tag_string = r"\tag #'({})".format(instrument_tags)
        tag_command = abjad.LilyPondLiteral(tag_string, 'before')
        abjad.attach(tag_command, global_context)
        score.insert(0, global_context)
        return score
Esempio n. 9
0
def make_empty_score():
    tag = baca.tags.function_name(inspect.currentframe())
    global_context = baca.score.make_global_context()
    rh_voice_1 = abjad.Voice(lilypond_type="RHVoiceI",
                             name="RH.Music.1",
                             tag=tag)
    rh_voice_1I = abjad.Voice(lilypond_type="RHInsertVoiceI",
                              name="RH.Insert_Voice.1",
                              tag=tag)
    rh_voice_2 = abjad.Voice(lilypond_type="RHVoiceII",
                             name="RH.Music.2",
                             tag=tag)
    rh_voice_2I = abjad.Voice(
        lilypond_type="RHInsertVoiceII",
        name="RH.Insert_Voice.2",
        tag=tag,
    )
    rh_voice_3 = abjad.Voice(lilypond_type="RHVoiceIII",
                             name="RH.Music.3",
                             tag=tag)
    rh_voice_3I = abjad.Voice(
        lilypond_type="RHInsertVoiceIII",
        name="RH.Insert_Voice.3",
        tag=tag,
    )
    rh_voice_4 = abjad.Voice(lilypond_type="RHVoiceIV",
                             name="RH.Music.4",
                             tag=tag)
    rh_voice_4I = abjad.Voice(
        lilypond_type="RHInsertVoiceIV",
        name="RH.Insert_Voice.4",
        tag=tag,
    )
    rh_voice_5 = abjad.Voice(lilypond_type="RHVoiceV",
                             name="RH.Music.5",
                             tag=tag)
    rh_voice_6 = abjad.Voice(lilypond_type="RHVoiceVI",
                             name="RH.Music.6",
                             tag=tag)
    rh_resonance_voice = abjad.Voice(
        lilypond_type="RHResonanceVoice",
        name="RH.Resonance_Voice",
        tag=tag,
    )
    lh_voice_1 = abjad.Voice(lilypond_type="LHVoiceI",
                             name="LH.Music.1",
                             tag=tag)
    lh_voice_2 = abjad.Voice(lilypond_type="LHVoiceII",
                             name="LH.Music.2",
                             tag=tag)
    lh_voice_3 = abjad.Voice(lilypond_type="LHVoiceIII",
                             name="LH.Music.3",
                             tag=tag)
    lh_voice_4 = abjad.Voice(lilypond_type="LHVoiceIV",
                             name="LH.Music.4",
                             tag=tag)
    lh_voice_4I = abjad.Voice(
        lilypond_type="LHInsertVoiceIV",
        name="LH.Insert_Voice.4",
        tag=tag,
    )
    lh_voice_5 = abjad.Voice(lilypond_type="LHVoiceV",
                             name="LH.Music.5",
                             tag=tag)
    lh_voice_5I = abjad.Voice(lilypond_type="LHInsertVoiceV",
                              name="LH.Insert_Voice.5",
                              tag=tag)
    lh_voice_6 = abjad.Voice(lilypond_type="LHVoiceVI",
                             name="LH.Music.6",
                             tag=tag)
    lh_voice_6I = abjad.Voice(
        lilypond_type="LHInsertVoiceVI",
        name="LH.Insert_Voice.6",
        tag=tag,
    )
    lh_resonance_voice = abjad.Voice(
        lilypond_type="LHResonanceVoice",
        name="LH.Resonance_Voice",
        tag=tag,
    )
    piano_music_rh_staff = abjad.Staff(
        [
            rh_voice_1,
            rh_voice_1I,
            rh_voice_2,
            rh_voice_2I,
            rh_voice_3,
            rh_voice_3I,
            rh_voice_4,
            rh_voice_4I,
            rh_voice_5,
            rh_voice_6,
            rh_resonance_voice,
        ],
        lilypond_type="PianoMusicRHStaff",
        simultaneous=True,
        name="Piano_Music_RH.Staff",
        tag=tag,
    )
    piano_music_lh_staff = abjad.Staff(
        [
            lh_voice_1,
            lh_voice_2,
            lh_voice_3,
            lh_voice_4,
            lh_voice_4I,
            lh_voice_5,
            lh_voice_5I,
            lh_voice_6,
            lh_voice_6I,
            lh_resonance_voice,
        ],
        lilypond_type="PianoMusicLHStaff",
        simultaneous=True,
        name="Piano_Music_LH.Staff",
        tag=tag,
    )
    piano_music_staff_group = abjad.StaffGroup(
        [piano_music_rh_staff, piano_music_lh_staff],
        lilypond_type="PianoMusicStaffGroup",
        name="Piano_Music.Staff_Group",
        tag=tag,
    )
    music_context = abjad.Context(
        [piano_music_staff_group],
        lilypond_type="MusicContext",
        name="MusicContext",
        tag=tag,
    )
    score = abjad.Score([global_context, music_context], name="Score", tag=tag)
    baca.score.assert_lilypond_identifiers(score)
    baca.score.assert_unique_context_names(score)
    # baca.score.assert_matching_custom_context_names(score)
    _validate_voice_names(score)
    return score
Esempio n. 10
0
    def __call__(self) -> abjad.Score:
        """
        Calls score template.
        """
        site = "arctic.ScoreTemplate.__call__()"
        tag = abjad.Tag(site)

        # GLOBAL CONTEXT
        #global_context = self._make_global_context()

        # Violin
        markup_voice = abjad.Voice(name="Violin_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="Violin_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="Violin_Dynamics_Voice", tag=tag)
        violin_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            simultaneous=True,
            name="Violin",
            tag=tag,
        )
        abjad.annotate(
            violin_staff,
            "default_instrument",
            arctic.instruments["Violin"],
        )
        abjad.annotate(violin_staff, "default_clef", abjad.Clef("treble"))
        violin_tag = abjad.LilyPondLiteral(r"\tag #'violin", format_slot='before')
        abjad.attach(violin_tag, violin_staff)
        abjad.setting(violin_staff).midi_instrument = abjad.scheme.Scheme(
                'violin', force_quotes=True)

        # MonoSynth
        markup_voice = abjad.Voice(name="Monosynth_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="Monosynth_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="Monosynth_Dynamics_Voice", tag=tag)
        monosynth_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            simultaneous=True,
            name="Monosynth",
            tag=tag,
        )
        abjad.annotate(
            monosynth_staff,
            "default_instrument",
            arctic.instruments["Monosynth"],
        )
        abjad.annotate(monosynth_staff, "default_clef", abjad.Clef("treble"))
        monosynth_tag = abjad.LilyPondLiteral(r"\tag #'monosynth", format_slot='before')
        abjad.attach(monosynth_tag, monosynth_staff)
        abjad.setting(monosynth_staff).midi_instrument = abjad.scheme.Scheme(
                'clarinet', force_quotes=True)

        ### RH PolySynth Voices ###
        markup_voice = abjad.Voice(name="RH_I_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="RH_I_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="RH_I_Dynamics_Voice", tag=tag)
        #rh_voice_2 = abjad.Voice(
        #            lilypond_type="RHVoiceII", name="RH_II_Music_Voice", tag=tag
        #            )
       
        # RH PolySynth Staff 
        polysynth_music_rh_staff = abjad.Staff(
                [markup_voice, music_voice, dynamics_voice],
                simultaneous=True,
                name="RH_Polysynth",
                tag=tag,
                )
        abjad.annotate(
                polysynth_music_rh_staff, "default_clef", abjad.Clef("treble")
                )
        
        ### LH PolySynth Voices ###
        markup_voice = abjad.Voice(name="LH_I_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="LH_I_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="LH_I_Dynamics_Voice", tag=tag)
        #        lh_voice_2 = abjad.Voice(
        #            lilypond_type="LHVoiceII", name="LH_II_Music_Voice", tag=tag
        #        )
        #
       
        # LH PolySynth Staff
        polysynth_music_lh_staff = abjad.Staff(
                [markup_voice, music_voice, dynamics_voice],
                simultaneous=True,
                name="LH_Polysynth",
                tag=tag,
                )
        abjad.annotate(
                polysynth_music_lh_staff, "default_clef", abjad.Clef("bass")
                )

        # Polysynth Staff Group
        polysynth_staff_group = abjad.StaffGroup(
                [polysynth_music_rh_staff, polysynth_music_lh_staff],
                simultaneous=True,
                lilypond_type="PianoStaff",
                name="Polysynth_Staff_Group",
                tag=tag,
                )
        polysynth_tag = abjad.LilyPondLiteral(r"\tag #'polysynth", format_slot='before')
        abjad.attach(polysynth_tag, polysynth_staff_group)
        abjad.setting(polysynth_staff_group).midi_instrument = abjad.scheme.Scheme(
                'organ', force_quotes=True)
        
        # Music Context
        music_context = abjad.Context(
                [
                    violin_staff,
                    monosynth_staff,
                    polysynth_staff_group,
                ],
                lilypond_type="MusicContext",
                simultaneous=True,
                name="Music_Context",
                tag=tag,
                )

        # Score
        score = abjad.Score(
                [music_context], name="Score", tag=tag
                )
        return score
Esempio n. 11
0
    def __call__(self) -> abjad.Score:
        """
        Calls score template.
        """
        site = "rill.ScoreTemplate.__call__()"
        tag = abjad.Tag(site)

        # GLOBAL CONTEXT
        global_context = self._make_global_context()

        # Violin
        markup_voice = abjad.Voice(name="Violin_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="Violin_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="Violin_Dynamics_Voice", tag=tag)
        violin_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            simultaneous=True,
            name="Violin",
            tag=tag,
        )
        abjad.annotate(
            violin_staff,
            "default_instrument",
            rill.instruments["Violin"],
        )
        abjad.annotate(violin_staff, "default_clef", abjad.Clef("treble"))

        # MonoSynth
        markup_voice = abjad.Voice(name="MonoSynth_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="MonoSynth_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="MonoSynth_Dynamics_Voice", tag=tag)
        monosynth_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            simultaneous=True,
            name="MonoSynth",
            tag=tag,
        )
        abjad.annotate(
            monosynth_staff,
            "default_instrument",
            rill.instruments["MonoSynth"],
        )
        abjad.annotate(monosynth_staff, "default_clef", abjad.Clef("treble"))

        ### RH PolySynth Voices ###
        markup_voice = abjad.Voice(name="RH_I_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="RH_I_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="RH_I_Dynamics_Voice", tag=tag)

        #        rh_voice_2 = abjad.Voice(
        #            lilypond_type="RHVoiceII", name="RH_II_Music_Voice", tag=tag
        #            )

        # RH PolySynth Staff
        polysynth_music_rh_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            lilypond_type="PolySynthRHStaff",
            simultaneous=True,
            name="PolySynth_Music_RH_Staff",
            tag=tag,
        )
        abjad.annotate(polysynth_music_rh_staff, "default_clef",
                       abjad.Clef("treble"))

        ### LH PolySynth Voices ###
        markup_voice = abjad.Voice(name="LH_I_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="LH_I_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="LH_I_Dynamics_Voice", tag=tag)
        #        lh_voice_2 = abjad.Voice(
        #            lilypond_type="LHVoiceII", name="LH_II_Music_Voice", tag=tag
        #        )
        #

        # LH PolySynth Staff
        polysynth_music_lh_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            lilypond_type="PolySynthLHStaff",
            simultaneous=True,
            name="PolySynth_Music_LH_Staff",
            tag=tag,
        )
        abjad.annotate(polysynth_music_lh_staff, "default_clef",
                       abjad.Clef("bass"))

        # PolySynth Staff Group
        polysynth_music_staff_group = abjad.StaffGroup(
            [polysynth_music_rh_staff, polysynth_music_lh_staff],
            lilypond_type="PolySynthMusicStaffGroup",
            name="PolySynth_Music_Staff_Group",
            tag=tag,
        )
        polysynth = rill.instruments["PolySynth"]
        abjad.annotate(polysynth_music_staff_group, "default_insrument",
                       polysynth)

        # PolySynth Music Context
        polysynth_music_context = abjad.Context([polysynth_music_staff_group],
                                                lilypond_type="MusicContext",
                                                name="PolySynth_Music_Context",
                                                tag=tag)

        # Music Context
        music_context = abjad.Context(
            [
                violin_staff,
                monosynth_staff,
                polysynth_music_context,
            ],
            lilypond_type="MusicContext",
            simultaneous=True,
            name="Music_Context",
            tag=tag,
        )

        # Score
        score = abjad.Score([global_context, music_context],
                            name="Score",
                            tag=tag)
        return score