automuse.chord package
Submodules
automuse.chord.counted module
Utilities that construct chords by counting intervals.
Module contents
Utilities that construct chords.
- automuse.chord.transpose(note: str, by: int) str[source]
- automuse.chord.transpose(note: list[str], by: int) list[str]
Local copy of
chord.transpose().Here to avoid circular import.
- automuse.chord.chord(tonic: str, mode: list[int], order: int = 0, add: int | list[int] | None = None, sus: int | list[int] | None = None, sharp: int | list[int] | None = None, flat: int | list[int] | None = None, raw_offsets: Sequence[str | int] | None = None) list[str][source]
Construct a chord from a scale. Construct a triad by default.
If
tonicis an empty string, return an empty list.- Parameters:
tonic – Root of the chord.
mode – Mode of the chord, for example
modes.MAJOR.order – Order of the chord, for example 1 for \(\text{I}\).
add – Scale degrees to add, 0 indexed.
sus – Scale degrees to remove, 0 indexed.
sharp – Scale degrees to add then raise by one semitone.
flat – Scale degrees to add then lower by one semitone.
raw_offsets – Extra notes to add to the chord, specified as semitone offsets from the tonic. Last resort.
order – Order of scale. For example, 0 means \(\text{I}\) and 1 means \(\text{II}\)
Warning
susis applied beforeaddand simply takes away degrees, instead of replacing them.To replace a degree, add the replacement in :add:`raw_intervals`: for example, you can call
chord(..., sus=[2], raw_intervals="diminished 2").
- automuse.chord.seventh(tonic: str, mode: list[int], type: Literal['major'] | Literal['minor'] | Literal['augmented'] | Literal['diminished'] | None = None, add: int | list[int] | None = None, sus: int | list[int] | None = None, sharp: int | list[int] | None = None, flat: int | list[int] | None = None, raw_offsets: list[int] | list[str] | None = None, order: int = 0) list[str][source]
Construct a seventh chord from a scale. Can add custom \(\hat{7}\)s.
See
chord()for parameters.
- automuse.chord.neapolitan_chord(tonic: str, intervals: list[int]) list[str][source]
Construct a Neapolitan chord from a scale.
- automuse.chord.power(root: str) list[str][source]
Construct the power chord of
root.A power chord has no major and minor qualities, because it always consists of the root and a perfect fifth.
- automuse.chord.rewop(root: str) list[str][source]
Inverse of
power(). Useful for, for example, adding bass to a note.
- class automuse.chord.ChordArgsDict[source]
Bases:
TypedDictA
dictthat captures the interface ofchord(). Unpack to use.- tonic: str
- mode: list[int]
- order: int
- add: int | list[int]
- sus: int | list[int]
- sharp: int | list[int]
- flat: int | list[int]
- raw_offsets: Sequence[str | int]
- class automuse.chord.ChordArgs[source]
Bases:
objectPacked arguments for
chord.- tonic: str
- mode: list[int]
- order: int
- add: int | list[int] | None
- sus: int | list[int] | None
- sharp: int | list[int] | None
- flat: int | list[int] | None
- raw_offsets: Sequence[str | int] | None
- inversion: int = 0
- mode_name: str = '?'
- to_dict() ChordArgsDict[source]
Return a
dictthat can be unpacked inchord().Does not contain keys that are not parameter in
chord().
- __init__(tonic: str, mode: list[int], order: int, add: int | list[int] | None, sus: int | list[int] | None, sharp: int | list[int] | None, flat: int | list[int] | None, raw_offsets: Sequence[str | int] | None, inversion: int = 0, mode_name: str = '?') None
- automuse.chord.chord_to_name(tonic: str, mode_name: str, order: int, chord_type: Literal['triad'] | Literal['seventh'], inversion: int, seventh_type: Literal['major'] | Literal['minor'] | Literal['augmented'] | Literal['diminished'] | None = None, include_tonic: bool = True) str[source]
- automuse.chord.chord_to_quality(chord: list[str], offsets_to_quality: dict[tuple[int, ...], str] = {(3, 6): '-', (3, 6, 9): '⁻⁷', (3, 6, 10): 'ᶲ⁷', (3, 6, 11): 'mᴹ⁷ᵇ⁵', (3, 7): 'm', (3, 7, 10): 'm⁷', (3, 7, 11): 'mᴹ⁷', (3, 8): '+', (4, 6, 10): '⁷ᵇ⁵', (4, 6, 11): '⁷ᵇ⁵', (4, 7): 'M', (4, 7, 10): '⁷', (4, 7, 11): 'M⁷', (4, 8, 10): '+⁷', (4, 8, 11): '+ᴹ⁷'})[source]
Return the quality of
chord. Useoffsets_to_qualityto determine how intervals map to qualities (for example,(4, 7)maps toMfor Major).If
chordhas 3 notes, treat it as a triad; otherwise, slice the first four notes fromchordand treat it as a seventh.Return
🐆followed by offsets if the quality cannot be determined; Ifchordis empty, simply return🐆.