musicaiz.algorithms.harmonic_shifting

musicaiz.algorithms.harmonic_shifting(origin_notes: List[List[musicaiz.structure.notes.Note]], origin_progression: List[List[str]], origin_tonality: str, origin_scale: str, target_progression: List[List[str]], target_tonality: str, target_scale: str) List[List[musicaiz.structure.notes.Note]][source]

This function maps the pitches of a midi to a new scale and chord progression. To do that, given the progression of the input midi and the target scale and progression, we analyze the note position in the chord built from a degree and we map the pitch to the same position in the target degree chord. Note that for using this function we should know in advance the degrees that are contained in each bar, but we don’t need to know where are the transitions from a degree to another inside the bar.

Parameters
origin_notes: List[Note]

the original midi data.

origin_progression: List[List[str]]

the target degrees per bar.

origin_tonality: str

the origin tonality.

origin_scale: str

the origin scale.

target_progression: List[List[str]]

the target degrees per bar.

target_tonality: str

the target scale.

target_scale: str

the target scale.

Returns
origin_notes: List[Note]

Examples

Example of 2 bars, 1st bar with 3 notes and 2nd bar with 1 note:

>>> origin_notes = [  # each list corresponds to the notes in a bar
>>>     [
>>>         Note(pitch=43, start=0, end=96, velocity=82),
>>>         Note(pitch=58, start=96, end=96*2, velocity=82),
>>>         Note(pitch=60, start=96*2, end=96*3, velocity=82),
>>>     ],
>>>     [
>>>         Note(pitch=72, start=96*4, end=96*5, velocity=44)
>>>     ]
>>> ]
>>> origin_bars = [["II", "IV"], ["VII"]]
>>> origin_tonality = "G_MINOR"
>>> origin_scale = "NATURAL"
>>> target_progression = [["I", "V"], ["IV"]]
>>> target_tonality = "C_MINOR"
>>> target_scale = "NATURAL"