Saltar a contenido

FoxDotChord.__chord__

FoxDotChord._pattern.__chord__ 🔗

Bases: __pattern__

Composing chords and progressions.

Progression

  • c[...] or c(...): creates a new progression.

Random/Stutters

  • c*[...]: set random values.

  • c*(...): distribute the values by the current "dur".

Shuffles

  • c**[...] or c**(...): shuffles the values.

Delays

  • c^[..., dur] or c^(..., dur): creates a PGroup that delays each value in dur * n.

Stutters

  • c+[...] or c+(...): stutters the values over the length of and event's 'sus'.

  • c/[...] or c/(...): stutter every other request.

Source code in FoxDotChord/_pattern.py
class __chord__(__pattern__):  # noqa: N801, pylint: disable=invalid-name
    """
    Composing chords and progressions.

    **_`Progression`_**

    - `c[...]` or `c(...)`:
      creates a new progression.

    **_`Random/Stutters`_**

    - `c*[...]`:
      set random values.

    - `c*(...)`:
      distribute the values by the current "dur".

    **_`Shuffles`_**

    - `c**[...]` or `c**(...)`:
      shuffles the values.

    **_`Delays`_**

    - `c^[..., dur]` or `c^(..., dur)`:
       creates a PGroup that delays each value in dur * n.

    **_`Stutters`_**

    - `c+[...]` or `c+(...)`:
      stutters the values over the length of and event's 'sus'.

    - `c/[...]` or `c/(...)`:
      stutter every other request.
    """

    def __getitem__(self, args) -> Union['ChordPattern', TimeVar]:
        """
        Creates a harmonic progression based on a list of chords.
        e.g. `c[...]`

        Parameters
        ----------
        args : Any
            Many chords or others patterns.

        Examples
        --------
        **_`Progression:`_**

        You can create a chord pattern in a few ways.

        One of them is using a list of strings:

        >>> c['Am7', 'C7/9', 'F7Maj', 'G4/9/13']
        P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]

        Or passing a string of chords separated by `space`:

        >>> c['Am7 C7/9 F7Maj G4/9/13']
        P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]

        **_`Repetition:`_**

        You can also set how many times the chord will be repeated

        >>> c['C!4 Dm!2'].json_value()
        ['TimeVar', [Chord('C'), Chord('Dm')], [4.0, 2.0]]

        Or repeat the number of times the arpeggio will be made

        >>> c['C!4 Dm!2 G7@!2'].json_value()
        ['TimeVar', [Chord('C'), Chord('Dm'), 4, 6, 8, 10], [4.0, 2.0, 2.0, 2.0, 2.0, 2.0]]

        Or first repeat the chord and then arpeggiate each repetition

        >>> c['G7!2@']
        P[4, 6, 8, 10, 4, 6, 8, 10]

        Repetition of a group can be done by multiplying it,
        either as a `string` or `list`:

        >>> c['Dm7/11!8 Bb7M!7 Bb7M/5- ' * 2 + 'Dm7M/9!4 Bb7M!2 G7/9!2 ' * 2].json_value()
        ['TimeVar', [Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9')], [8.0, 7.0, 1.0, 8.0, 7.0, 1.0, 4.0, 2.0, 2.0, 4.0, 2.0, 2.0]]

        >>> c[['Dm7/11!8 Bb7M!7 Bb7M/5-'] * 2 + ['Dm7M/9!4 Bb7M!2 G7/9!2'] * 2].json_value()
        ['TimeVar', [Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9')], [8.0, 7.0, 1.0, 8.0, 7.0, 1.0, 4.0, 2.0, 2.0, 4.0, 2.0, 2.0]]

        It must also accept repetition values that are not integers:

        >>> c['B7M D7 G7M Bb7!.75 Eb7M!2.75 Am7!.75 D7'].json_value()
        ['TimeVar', [Chord('B7M'), Chord('D7'), Chord('G7M'), Chord('Bb7'), Chord('Eb7M'), Chord('Am7'), Chord('D7')], [1.0, 1.0, 1.0, 0.75, 2.75, 0.75, 1.0]]

        **_`Mixing inputs:`_**

        >>> c['C  D ', [1, 4], 'Dm E#', (2, 3), 1]
        P[Chord('C'), Chord('D'), P[1, 4], Chord('Dm'), Chord('E#'), P(2, 3), 1]

        >>> c[1, 'C D', [1, 4], 'Dm E#@', (2, 3)]
        P[1, Chord('C'), Chord('D'), P[1, 4], Chord('Dm'), 3, 5, 7, P(2, 3)]

        >>> c[(2, 3), 'C!4 D', [1, 4], 'Dm@!3', 1].json_value()
        ['TimeVar', [P(2, 3), Chord('C'), Chord('D'), 1, 1, 3, 5, 1, P(2, 3), Chord('C'), Chord('D'), 4, 1, 3, 5, 1], [1.0, 4.0, 1.0, 1.0, 3.0, 3.0, 3.0, 1.0, 1.0, 4.0, 1.0, 1.0, 3.0, 3.0, 3.0, 1.0]]

        >>> c[1, c['C D'].arp(), [1, 4], c['Dm E#@'], (2, 3)]
        P[1, P[0, 2, 4, 1, 3.5, 5], P[1, 4], P[Chord('Dm'), 3, 5, 7], P(2, 3)]

        **_`Composition:`_**

        You can put chords in a list to alternate between them.
        In the example below, the first three chords (`#!python 'E7M G⁰ G#m7'`)
        will be played once in the sequence while the list
        (`#!python ['C#7/13 B7/13']` ) will alternatively be:

        - E7M G⁰ G#m7 `C#7/13`
        - E7M G⁰ G#m7 `B7/13`

        >>> c['E7M G⁰ G#m7', ['C#7/13 B7/13']]
        P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P[Chord('C#7/13'), Chord('B7/13')]]

        Or using `#!python '()'`, like:

        >>> c['E7M G⁰ G#m7 (C#7/13 B7/13)']
        P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P[Chord('C#7/13'), Chord('B7/13')]]

        >>> c['E7M!4 G⁰!4 G#m7!4', ['C#7/13!4 B7/13!4']].json_value()
        ['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('C#7/13'), Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('B7/13')], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

        With `#!python '()'`:

        >>> c['E7M!4 G⁰!4 G#m7!4 (C#7/13!4 B7/13!4)'].json_value()
        ['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('C#7/13'), Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('B7/13')], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

        To play a group together at the same time, use a `tuple` to form the
        chords:

        >>> c['E7M G⁰ G#m7', ('C#7/13', 'B7/13')]
        P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))]

        Or use `#!python '<><>'`

        >>> c['E7M G⁰ G#m7 < C#7/13 >< B7/13 >']
        P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))]

        >>> c['E7M!4 G⁰!4 G#m7!4', ('C#7/13!4', 'B7/13!4')].json_value()
        ['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

        Ot with `#!python <><>`

        >>> c['E7M!4 G⁰!4 G#m7!4 <C#7/13!4> <B7/13!4>'].json_value()
        ['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

        Returns
        -------
        Pattern
            Chord progression.
        TimeVar
            If any repetition is defined other than 1
        """  # noqa: E501
        if not isinstance(args, tuple):
            args = (args,)

        chords, durs = [], []

        for pattern in args:
            for chord, dur in zip(*parse_chords(pattern)):
                if not isinstance(chord, Extendable):
                    chords.append(chord)
                    durs.append(dur)
                else:
                    chords.extend(chord)
                    if isinstance(dur, Iterable):
                        durs.append(dur)
                    else:
                        durs.extend([dur for _ in range(len(chord))])

        if any(filter(lambda r: r > 1, flat(durs))):
            return TimeVar(chords, durs)

        return ChordPattern(chords)

    def __call__(self, *args):
        """
        Creates a harmonic progression based on a list of chords.
        e.g. `c(...)`

        Parameters
        ----------
        args : Any
            Many chords or others patterns.

        Examples
        --------
        You can create a chord pattern in a few ways.

        One of them is using `[]` or `()` with a list of strings
        or passing a string of chords separated by `space`:

        >>> c('Am7', 'C7/9', 'F7Maj', 'G4/9/13')
        P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]
        >>> c('Am7 C7/9 F7Maj G4/9/13')
        P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]

        Returns
        -------
        Pattern
            Chord progression.
        TimeVar
            If any repetition is defined other than 1
        """
        return self.__getitem__(args)

    def __mul__(self, other):
        """
        Random  `[]` or spreads `()`.
        e.g. `c*[...]` or `c*(...)`

        Parameters
        ----------
        other : Any
            Another object.

        Examples
        --------
        **_`Random:`_**

        Use `[]` to set random values:

        >>> c*['A C']
        PRand(P[Chord('A'), Chord('C')])

        Or using `#!python '{}'`

        >>> c['{A C}']
        P[PRand(P[Chord('A'), Chord('C')])]

        **_`Stutters`_**

        You can spreads the values across the current “dur”.

        If the dur is 4 beats then it will play each value 2/4 beats apart:

        >>> c['Am7', c*('Bm7 E7')]
        P[Chord('Am7'), P*(Chord('Bm7'), Chord('E7'))]

        Or with `#!python '[]'`

        >>> c['Am7 [Bm7 E7]']
        P[Chord('Am7'), P*(Chord('Bm7'), Chord('E7'))]

        In the example above, `Am7` will be played for a full beat while `Bm7`
        and `E7` will be played before the end of the beat.

        This can be interesting in arpeggios.

        >>> c[c*('Am7/2@'), c*(c*('Bm7@'), c*('E7@'))]
        P[P*(5, 6, 7, 9, 11), P*(P*(6, 8, 10.5, 12), P*(2, 4.5, 6, 8))]

        >>> c['[Am7/2@] [[Bm7@]  [E7@]]']
        P[P*(5, 6, 7, 9, 11), P*(P*(6, 8, 10.5, 12), P*(2, 4.5, 6, 8))]

        For example:

        ```python
        p1 >> keys(c['Am7 [Bm7 E7]'], dur=4)
        b1 >> bassguitar(c['[Am7/2@] [[Bm7@] [E7@]]'], dur=4)
        ```

        Returns
        -------
        PRand
            If a list or a Pattern is a step, the returned value will be PRand.
        PGroupStar
            Stutters the values over the length of and event's "dur".
        """
        if isinstance(other, (list, Pattern)):
            return PRand(list(self(other)))
        if isinstance(other, (tuple)):
            return PGroupStar(self(*other))
        return PGroupStar(self(other))

    def __pow__(self, other):
        """
        Returns scrambled version.
        e.g. `c**[...]`

        Parameters
        ----------
        other : Any
            Another object.

        Examples
        --------
        >>> c**('A C')
        P**(Chord('A'), Chord('C'))
        >>> c**['A C']
        P**(Chord('A'), Chord('C'))

        Returns
        -------
        PGroupPow
            Shuffled values.
        """
        return super().__pow__(self(other))

    def __xor__(self, other):
        """
        Returns a PGroup that delays each value by dur * n.
        e.g. `c^[..., dur]`

        Parameters
        ----------
        other : Any
            Another object.

        Examples
        --------
        >>> c^('A C', 4)
        P^(Chord('A'), Chord('C'))

        Returns
        -------
        PGroupXor
            Pattern with delay.
        """
        new = self(*other) if isinstance(other, tuple) else self(other)
        return super().__xor__(new)

    def __add__(self, other):
        """
        Stutters the values over the length of and event's 'sus'.
        e.g. `c+[...]`

        Parameters
        ----------
        other : Any
            Another object.

        Examples
        --------
        >>> c+('A C')
        P+(Chord('A'), Chord('C'))
        >>> ('A C')+c
        P+(Chord('A'), Chord('C'))

        Returns
        -------
        PGroupPlus
            Stuttered values.
        """
        return super().__add__(self(other))

    def __truediv__(self, other):
        """
        Stutter every other request.
        e.g. `c/[...]`

        Parameters
        ----------
        other : Any
            Another object.

        Examples
        --------
        >>> c/('A C')
        P/(Chord('A'), Chord('C'))

        Returns
        -------
        PGroupDiv
            Stuttered values.
        """
        return super().__truediv__(self(other))

__getitem__(args) -> Union[ChordPattern, TimeVar] 🔗

Creates a harmonic progression based on a list of chords. e.g. c[...]

Parameters:

Name Type Description Default
args Any

Many chords or others patterns.

required

Examples:

Progression:

You can create a chord pattern in a few ways.

One of them is using a list of strings:

>>> c['Am7', 'C7/9', 'F7Maj', 'G4/9/13']
P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]

Or passing a string of chords separated by space:

>>> c['Am7 C7/9 F7Maj G4/9/13']
P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]

Repetition:

You can also set how many times the chord will be repeated

>>> c['C!4 Dm!2'].json_value()
['TimeVar', [Chord('C'), Chord('Dm')], [4.0, 2.0]]

Or repeat the number of times the arpeggio will be made

>>> c['C!4 Dm!2 G7@!2'].json_value()
['TimeVar', [Chord('C'), Chord('Dm'), 4, 6, 8, 10], [4.0, 2.0, 2.0, 2.0, 2.0, 2.0]]

Or first repeat the chord and then arpeggiate each repetition

>>> c['G7!2@']
P[4, 6, 8, 10, 4, 6, 8, 10]

Repetition of a group can be done by multiplying it, either as a string or list:

>>> c['Dm7/11!8 Bb7M!7 Bb7M/5- ' * 2 + 'Dm7M/9!4 Bb7M!2 G7/9!2 ' * 2].json_value()
['TimeVar', [Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9')], [8.0, 7.0, 1.0, 8.0, 7.0, 1.0, 4.0, 2.0, 2.0, 4.0, 2.0, 2.0]]
>>> c[['Dm7/11!8 Bb7M!7 Bb7M/5-'] * 2 + ['Dm7M/9!4 Bb7M!2 G7/9!2'] * 2].json_value()
['TimeVar', [Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9')], [8.0, 7.0, 1.0, 8.0, 7.0, 1.0, 4.0, 2.0, 2.0, 4.0, 2.0, 2.0]]

It must also accept repetition values that are not integers:

>>> c['B7M D7 G7M Bb7!.75 Eb7M!2.75 Am7!.75 D7'].json_value()
['TimeVar', [Chord('B7M'), Chord('D7'), Chord('G7M'), Chord('Bb7'), Chord('Eb7M'), Chord('Am7'), Chord('D7')], [1.0, 1.0, 1.0, 0.75, 2.75, 0.75, 1.0]]

Mixing inputs:

>>> c['C  D ', [1, 4], 'Dm E#', (2, 3), 1]
P[Chord('C'), Chord('D'), P[1, 4], Chord('Dm'), Chord('E#'), P(2, 3), 1]
>>> c[1, 'C D', [1, 4], 'Dm E#@', (2, 3)]
P[1, Chord('C'), Chord('D'), P[1, 4], Chord('Dm'), 3, 5, 7, P(2, 3)]
>>> c[(2, 3), 'C!4 D', [1, 4], 'Dm@!3', 1].json_value()
['TimeVar', [P(2, 3), Chord('C'), Chord('D'), 1, 1, 3, 5, 1, P(2, 3), Chord('C'), Chord('D'), 4, 1, 3, 5, 1], [1.0, 4.0, 1.0, 1.0, 3.0, 3.0, 3.0, 1.0, 1.0, 4.0, 1.0, 1.0, 3.0, 3.0, 3.0, 1.0]]
>>> c[1, c['C D'].arp(), [1, 4], c['Dm E#@'], (2, 3)]
P[1, P[0, 2, 4, 1, 3.5, 5], P[1, 4], P[Chord('Dm'), 3, 5, 7], P(2, 3)]

Composition:

You can put chords in a list to alternate between them. In the example below, the first three chords ('E7M G⁰ G#m7') will be played once in the sequence while the list (['C#7/13 B7/13'] ) will alternatively be:

  • E7M G⁰ G#m7 C#7/13
  • E7M G⁰ G#m7 B7/13
>>> c['E7M G⁰ G#m7', ['C#7/13 B7/13']]
P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P[Chord('C#7/13'), Chord('B7/13')]]

Or using '()', like:

>>> c['E7M G⁰ G#m7 (C#7/13 B7/13)']
P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P[Chord('C#7/13'), Chord('B7/13')]]
>>> c['E7M!4 G⁰!4 G#m7!4', ['C#7/13!4 B7/13!4']].json_value()
['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('C#7/13'), Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('B7/13')], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

With '()':

>>> c['E7M!4 G⁰!4 G#m7!4 (C#7/13!4 B7/13!4)'].json_value()
['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('C#7/13'), Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('B7/13')], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

To play a group together at the same time, use a tuple to form the chords:

>>> c['E7M G⁰ G#m7', ('C#7/13', 'B7/13')]
P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))]

Or use '<><>'

>>> c['E7M G⁰ G#m7 < C#7/13 >< B7/13 >']
P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))]
>>> c['E7M!4 G⁰!4 G#m7!4', ('C#7/13!4', 'B7/13!4')].json_value()
['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

Ot with <><>

>>> c['E7M!4 G⁰!4 G#m7!4 <C#7/13!4> <B7/13!4>'].json_value()
['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

Returns:

Type Description
Pattern

Chord progression.

TimeVar

If any repetition is defined other than 1

Source code in FoxDotChord/_pattern.py
def __getitem__(self, args) -> Union['ChordPattern', TimeVar]:
    """
    Creates a harmonic progression based on a list of chords.
    e.g. `c[...]`

    Parameters
    ----------
    args : Any
        Many chords or others patterns.

    Examples
    --------
    **_`Progression:`_**

    You can create a chord pattern in a few ways.

    One of them is using a list of strings:

    >>> c['Am7', 'C7/9', 'F7Maj', 'G4/9/13']
    P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]

    Or passing a string of chords separated by `space`:

    >>> c['Am7 C7/9 F7Maj G4/9/13']
    P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]

    **_`Repetition:`_**

    You can also set how many times the chord will be repeated

    >>> c['C!4 Dm!2'].json_value()
    ['TimeVar', [Chord('C'), Chord('Dm')], [4.0, 2.0]]

    Or repeat the number of times the arpeggio will be made

    >>> c['C!4 Dm!2 G7@!2'].json_value()
    ['TimeVar', [Chord('C'), Chord('Dm'), 4, 6, 8, 10], [4.0, 2.0, 2.0, 2.0, 2.0, 2.0]]

    Or first repeat the chord and then arpeggiate each repetition

    >>> c['G7!2@']
    P[4, 6, 8, 10, 4, 6, 8, 10]

    Repetition of a group can be done by multiplying it,
    either as a `string` or `list`:

    >>> c['Dm7/11!8 Bb7M!7 Bb7M/5- ' * 2 + 'Dm7M/9!4 Bb7M!2 G7/9!2 ' * 2].json_value()
    ['TimeVar', [Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9')], [8.0, 7.0, 1.0, 8.0, 7.0, 1.0, 4.0, 2.0, 2.0, 4.0, 2.0, 2.0]]

    >>> c[['Dm7/11!8 Bb7M!7 Bb7M/5-'] * 2 + ['Dm7M/9!4 Bb7M!2 G7/9!2'] * 2].json_value()
    ['TimeVar', [Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7/11'), Chord('Bb7M'), Chord('Bb7M/5-'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9'), Chord('Dm7M/9'), Chord('Bb7M'), Chord('G7/9')], [8.0, 7.0, 1.0, 8.0, 7.0, 1.0, 4.0, 2.0, 2.0, 4.0, 2.0, 2.0]]

    It must also accept repetition values that are not integers:

    >>> c['B7M D7 G7M Bb7!.75 Eb7M!2.75 Am7!.75 D7'].json_value()
    ['TimeVar', [Chord('B7M'), Chord('D7'), Chord('G7M'), Chord('Bb7'), Chord('Eb7M'), Chord('Am7'), Chord('D7')], [1.0, 1.0, 1.0, 0.75, 2.75, 0.75, 1.0]]

    **_`Mixing inputs:`_**

    >>> c['C  D ', [1, 4], 'Dm E#', (2, 3), 1]
    P[Chord('C'), Chord('D'), P[1, 4], Chord('Dm'), Chord('E#'), P(2, 3), 1]

    >>> c[1, 'C D', [1, 4], 'Dm E#@', (2, 3)]
    P[1, Chord('C'), Chord('D'), P[1, 4], Chord('Dm'), 3, 5, 7, P(2, 3)]

    >>> c[(2, 3), 'C!4 D', [1, 4], 'Dm@!3', 1].json_value()
    ['TimeVar', [P(2, 3), Chord('C'), Chord('D'), 1, 1, 3, 5, 1, P(2, 3), Chord('C'), Chord('D'), 4, 1, 3, 5, 1], [1.0, 4.0, 1.0, 1.0, 3.0, 3.0, 3.0, 1.0, 1.0, 4.0, 1.0, 1.0, 3.0, 3.0, 3.0, 1.0]]

    >>> c[1, c['C D'].arp(), [1, 4], c['Dm E#@'], (2, 3)]
    P[1, P[0, 2, 4, 1, 3.5, 5], P[1, 4], P[Chord('Dm'), 3, 5, 7], P(2, 3)]

    **_`Composition:`_**

    You can put chords in a list to alternate between them.
    In the example below, the first three chords (`#!python 'E7M G⁰ G#m7'`)
    will be played once in the sequence while the list
    (`#!python ['C#7/13 B7/13']` ) will alternatively be:

    - E7M G⁰ G#m7 `C#7/13`
    - E7M G⁰ G#m7 `B7/13`

    >>> c['E7M G⁰ G#m7', ['C#7/13 B7/13']]
    P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P[Chord('C#7/13'), Chord('B7/13')]]

    Or using `#!python '()'`, like:

    >>> c['E7M G⁰ G#m7 (C#7/13 B7/13)']
    P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P[Chord('C#7/13'), Chord('B7/13')]]

    >>> c['E7M!4 G⁰!4 G#m7!4', ['C#7/13!4 B7/13!4']].json_value()
    ['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('C#7/13'), Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('B7/13')], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

    With `#!python '()'`:

    >>> c['E7M!4 G⁰!4 G#m7!4 (C#7/13!4 B7/13!4)'].json_value()
    ['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('C#7/13'), Chord('E7M'), Chord('G⁰'), Chord('G#m7'), Chord('B7/13')], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

    To play a group together at the same time, use a `tuple` to form the
    chords:

    >>> c['E7M G⁰ G#m7', ('C#7/13', 'B7/13')]
    P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))]

    Or use `#!python '<><>'`

    >>> c['E7M G⁰ G#m7 < C#7/13 >< B7/13 >']
    P[Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))]

    >>> c['E7M!4 G⁰!4 G#m7!4', ('C#7/13!4', 'B7/13!4')].json_value()
    ['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

    Ot with `#!python <><>`

    >>> c['E7M!4 G⁰!4 G#m7!4 <C#7/13!4> <B7/13!4>'].json_value()
    ['TimeVar', [Chord('E7M'), Chord('G⁰'), Chord('G#m7'), P(Chord('C#7/13'), Chord('B7/13'))], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]]

    Returns
    -------
    Pattern
        Chord progression.
    TimeVar
        If any repetition is defined other than 1
    """  # noqa: E501
    if not isinstance(args, tuple):
        args = (args,)

    chords, durs = [], []

    for pattern in args:
        for chord, dur in zip(*parse_chords(pattern)):
            if not isinstance(chord, Extendable):
                chords.append(chord)
                durs.append(dur)
            else:
                chords.extend(chord)
                if isinstance(dur, Iterable):
                    durs.append(dur)
                else:
                    durs.extend([dur for _ in range(len(chord))])

    if any(filter(lambda r: r > 1, flat(durs))):
        return TimeVar(chords, durs)

    return ChordPattern(chords)

__call__(*args) 🔗

Creates a harmonic progression based on a list of chords. e.g. c(...)

Parameters:

Name Type Description Default
args Any

Many chords or others patterns.

()

Examples:

You can create a chord pattern in a few ways.

One of them is using [] or () with a list of strings or passing a string of chords separated by space:

>>> c('Am7', 'C7/9', 'F7Maj', 'G4/9/13')
P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]
>>> c('Am7 C7/9 F7Maj G4/9/13')
P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]

Returns:

Type Description
Pattern

Chord progression.

TimeVar

If any repetition is defined other than 1

Source code in FoxDotChord/_pattern.py
def __call__(self, *args):
    """
    Creates a harmonic progression based on a list of chords.
    e.g. `c(...)`

    Parameters
    ----------
    args : Any
        Many chords or others patterns.

    Examples
    --------
    You can create a chord pattern in a few ways.

    One of them is using `[]` or `()` with a list of strings
    or passing a string of chords separated by `space`:

    >>> c('Am7', 'C7/9', 'F7Maj', 'G4/9/13')
    P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]
    >>> c('Am7 C7/9 F7Maj G4/9/13')
    P[Chord('Am7'), Chord('C7/9'), Chord('F7Maj'), Chord('G4/9/13')]

    Returns
    -------
    Pattern
        Chord progression.
    TimeVar
        If any repetition is defined other than 1
    """
    return self.__getitem__(args)

__mul__(other) 🔗

Random [] or spreads (). e.g. c*[...] or c*(...)

Parameters:

Name Type Description Default
other Any

Another object.

required

Examples:

Random:

Use [] to set random values:

>>> c*['A C']
PRand(P[Chord('A'), Chord('C')])

Or using '{}'

>>> c['{A C}']
P[PRand(P[Chord('A'), Chord('C')])]

Stutters

You can spreads the values across the current “dur”.

If the dur is 4 beats then it will play each value 2/4 beats apart:

>>> c['Am7', c*('Bm7 E7')]
P[Chord('Am7'), P*(Chord('Bm7'), Chord('E7'))]

Or with '[]'

>>> c['Am7 [Bm7 E7]']
P[Chord('Am7'), P*(Chord('Bm7'), Chord('E7'))]

In the example above, Am7 will be played for a full beat while Bm7 and E7 will be played before the end of the beat.

This can be interesting in arpeggios.

>>> c[c*('Am7/2@'), c*(c*('Bm7@'), c*('E7@'))]
P[P*(5, 6, 7, 9, 11), P*(P*(6, 8, 10.5, 12), P*(2, 4.5, 6, 8))]
>>> c['[Am7/2@] [[Bm7@]  [E7@]]']
P[P*(5, 6, 7, 9, 11), P*(P*(6, 8, 10.5, 12), P*(2, 4.5, 6, 8))]

For example:

p1 >> keys(c['Am7 [Bm7 E7]'], dur=4)
b1 >> bassguitar(c['[Am7/2@] [[Bm7@] [E7@]]'], dur=4)

Returns:

Type Description
PRand

If a list or a Pattern is a step, the returned value will be PRand.

PGroupStar

Stutters the values over the length of and event's "dur".

Source code in FoxDotChord/_pattern.py
def __mul__(self, other):
    """
    Random  `[]` or spreads `()`.
    e.g. `c*[...]` or `c*(...)`

    Parameters
    ----------
    other : Any
        Another object.

    Examples
    --------
    **_`Random:`_**

    Use `[]` to set random values:

    >>> c*['A C']
    PRand(P[Chord('A'), Chord('C')])

    Or using `#!python '{}'`

    >>> c['{A C}']
    P[PRand(P[Chord('A'), Chord('C')])]

    **_`Stutters`_**

    You can spreads the values across the current “dur”.

    If the dur is 4 beats then it will play each value 2/4 beats apart:

    >>> c['Am7', c*('Bm7 E7')]
    P[Chord('Am7'), P*(Chord('Bm7'), Chord('E7'))]

    Or with `#!python '[]'`

    >>> c['Am7 [Bm7 E7]']
    P[Chord('Am7'), P*(Chord('Bm7'), Chord('E7'))]

    In the example above, `Am7` will be played for a full beat while `Bm7`
    and `E7` will be played before the end of the beat.

    This can be interesting in arpeggios.

    >>> c[c*('Am7/2@'), c*(c*('Bm7@'), c*('E7@'))]
    P[P*(5, 6, 7, 9, 11), P*(P*(6, 8, 10.5, 12), P*(2, 4.5, 6, 8))]

    >>> c['[Am7/2@] [[Bm7@]  [E7@]]']
    P[P*(5, 6, 7, 9, 11), P*(P*(6, 8, 10.5, 12), P*(2, 4.5, 6, 8))]

    For example:

    ```python
    p1 >> keys(c['Am7 [Bm7 E7]'], dur=4)
    b1 >> bassguitar(c['[Am7/2@] [[Bm7@] [E7@]]'], dur=4)
    ```

    Returns
    -------
    PRand
        If a list or a Pattern is a step, the returned value will be PRand.
    PGroupStar
        Stutters the values over the length of and event's "dur".
    """
    if isinstance(other, (list, Pattern)):
        return PRand(list(self(other)))
    if isinstance(other, (tuple)):
        return PGroupStar(self(*other))
    return PGroupStar(self(other))

__pow__(other) 🔗

Returns scrambled version. e.g. c**[...]

Parameters:

Name Type Description Default
other Any

Another object.

required

Examples:

>>> c**('A C')
P**(Chord('A'), Chord('C'))
>>> c**['A C']
P**(Chord('A'), Chord('C'))

Returns:

Type Description
PGroupPow

Shuffled values.

Source code in FoxDotChord/_pattern.py
def __pow__(self, other):
    """
    Returns scrambled version.
    e.g. `c**[...]`

    Parameters
    ----------
    other : Any
        Another object.

    Examples
    --------
    >>> c**('A C')
    P**(Chord('A'), Chord('C'))
    >>> c**['A C']
    P**(Chord('A'), Chord('C'))

    Returns
    -------
    PGroupPow
        Shuffled values.
    """
    return super().__pow__(self(other))

__xor__(other) 🔗

Returns a PGroup that delays each value by dur * n. e.g. c^[..., dur]

Parameters:

Name Type Description Default
other Any

Another object.

required

Examples:

>>> c^('A C', 4)
P^(Chord('A'), Chord('C'))

Returns:

Type Description
PGroupXor

Pattern with delay.

Source code in FoxDotChord/_pattern.py
def __xor__(self, other):
    """
    Returns a PGroup that delays each value by dur * n.
    e.g. `c^[..., dur]`

    Parameters
    ----------
    other : Any
        Another object.

    Examples
    --------
    >>> c^('A C', 4)
    P^(Chord('A'), Chord('C'))

    Returns
    -------
    PGroupXor
        Pattern with delay.
    """
    new = self(*other) if isinstance(other, tuple) else self(other)
    return super().__xor__(new)

__add__(other) 🔗

Stutters the values over the length of and event's 'sus'. e.g. c+[...]

Parameters:

Name Type Description Default
other Any

Another object.

required

Examples:

>>> c+('A C')
P+(Chord('A'), Chord('C'))
>>> ('A C')+c
P+(Chord('A'), Chord('C'))

Returns:

Type Description
PGroupPlus

Stuttered values.

Source code in FoxDotChord/_pattern.py
def __add__(self, other):
    """
    Stutters the values over the length of and event's 'sus'.
    e.g. `c+[...]`

    Parameters
    ----------
    other : Any
        Another object.

    Examples
    --------
    >>> c+('A C')
    P+(Chord('A'), Chord('C'))
    >>> ('A C')+c
    P+(Chord('A'), Chord('C'))

    Returns
    -------
    PGroupPlus
        Stuttered values.
    """
    return super().__add__(self(other))

__truediv__(other) 🔗

Stutter every other request. e.g. c/[...]

Parameters:

Name Type Description Default
other Any

Another object.

required

Examples:

>>> c/('A C')
P/(Chord('A'), Chord('C'))

Returns:

Type Description
PGroupDiv

Stuttered values.

Source code in FoxDotChord/_pattern.py
def __truediv__(self, other):
    """
    Stutter every other request.
    e.g. `c/[...]`

    Parameters
    ----------
    other : Any
        Another object.

    Examples
    --------
    >>> c/('A C')
    P/(Chord('A'), Chord('C'))

    Returns
    -------
    PGroupDiv
        Stuttered values.
    """
    return super().__truediv__(self(other))