Beat

Beat(time=0.12, taps=16, w1=80, w2=50, w3=30, poly=1)

Generates algorithmic trigger patterns.

A trigger is an audio signal with a value of 1 surrounded by 0s.

Beat generates measures of length `taps` and uses weight parameters (`w1`, `w2` and `w3`) to compute the chances of a beat to be present in the generated measure.

User can store the current pattern in one of the 32 preset slots with the store() method and recall it later with recall(x).

A preset is a list where the first value is the number of beats in the measure, followed by 1s and 0s. For a 4/4 measure with only down beats:

[16, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]

The play() method starts the Beat and is not called at the object creation time.

Parent class : PyoObject

Parameters:

    time : float or PyoObject, optional
        Time, in seconds, between each beat of the pattern. Defaults to 0.125.
    taps : int, optional
        Number of beats in the generated pattern, max = 64. Defaults to 16.
    w1 : int {0 -> 100}, optional
        Probability for down beats. Defaults to 80.
    w2 : int {0 -> 100}, optional
        Probability for up beats. Defaults to 50.
    w3 : int {0 -> 100}, optional
        Probability for the weakest beats. Defaults to 30.
    poly : int, optional
        Beat polyphony. Denotes how many independent streams are 
        generated by the object, allowing overlapping processes.
        Available only at initialization. Defaults to 1.

Methods:

    setTime(x) : Replace the `time` attribute.
    setTaps(x) : Replace the `taps` attribute.
    setW1(x) : Replace the `w1` attribute.
    setW2(x) : Replace the `w2` attribute.
    setW3(x) : Replace the `w3` attribute.
    setWeights(w1, w2, w3) : Replace the weight attributes.
    new() : Generates a new pattern with the current parameters.
    fill() : Generates a fill-in pattern and then restore the current one.
    store(x) : Store the current pattern in memory `x`.
    recall(x) : Recall the pattern previously stored in memory `x`.
    getPresets() : Returns the list of stored presets.
    setPresets(list) : Store a list of presets.
    get(identifier, all) : Return the first sample of the current 
        buffer as a float.

Attributes:

    time : float or PyoObject. Time, in seconds, between each tap of the pattern.
    taps : int. Number of taps in the generated pattern.
    w1 : Probability for down beats.
    w2 : Probability for up beats.
    w3 : Probability for other beats.

Notes:

    Beat outputs many signals identified with a string between brackets:
    
    obj['amp'] returns audio stream of the current beat amplitude.
    obj['dur'] returns audio stream of the current beat duration in seconds.
    obj['end'] returns audio stream with a trigger just before the end of the measure.
    
    obj without brackets returns the generated trigger stream of the measure.
     
    The out() method is bypassed. Beat's signal can not be sent to audio outs.

    Beat has no `mul` and `add` attributes.

Examples:

    >>> s = Server().boot()
    >>> s.start()
    >>> t = CosTable([(0,0), (100,1), (500,.3), (8191,0)])
    >>> beat = Beat(time=.125, taps=16, w1=90, w2=50, w3=35, poly=1).play()
    >>> trmid = TrigXnoiseMidi(beat, dist=12, mrange=(60, 96))
    >>> trhz = Snap(trmid, choice=[0,2,3,5,7,8,10], scale=1)
    >>> tr2 = TrigEnv(beat, table=t, dur=beat['dur'], mul=beat['amp'])
    >>> a = Sine(freq=trhz, mul=tr2).out()

Methods details:

    Beat.setTime(x):

        Replace the `time` attribute.

        Parameters:

        x : float or PyoObject
            New `time` attribute.

    Beat.setTaps(x):

        Replace the `taps` attribute.

        Parameters:

        x : int
            New `taps` attribute.

    Beat.setW1(x):

        Replace the `w1` attribute.

        Parameters:

        x : int
            New `w1` attribute.

    Beat.setW2(x):

        Replace the `w2` attribute.

        Parameters:

        x : int
            New `w2` attribute.

    Beat.setW3(x):

        Replace the `w3` attribute.

        Parameters:

        x : int
            New `w3` attribute.

    Beat.setWeights(w1=None, w2=None, w3=None):

        Replace the weight attributes.
        
        Arguments set to `None` remain unchanged.

        Parameters:

        w1 : int, optional
            New `w1` attribute. Defaults to None.
        w2 : int, optional
            New `w2` attribute. Defaults to None.
        w3 : int, optional
            New `w3` attribute. Defaults to None.

    Beat.new(self):

        Generates a new pattern with the current parameters.

    Beat.fill(self):

        Generates a fill-in pattern and then restore the current one.

    Beat.store(x):

        Store the current pattern in memory `x`.
        
        Parameters:
        
        x : int
            Memory number. 0 <= x < 32.

    Beat.recall(x):

        Recall the pattern previously stored in memory `x`.

        Parameters:

        x : int
            Memory number. 0 <= x < 32.

    Beat.getPresets(self):

        Returns the list of stored presets.

    Beat.setPresets(x):

        Store a list presets.
        
        Parameters:
        
        x : list
            List of presets.

    Beat.get(identifier="amp", all=False):

        Return the first sample of the current buffer as a float.

        Can be used to convert audio stream to usable Python data.

        "amp" or "dur" must be given to `identifier` to specify
        which stream to get value from.

        Parameters:

            identifier : string {"amp", "dur"}
                Address string parameter identifying audio stream.
                Defaults to "amp".
            all : boolean, optional
                If True, the first value of each object's stream
                will be returned as a list. Otherwise, only the value
                of the first object's stream will be returned as a float.
                Defaults to False.