Пример #1
0
def test_play_02():
    """
    A score can be played.
    """
    notes = [abjad.Note(i, (1, 64)) for i in range(10)]
    staff = abjad.Staff(notes)
    score = abjad.Score([staff])
    abjad.play(score, test=True)
Пример #2
0
def make_score(sequence, chords, midi=False):
    print("Length of sequence:", len(sequence), "of", len(chords))
    staff = make_one_part(sequence)
    abjad.show(staff)
    if midi:
        abjad.play(staff)

    # make csv
    filename = 'chords.csv'
    with open(filename, 'w') as csvfile:
        chord_writer = csv.writer(csvfile, delimiter=',')
        for chord in sequence:
            chord_writer.writerow([chord])
Пример #3
0
def make_vla_vln_score(chords, midi=False):
    vla_chords = []
    vln_chords = []

    for chord in chords:
        vla_chord = chord[:4]
        vln_chord = chord[1:]
        vla_chords.append(vla_chord)
        vln_chords.append(vln_chord)

    vla_staff = make_one_part(vla_chords, parenthesis=3)
    clef = abjad.Clef(name='alto')
    abjad.attach(clef, vla_staff[0])
    viola = abjad.instrumenttools.Viola()
    abjad.attach(viola, vla_staff)
    #vla_staff.name = 'Viola'
    vln_staff = make_one_part(vln_chords, parenthesis=0)
    violin = abjad.instrumenttools.Violin()
    abjad.attach(violin, vln_staff)
    #vln_staff.name = 'Violin'
    score = abjad.Score([vln_staff, vla_staff])
    score.add_final_bar_line()

    lilypond_file = abjad.LilyPondFile.new(score,
                                           default_paper_size=('letter',
                                                               'landscape'),
                                           global_staff_size=20)

    #postscript = abjad.Postscript()

    lilypond_file.header_block.title = abjad.Markup("tuning no. 4:")

    lilypond_file.header_block.title.setfont("Arial")
    lilypond_file.header_block.subtitle = abjad.Markup('Pythagorean chains')
    lilypond_file.header_block.composer = abjad.Markup('John Eagle')
    lilypond_file.header_block.tagline = " "
    lilypond_file.paper_block.top_margin = 15
    lilypond_file.paper_block.left_margin = 20

    abjad.show(lilypond_file)
    if midi:
        abjad.play(score)
Пример #4
0
def show_score(voiced_chords):
    def add2staff(voice1, voice2, staff):
        voice1 = abjad.Voice(voice1)
        command = abjad.indicatortools.LilyPondCommand('voiceOne')
        abjad.attach(command, voice1)
        voice2 = abjad.Voice(voice2)
        command = abjad.indicatortools.LilyPondCommand('voiceTwo')
        abjad.attach(command, voice2)
        staff.extend([voice1, voice2])
        staff.is_simultaneous = True

    #right format
    notes = []
    satb = [""] * 4
    for chord in voiced_chords:
        for i, note in enumerate(chord):
            octave = note.octave
            name = str.lower(note.name)
            name += ("'" * (octave - 3) * (octave > 3) + "," * (3 - octave) *
                     (octave < 3) + "4 ")

            #builds the voices
            satb[i] += name

    soprano, alto, tenor, bass = satb

    #build the score

    upper_staff = abjad.Staff()
    lower_staff = abjad.Staff()
    satb_staff = abjad.StaffGroup([upper_staff, lower_staff])

    add2staff(soprano, alto, upper_staff)
    add2staff(tenor, bass, lower_staff)
    abjad.attach(abjad.Clef('bass'), lower_staff[0])

    abjad.show(satb_staff)
    abjad.play(satb_staff)
Пример #5
0
def test_play_01():
    """
    A note can be played.
    """
    note = abjad.Note(1, (1, 2))
    abjad.play(note, test=True)
Пример #6
0
    def make_permutations(self, pitch_set):
        return list(permutations(pitch_set.items))

    def __call__(self, duration, repetitions):
        self.duration = duration
        for cycle in range(repetitions):
            shuffle(self.permutation_sequence)
            self.add_permutation_sequence_to_staves(self.permutation_sequence)
        return abjad.Score(self.staves)

    def add_permutation_sequence_to_staves(self, permutation_sequence):
        for chord in permutation_sequence:
            for staff_number, pitch in enumerate(chord):
                note = abjad.Note(pitch, self.duration)
                self.staves[staff_number].append(note)



if __name__ == "__main__":

    pset = abjad.PitchSet(
    ["g'", "a'", "b'"],
    item_class=abjad.NamedPitch,
    )

    m = SkeletonMaker(pset)
    score = m(abjad.Duration(1,4), 10)
    abjad.show(score)
    abjad.play(score)
Пример #7
0
from ornament.suspension.suspension_dictionary import suspension_dictionary
from ornament.passaggi.passaggi_dictionary import passaggi_dictionary
from ornament.unison.unison_dictionary import unison_dictionary

random.seed(3)  # 2, 3,  is not bad

pset = abjad.PitchSet(
    ["g'", "a'", "b'"],
    item_class=abjad.NamedPitch,
)

# choose a skeleton
# skeleton = preprocessed_skeletons[1]
skeleton_maker = SkeletonMaker(pset)
skeleton = skeleton_maker(abjad.Duration(1, 4), 10)
scale = tonality.Scale(('a', 'minor'))
pitch_range = abjad.pitch.PitchRange('[E2, B5]')
dict_tuple = (suspension_dictionary, passaggi_dictionary, unison_dictionary)

maker = SegmentMaker(scale, pitch_range)
maker(skeleton, dict_tuple,
      n_attacks=3)  # calling the maker instance configures and decorates

lilypond_file = abjad.LilyPondFile.new(music=maker.skeleton)

lilypond_file.header_block.title = abjad.Markup(r'Past Machine 1')
lilypond_file.header_block.composer = abjad.Markup('J. R. Trevino, 2019')

abjad.show(lilypond_file)
abjad.play(lilypond_file)