automuse.chord package

Submodules

automuse.chord.counted module

Utilities that construct chords by counting intervals.

automuse.chord.counted.count_triad_major(root: str) list[str][source]
automuse.chord.counted.count_triad_minor(root: str) list[str][source]
automuse.chord.counted.count_triad_augmented(root: str) list[str][source]
automuse.chord.counted.count_triad_diminished(root: str) list[str][source]
automuse.chord.counted.count_seventh_dominant(root: str) list[str][source]
automuse.chord.counted.count_seventh_major(root: str) list[str][source]
automuse.chord.counted.count_seventh_minor(root: str) list[str][source]
automuse.chord.counted.count_seventh_half_diminished(root: str) list[str][source]
automuse.chord.counted.count_seventh_diminished(root: str) list[str][source]
automuse.chord.counted.count_seventh_minor_major(root: str) list[str][source]
automuse.chord.counted.count_seventh_augmented_major(root: str) list[str][source]
automuse.chord.counted.count_seventh_augmented_minor(root: str) list[str][source]

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 tonic is 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

sus is applied before add and 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: TypedDict

A dict that captures the interface of chord(). 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: object

Packed 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 dict that can be unpacked in chord().

Does not contain keys that are not parameter in chord().

to_str() str[source]
__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. Use offsets_to_quality to determine how intervals map to qualities (for example, (4, 7) maps to M for Major).

If chord has 3 notes, treat it as a triad; otherwise, slice the first four notes from chord and treat it as a seventh.

Return 🐆 followed by offsets if the quality cannot be determined; If chord is empty, simply return 🐆.