Snap

Snap(input, choice, scale=0, mul=1, add=0)

Snap input values on a user's defined midi scale.

Snap takes an audio input of floating-point values from 0 to 127 and output the nearest value in the `choice` parameter. `choice` must only defined the first octave (0 <= x < 12) and the object will take care of the input octave range. According to `scale` parameter, output can be in midi notes, hertz or transposition factor (centralkey = 60).

Parent class : PyoObject

Parameters:

    input : PyoObject
        Incoming Midi notes as an audio stream.
    choice : list of floats
        Possible values, as midi notes, for output.
    scale : int {0, 1, 2}, optional
        Pitch output format. 0 = MIDI, 1 = Hertz, 2 = transpo. 
        In the transpo mode, the central key (the key where there 
        is no transposition) is 60. Defaults to 0.

Methods:

    setInput(x, fadetime) : Replace the `input` attribute.
    setChoice(x) : Replace the `choice` attribute.
    setScale(x) : Replace the `scale` attribute.

Attributes:

    input : PyoObject. Audio signal to transform.
    choice : list of floats. Possible values.
    scale : int. Output format.

Examples:

    >>> s = Server().boot()
    >>> s.start()
    >>> wav = SquareTable()
    >>> env = CosTable([(0,0), (100,1), (500,.3), (8191,0)])
    >>> met = Metro(.125, 8).play()
    >>> amp = TrigEnv(met, table=env, mul=.1)
    >>> pit = TrigXnoiseMidi(met, dist=4, x1=20, mrange=(48,84))
    >>> hertz = Snap(pit, choice=[0,2,3,5,7,8,10], scale=1)
    >>> a = Osc(table=wav, freq=hertz, phase=0, mul=amp).out()

Methods details:

    Snap.setInput(x, fadetime=0.05):

        Replace the `input` attribute.
        
        Parameters:

        x : PyoObject
            New signal to process.
        fadetime : float, optional
            Crossfade time between old and new input. Defaults to 0.05.

    Snap.setChoice(x):

        Replace the `choice` attribute.
        
        Parameters:

        x : list of floats
            new `choice` attribute.

    Snap.setScale(x):

        Replace the `scale` attribute.
        
        Possible values are: 
            0 -> Midi notes
            1 -> Hertz
            2 -> transposition factor 
                 (centralkey is (`minrange` + `maxrange`) / 2

        Parameters:

        x : int {0, 1, 2}
            new `scale` attribute.