Пример #1
0
    def parse_tones_poly(self, filename, model_name):
        notes = Staff()
        # remove measure and tacts
        notes.remove_commands.append('Time_signature_engraver')
        notes.remove_commands.append('Bar_engraver')

        mala_voice = ""
        vela_voice = ""
        tones_dict = self.get_tones_dict_poly()
        for mala_tone, tone_length in tones_dict['m']:
            duration = self.get_duration_label(tone_length)

            if duration:
                mala_voice += mala_tone + duration + " "

        for vela_tone, tone_length in tones_dict['v']:
            duration = self.get_duration_label(tone_length)

            if duration:
                vela_voice += vela_tone + duration + " "

        mala_voice = Voice(mala_voice, name='mala voice')
        literal = LilyPondLiteral(r'\voiceOne')
        attach(literal, mala_voice)

        vela_voice = Voice(vela_voice, name='vela voice')
        literal = LilyPondLiteral(r'\voiceTwo')
        attach(literal, vela_voice)

        container = Container([mala_voice, vela_voice])
        container.is_simultaneous = True
        notes.append(container)

        PersistenceManager(client=notes).as_pdf(
            os.path.join(SHEETS_DIR, model_name, filename))
Пример #2
0
    def __call__(self):

        # Violin
        violin_staff = Staff(
            [Voice(name='Violin Voice')],
            name='Violin Staff',
            context_name='ViolinStaff',
        )
        violin_tag = LilyPondCommand(r"tag #'violin", format_slot='before')
        attach(violin_tag, violin_staff)
        attach(Clef('treble'), violin_staff)
        attach(instrumenttools.Violin(), violin_staff)
        set_(violin_staff).midi_instrument = schemetools.Scheme(
            'violin', force_quotes=True)

        # Viola
        viola_staff = Staff(
            [Voice(name='Viola Voice')],
            name='Viola Staff',
            context_name='ViolaStaff',
        )
        viola_tag = LilyPondCommand(r"tag #'viola", format_slot='before')
        attach(viola_tag, viola_staff)
        attach(Clef('alto'), viola_staff)
        attach(instrumenttools.Viola(), viola_staff)
        set_(viola_staff).midi_instrument = schemetools.Scheme(
            'viola', force_quotes=True)

        # Cello
        cello_staff = Staff(
            [Voice(name='Cello Voice')],
            name='Cello Staff',
            context_name='CelloStaff',
        )
        cello_tag = LilyPondCommand(r"tag #'cello", format_slot='before')
        attach(cello_tag, cello_staff)
        attach(Clef('bass'), cello_staff)
        attach(instrumenttools.Cello(), cello_staff)
        set_(cello_staff).midi_instrument = schemetools.Scheme(
            'cello', force_quotes=True)

        # Everything else
        staff_group = StaffGroup(
            [violin_staff, viola_staff, cello_staff],
            name='Trio Staff Group',
        )
        score = Score(
            [staff_group],
            name='Trio Score',
        )

        return score
Пример #3
0
 def __call__(self, target: abjad.Voice):
     sequence = self._sequence
     sequence.simulate_queue(tag_as_pitch=self._tag_as_pitch)
     results = []
     for server in sequence.servers:
         q_event_sequence = server.q_event_sequence
         result = self._quantizer(
             q_event_sequence,
             q_schema=self._q_schema,
             grace_handler=self._grace_handler,
             heuristic=self._heuristic,
             attack_point_optimizer=self._attack_point_optimizer,
             attach_tempos=self._attach_tempos,
         )
         results.append(result)
     assert len(results) == 1
     result = results[0]
     target.extend(result)
Пример #4
0
 def _make_measures(self, time_signatures, rhythm_maker, pitches, seed):
     seed = seed or 0
     measures = Voice()
     for time_signature in time_signatures:
         multimeasure_rest = MultimeasureRest(1)
         multiplier = Multiplier(time_signature)
         attach(multiplier, multimeasure_rest)
         measures.append(Measure(time_signature, [multimeasure_rest]))
     if rhythm_maker is not None:
         divisions = rhythm_maker(time_signatures, rotation=seed)
         mutate(measures).replace_measure_contents(divisions)
     if pitches is not None:
         if not isinstance(pitches, collections.Iterable):
             pitches = [pitches]
         iterator = iterate(measures).by_logical_tie(pitched=True)
         iterator = enumerate(iterator, seed)
         for i, logical_tie in iterator:
             pitch = pitches[i % len(pitches)]
             for leaf in logical_tie:
                 leaf.written_pitch = pitch
     return measures
Пример #5
0
def make_bartok_score():
    score = Score([])
    piano_staff = StaffGroup([], context_name='PianoStaff')
    upper_staff = Staff([])
    lower_staff = Staff([])
    piano_staff.append(upper_staff)
    piano_staff.append(lower_staff)
    score.append(piano_staff)
    upper_measures = []
    upper_measures.append(Measure((2, 4), []))
    upper_measures.append(Measure((3, 4), []))
    upper_measures.append(Measure((2, 4), []))
    upper_measures.append(Measure((2, 4), []))
    upper_measures.append(Measure((2, 4), []))
    lower_measures = copy.deepcopy(upper_measures)
    upper_staff.extend(upper_measures)
    lower_staff.extend(lower_measures)
    upper_measures[0].extend("a'8 g'8 f'8 e'8")
    upper_measures[1].extend("d'4 g'8 f'8 e'8 d'8")
    upper_measures[2].extend("c'8 d'16 e'16 f'8 e'8")
    upper_measures[3].append("d'2")
    upper_measures[4].append("d'2")
    lower_measures[0].extend("b4 d'8 c'8")
    lower_measures[1].extend("b8 a8 af4 c'8 bf8")
    lower_measures[2].extend("a8 g8 fs8 g16 a16")
    upper_voice = Voice("b2", name='upper voice')
    command = indicatortools.LilyPondCommand('voiceOne')
    attach(command, upper_voice)
    lower_voice = Voice("b4 a4", name='lower voice')
    command = indicatortools.LilyPondCommand('voiceTwo')
    attach(command, lower_voice)
    lower_measures[3].extend([upper_voice, lower_voice])
    lower_measures[3].is_simultaneous = True
    upper_voice = Voice("b2", name='upper voice')
    command = indicatortools.LilyPondCommand('voiceOne')
    attach(command, upper_voice)
    lower_voice = Voice("g2", name='lower voice')
    command = indicatortools.LilyPondCommand('voiceTwo')
    attach(command, lower_voice)
    lower_measures[4].extend([upper_voice, lower_voice])
    lower_measures[4].is_simultaneous = True
    clef = Clef('bass')
    attach(clef, lower_staff)
    dynamic = Dynamic('pp')
    attach(dynamic, upper_measures[0][0])
    dynamic = Dynamic('mp')
    attach(dynamic, upper_measures[1][1])
    dynamic = Dynamic('pp')
    attach(dynamic, lower_measures[0][1])
    dynamic = Dynamic('mp')
    attach(dynamic, lower_measures[1][3])
    score.add_final_bar_line()
    selector = select().by_leaf(flatten=True)
    upper_leaves = selector(upper_staff)
    lower_leaves = selector(lower_staff)
    beam = Beam()
    attach(beam, upper_leaves[:4])
    beam = Beam()
    attach(beam, lower_leaves[1:5])
    beam = Beam()
    attach(beam, lower_leaves[6:10])
    slur = Slur()
    attach(slur, upper_leaves[:5])
    slur = Slur()
    attach(slur, upper_leaves[5:])
    slur = Slur()
    attach(slur, lower_leaves[1:6])
    crescendo = Crescendo()
    attach(crescendo, upper_leaves[-7:-2])
    decrescendo = Decrescendo()
    attach(decrescendo, upper_leaves[-2:])
    markup = Markup('ritard.')
    text_spanner = spannertools.TextSpanner()
    override(text_spanner).text_spanner.bound_details__left__text = markup
    attach(text_spanner, upper_leaves[-7:])
    tie = Tie()
    attach(tie, upper_leaves[-2:])
    note_1 = lower_staff[-2]['upper voice'][0]
    note_2 = lower_staff[-1]['upper voice'][0]
    notes = [note_1, note_2]
    tie = Tie()
    attach(tie, notes)
    return score
Пример #6
0
 def __call__(self):
     voice = Voice(name='Example Voice')
     staff = Staff([voice], name='Example Staff')
     score = Score([staff], name='Example Score')
     return score