Пример #1
0
    def __call__(self):
        """Return ``self.ready_staff``."""
        abjad_instrument = self.abjad_instrument
        staves = self.append_staves(self)
        self.append_voices(self, staves)
        staff_count = self.staff_count

        if staff_count == 1:
            abjad.annotate(staves[0], "default_instrument", abjad_instrument)
            self.ready_staff = staves[0]
        else:
            if abjad_instrument == abjad.Piano():
                staffgroup = abjad.StaffGroup(
                    lilypond_type="PianoStaff",
                    name="Piano_StaffGroup",
                    tag=self.tag,
                    simultaneous=True,
                )
                for staff in staves:
                    staffgroup.append(staff)

            else:
                staffgroup = abjad.StaffGroup(name=self.name, tag=self.tag)
                for staff in staves:
                    staffgroup.append(staff)

            abjad.annotate(staffgroup, "default_instrument", abjad_instrument)

            self.ready_staff = staffgroup

        return self.ready_staff
    def __call__(self):
        """
        Calls two-staff piano score template.

        Returns score.
        """
        import abjad
        tag = 'TwoStaffPianoScoreTemplate'
        # GLOBAL CONTEXT
        global_context = self._make_global_context()

        # RH STAFF
        rh_voice = abjad.Voice(
            name='RH_Voice',
            tag=tag,
        )
        rh_staff = abjad.Staff(
            [rh_voice],
            name='RH_Staff',
            tag=tag,
        )

        # LH STAFF
        lh_voice = abjad.Voice(
            name='LH_Voice',
            tag=tag,
        )
        lh_staff = abjad.Staff(
            [lh_voice],
            name='LH_Staff',
            tag=tag,
        )
        abjad.annotate(
            lh_staff,
            'default_clef',
            abjad.Clef('bass'),
        )

        # PIANO STAFF
        staff_group = abjad.StaffGroup(
            [rh_staff, lh_staff],
            lilypond_type='PianoStaff',
            name='Piano_Staff',
            tag=tag,
        )
        abjad.annotate(
            staff_group,
            'default_instrument',
            abjad.Piano(),
        )

        # SCORE
        score = abjad.Score(
            [global_context, staff_group],
            name='Two_Staff_Piano_Score',
            tag=tag,
        )
        return score
Пример #3
0
def make_mozart_score():
    """
    Makes Mozart score.
    """
    score_template = abjad.TwoStaffPianoScoreTemplate()
    score = score_template()
    # select the measures to use
    choices = abjad.demos.mozart.choose_mozart_measures()
    # create and populate the volta containers
    treble_volta = abjad.Container()
    bass_volta = abjad.Container()
    for choice in choices[:7]:
        treble, bass = abjad.demos.mozart.make_mozart_measure(choice)
        treble_volta.append(treble)
        bass_volta.append(bass)
    # abjad.attach indicators to the volta containers
    command = abjad.LilyPondLiteral(r"\repeat volta 2", "before")
    abjad.attach(command, treble_volta)
    command = abjad.LilyPondLiteral(r"\repeat volta 2", "before")
    abjad.attach(command, bass_volta)
    # append the volta containers to our staves
    score["RH_Voice"].append(treble_volta)
    score["LH_Voice"].append(bass_volta)
    # create and populate the alternative ending containers
    treble_alternative = abjad.Container()
    bass_alternative = abjad.Container()
    for choice in choices[7:9]:
        treble, bass = abjad.demos.mozart.make_mozart_measure(choice)
        treble_alternative.append(treble)
        bass_alternative.append(bass)
    # abjad.attach indicators to the alternative containers
    command = abjad.LilyPondLiteral(r"\alternative", "before")
    abjad.attach(command, treble_alternative)
    command = abjad.LilyPondLiteral(r"\alternative", "before")
    abjad.attach(command, bass_alternative)
    # append the alternative containers to our staves
    score["RH_Voice"].append(treble_alternative)
    score["LH_Voice"].append(bass_alternative)
    # create the remaining measures
    for choice in choices[9:]:
        treble, bass = abjad.demos.mozart.make_mozart_measure(choice)
        score["RH_Voice"].append(treble)
        score["LH_Voice"].append(bass)
    # abjad.attach indicators
    time_signature = abjad.TimeSignature((3, 8))
    leaf = abjad.inspect(score["RH_Staff"]).leaf(0)
    abjad.attach(time_signature, leaf)
    bar_line = abjad.BarLine("|.")
    leaf = abjad.inspect(score["RH_Staff"]).leaf(-1)
    abjad.attach(bar_line, leaf)
    # remove the default piano instrument and add a custom one:
    abjad.detach(abjad.Instrument, score["Piano_Staff"])
    klavier = abjad.Piano(name="Katzenklavier", short_name="kk.")
    leaf = abjad.inspect(score["Piano_Staff"]).leaf(0)
    abjad.attach(klavier, leaf)
    return score
Пример #4
0
def instruments():
    return dict([("Piano", abjad.Piano())])
Пример #5
0
 class MidDrones(calliope.Staff):
     instrument=abjad.Piano(
         name="Mid Drones", short_name="m.drn.")
     midi_instrument = "string ensemble 2"
Пример #6
0
 class BassDrones(calliope.Staff):
     instrument=abjad.Piano(
         name="Bass Drones", short_name="b.drn.")
     clef="bass"
     midi_instrument = "fretless bass"
Пример #7
0
import abjad

instrument_one = abjad.Piano()
instrument_one_range = instrument_one.pitch_range
instrument_one_range_lowest = 0
instrument_one_range_highest = abjad.NumberedPitch(
    instrument_one_range.stop_pitch
).number

instrument_two = abjad.Piano()
instrument_two_range = instrument_two.pitch_range
instrument_two_range_lowest = 0
instrument_two_range_highest = abjad.NumberedPitch(
    instrument_two_range.stop_pitch
).number

instrument_three = abjad.Piano()
instrument_three_range = instrument_three.pitch_range
instrument_three_range_lowest = abjad.NumberedPitch(
    instrument_three_range.start_pitch
).number
instrument_three_range_highest = 6

instrument_four = abjad.Piano()
instrument_four_range = instrument_four.pitch_range
instrument_four_range_lowest = abjad.NumberedPitch(
    instrument_four_range.start_pitch
).number
instrument_four_range_highest = 6

instruments = [instrument_one, instrument_two, instrument_three, instrument_four]
Пример #8
0
 class HighDrones(calliope.Staff):
     instrument=abjad.Piano(
         name="High Drones", short_name="h.drn.")
     midi_instrument = "piccolo"
Пример #9
0
import abjad
import mccartney

instruments = abjad.OrderedDict([
    (
        "Violin",
        abjad.Violin(
            markup=mccartney.markups.instrument("Violin"),
            short_markup=mccartney.markups.short_instrument("vln"),
        ),
    ),
    (
        "MonoSynth",
        abjad.ClarinetInBFlat(
            markup=mccartney.markups.instrument("MonoSynth"),
            short_markup=mccartney.markups.short_instrument("msy"),
        ),
    ),
    (
        "PolySynth",
        abjad.Piano(
            markup=mccartney.markups.instrument("PolySynth"),
            short_markup=mccartney.markups.short_instrument("psy"),
        ),
    ),
])

if __name__ == '__main__':
    for key, item in instruments.items():
        print(key, item)
Пример #10
0
 class S2(calliope.Staff):
     instrument = abjad.Piano(name="S 2", short_name="s.2")
Пример #11
0
 class MelodyLine2(calliope.Staff):
     instrument=abjad.Piano(
         name="Melody Line 2", short_name="mel.2")
     midi_instrument = "misc2"
Пример #12
0
 class CounterLine(calliope.Staff):
     instrument=abjad.Piano(
         name="Counter Line", short_name="count.")
     midi_instrument = "misc3"
Пример #13
0
def instruments():
    return {
        "Piano": abjad.Piano(),
        "Violin": abjad.Violin(),
    }
Пример #14
0
 class S4(calliope.Staff):
     instrument = abjad.Piano(name="S 4", short_name="s.4")
Пример #15
0
 class S3(calliope.Staff):
     instrument = abjad.Piano(name="S 3", short_name="s.3")
Пример #16
0
        >>>
        """
        lilypond = abjad.lilypond(self.score)
        print(lilypond)
        return lilypond

    def show(self):
        """Show ``self.score``."""
        return abjad.show(self.score)

    def play(self):
        pass

    def save_ly(self, file_name: str):
        lilypond_file = abjad.LilyPondFile(items=[self.score], )
        abjad.persist.as_ly(lilypond_file, file_name)
        print("Current working directory: {0}".format(os.getcwd()))


def make_group(instruments: list, group_name: str):
    group = abjad.StaffGroup(name=group_name)
    for instrument in instruments:
        group.append(instrument.ready_staff)
    return group


if __name__ == "__main__":
    inst = Instrument(abjad.Piano(), "Piano", 2, [2, 2])
    score = Score()
    score.append([inst])
Пример #17
0
import baca
from abjadext import rmakers

instruments = dict([
    ("BassClarinet", abjad.BassClarinet()),
    ("Bassoon", abjad.Bassoon()),
    ("Cello", abjad.Cello()),
    ("Clarinet", abjad.ClarinetInBFlat()),
    ("Contrabass", abjad.Contrabass(pitch_range="[E1, D6]")),
    ("EnglishHorn", abjad.EnglishHorn()),
    ("Flute", abjad.Flute()),
    ("Harp", abjad.Harp()),
    ("Horn", abjad.FrenchHorn()),
    ("Oboe", abjad.Oboe()),
    ("Percussion", abjad.Percussion()),
    ("Piano", abjad.Piano()),
    ("Trombone", abjad.TenorTrombone()),
    ("Trumpet", abjad.Trumpet()),
    ("Tuba", abjad.Tuba()),
    ("Vibraphone", abjad.Vibraphone()),
    ("Viola", abjad.Viola()),
    ("Violin", abjad.Violin()),
])


def instrument(key):
    return baca.instrument(instruments[key])


def margin_markup(key,
                  alert=None,
Пример #18
0
 class BassLine(calliope.Staff):
     instrument=abjad.Piano(
         name="Bass Line", short_name="bass.")
     clef="bass"
     midi_instrument = "electric bass (finger)"
Пример #19
0
alto_flute = muda.score.Instrument(
    abjad_instrument=abjad.AltoFlute(),
    lilypond_name="AltoFlute",
    nstaffs=1,
    nvoices=[1],
)

# Note: the markup for "instrumentName" in lilypond will be the lilypond_name variable with a espace between the words.
bass_clarinet = muda.score.Instrument(
    abjad_instrument=abjad.BassClarinet(),
    lilypond_name="BassClarinet",
    nstaffs=1,
    nvoices=[1],
)
piano = muda.score.Instrument(
    abjad_instrument=abjad.Piano(),
    lilypond_name="Piano",
    nstaffs=2,
    nvoices=[2, 2],
    piano=True,
)
violin = muda.score.Instrument(abjad_instrument=abjad.Violin(),
                               lilypond_name="Violin",
                               nstaffs=1,
                               nvoices=[1])
viola = muda.score.Instrument(abjad_instrument=abjad.Viola(),
                              lilypond_name="Viola",
                              nstaffs=1,
                              nvoices=[1])
cello = muda.score.Instrument(abjad_instrument=abjad.Cello(),
                              lilypond_name="Cello",
Пример #20
0
    def __call__(self) -> abjad.Score:
        """
        Calls score template.
        """
        # GLOBAL CONTEXT
        global_context = abjad.Voice(name="Global_Context")
        global_context_ii = abjad.Voice(name="Global_Context_II")
        global_context_iii = abjad.Voice(name="Global_Context_III")

        # RH STAFF
        rh_voice_one = abjad.Voice(name="RH_Voice_One")
        # command = abjad.LilyPondLiteral(r"\voiceOne")
        # abjad.attach(command, rh_voice_one)
        # abjad.override(rh_voice_one).stem.direction = abjad.Up
        # abjad.override(rh_voice_one).tie.direction = abjad.Up
        rh_voice_two = abjad.Voice(name="RH_Voice_Two")
        # command = abjad.LilyPondLiteral(r"\voiceTwo")
        # abjad.attach(command, rh_voice_two)
        # abjad.override(rh_voice_two).stem.direction = abjad.Down
        # abjad.override(rh_voice_two).tie.direction = abjad.Down
        rh_voice_three = abjad.Voice(name="RH_Voice_Three")
        # command = abjad.LilyPondLiteral(r"\voiceThree")
        # abjad.attach(command, rh_voice_three)
        # abjad.override(rh_voice_three).stem.direction = abjad.Down
        # abjad.override(rh_voice_three).tie.direction = abjad.Down
        rh_staff = abjad.Staff(
            [global_context, rh_voice_one, rh_voice_two, rh_voice_three],
            name="RH_Staff")
        rh_staff.simultaneous = True

        # LH STAFF
        lh_voice_one = abjad.Voice(name="LH_Voice_Four")
        lh_voice_two = abjad.Voice(name="LH_Voice_Five")
        lh_staff = abjad.Staff([global_context_ii, lh_voice_one, lh_voice_two],
                               name="LH_Staff")
        lh_staff.simultaneous = True

        # ORGAN STAFF
        piano_group = abjad.StaffGroup(
            [rh_staff, lh_staff],
            lilypond_type="PianoStaff",
            name="Piano_Staff",
        )
        abjad.annotate(piano_group, "default_instrument", abjad.Piano())
        instrumentName_piano = abjad.LilyPondLiteral(
            r"\set PianoStaff.instrumentName = \markup{Organ}")
        abjad.attach(instrumentName_piano, piano_group)

        # ELECTRONICS
        # ELECTRONICS RH STAFF
        voice_one_elec = abjad.Voice(name="RH_Voice_One_Electronics")
        electronics = abjad.Staff([global_context_iii, voice_one_elec],
                                  name="Electronics_Staff")
        electronics.simultaneous = True

        abjad.annotate(electronics, "default_instrument", abjad.Piano())
        instrumentName_electronics = abjad.LilyPondLiteral(
            r"\set Staff.instrumentName = \markup{Electronics}")
        abjad.attach(instrumentName_electronics, electronics)

        # SCORE
        score = abjad.Score(
            [piano_group, electronics],
            name="Score",
        )
        # abjad.override(score).script.padding = 1.1
        # abjad.override(score).spacing_spanner.strict_grace_spacing = True
        # abjad.override(score).spacing_spanner.strict_note_spacing = True
        # abjad.override(score).spacing_spanner.uniform_stretching = True
        # abjad.override(score).stem.length = 8
        # abjad.override(score).text_script.outside_staff_padding = 1
        # abjad.override(score).tuplet_bracket.bracket_visibility = True
        # abjad.override(score).tuplet_bracket.minimum_length = 3
        # abjad.override(score).tuplet_bracket.outside_staff_padding = 1.5
        # abjad.override(score).tuplet_bracket.padding = 1.5
        # abjad.override(score).tuplet_bracket.springs_and_rods = \
        #     abjad.scheme.Scheme('ly:spanner::set-spacing-rods', verbatim=True)
        # abjad.override(score).tuplet_bracket.staff_padding = 2.25
        # abjad.override(score).tuplet_number.text = \
        #     abjad.scheme.Scheme(
        #         'tuplet-number::calc-fraction-text', verbatim=True)
        # abjad.setting(score).proportional_notation_duration = \
        #     abjad.scheme.SchemeMoment((1, 24))
        # abjad.setting(score).tuplet_full_length = True

        return score
Пример #21
0
 class Riff(calliope.Staff):
     instrument=abjad.Piano(
         name="Riff", short_name="riff.")
     midi_instrument = "electric guitar (clean)"
Пример #22
0
    for instr in scale_per_instrument:
        for p in scale_per_instrument[instr]:
            d.update({p.normalize(): instr})

    return d


PITCH2SCALE_DEGREE = _make_pitch2scale_degree_dict(INTONATIONS_PER_SCALE_DEGREE)
PITCH2INSTRUMENT = _make_pitch2instrument_dict(SCALE_PER_INSTRUMENT)


INSTRUMENT_NAME2OBJECT = {
    "cello": abjad.Cello(),
    "violin": abjad.Violin(),
    "viola": abjad.Viola(),
    "keyboard": abjad.Piano(name="keyboard", short_name="kbd."),
}


STANDARD_TEMPI = (
    35,
    36,
    37,
    38,
    39,
    40,
    42,
    44,
    46,
    48,
    50,
Пример #23
0
 class Chords(calliope.Staff):
     instrument=abjad.Piano(
         name="Chords", short_name="chrd.")
     midi_instrument = "french horn"