File size: 535 Bytes
5e84ffc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""Note transposer."""

from improvisation_lab.domain.music_theory import Notes


class NoteTransposer:
    """Class responsible for transposing notes."""

    def __init__(self):
        """Initialize NoteTransposer."""
        pass

    def transpose_note(self, note: Notes, interval: int) -> Notes:
        """Transpose a note by a given interval."""
        chromatic_scale = Notes.get_chromatic_scale(note.value)
        transposed_index = (interval) % len(chromatic_scale)
        return Notes(chromatic_scale[transposed_index])