Esempio n. 1
0
def apply_dynamics(section, score):
    for part, token in iterate_score_parts_for_attribute(
        section,
        score,
        'dynamics',
        ):
        if token:
            if isinstance(token, baca.tools.DynamicsSpecifier):
                token.apply(part)
            elif token[0] == '<>':
                apply_swells(part, token)
            elif token[0] == '<':
                apply_crescendi(part, token)
            elif token[0] == 'rest-terminated <':
                apply_rest_terminated_crescendi(part, token)
            elif token[0] == 'rest-terminated pattern':
                apply_rest_terminated_pattern(part, token)
            elif token[0] == 'rest-delimited':
                apply_rest_delimited_hairpin(part, token)
            elif 'sempre' in token[0]:
                apply_sempre(part, token)
            elif token[0] == 'terraces':
                apply_terraces(part, token)
            else:
                raise ValueError('unknown token %s.' % str(token))
Esempio n. 2
0
def register_pitches(section, score):
    for part, token in iterate_score_parts_for_attribute(
        section,
        score,
        'registration',
        ):
        if not token:
            continue
        for leaf in leaftools.iterate_leaves_in_expr(part):
            if token == vatz:
                if isinstance(leaf, Note):
                    leaf.written_pitch_indication_is_nonsemantic = True
                    #leaf.pitch = 11
                    leaf.pitch = 0
                elif isinstance(leaf, Chord):
                    leaf.written_pitch_indication_is_nonsemantic = True
                    #leaf.pitches = [11]
                    leaf.pitches = [0]
                continue
            if isinstance(leaf, Note):
                n = leaf.pitch.pitch_number
                n = pitchtools.transpose_pitch_number_by_octave_transposition_mapping(
                    n, token)
                leaf.pitch = n
            elif isinstance(leaf, Chord):
                nn = [nh.pitch.pitch_number for nh in leaf]
                nn = [pitchtools.transpose_pitch_number_by_octave_transposition_mapping(
                    n, token) for n in nn]
                leaf.pitches = nn
Esempio n. 3
0
def annotate_chord_counts(section, score):
    for part, token in iterate_score_parts_for_attribute(section, score, 'chord_counts'):
        if token:
            token = sequencetools.CyclicTuple(token)
            for i, note_or_chord in enumerate(
                leaftools.iterate_notes_and_chords_in_expr(part)):
                chord_count = token[i]
                marktools.Annotation('chord_count', chord_count)(note_or_chord)
Esempio n. 4
0
def annotate_trope_indices(section, score):
    for part, token in iterate_score_parts_for_attribute(section, score, 'troping'):
        if token is None:
            continue
        token = sequencetools.CyclicTuple(token)
        for i, note_or_chord in enumerate(leaftools.iterate_notes_and_chords_in_expr(part)):
            trope_index = token[i]
            marktools.Annotation('trope', trope_index)(note_or_chord)
Esempio n. 5
0
def annotate_pitch_indicators(section, score):
    for part, token in iterate_score_parts_for_attribute(section, score, 'pitches'):
        for note_or_chord in leaftools.iterate_notes_and_chords_in_expr(part):
            marktools.Annotation('pitch', token)(note_or_chord)