Value Converters (SLMap)

These objects are used to convert values between different ranges.

Map

class Map(min, max, scale)[source]

Converts value between 0 and 1 on various scales.

Base class for Map objects.

Args
min: int or float

Lowest value of the range.

max: int or float

Highest value of the range.

scale: string {‘lin’, ‘log’}

Method used to scale the input value on the specified range.

>>> m = Map(20., 20000., 'log')
>>> print(m.get(.5))
632.455532034
>>> print(m.set(12000))
0.926050416795

Public Data Attributes:

min

int or float.

max

int or float.

scale

string.

Public Methods:

__init__(min, max, scale)

get(x)

Takes x between 0 and 1 and returns scaled value.

set(x)

Takes x in the real range and returns value unscaled (between 0 and 1).

setMin(x)

Replace the min attribute.

setMax(x)

Replace the max attribute.

setScale(x)

Replace the scale attribute.


get(x)[source]

Takes x between 0 and 1 and returns scaled value.

set(x)[source]

Takes x in the real range and returns value unscaled (between 0 and 1).

setMin(x)[source]

Replace the min attribute.

Args
x: float

New min attribute.

setMax(x)[source]

Replace the max attribute.

Args
x: float

New max attribute.

setScale(x)[source]

Replace the scale attribute.

Args
x: string

New scale attribute.

property min

int or float. Lowest value of the range.

property max

int or float. Highest value of the range.

property scale

string. Method used to scale the input value.

SLMap

class SLMap(min, max, scale, name, init, res='float', ramp=0.025, dataOnly=False)[source]

Base Map class used to manage control sliders.

Derived from Map class, a few parameters are added for sliders initialization.

Parent

Map

Args
min: int or float

Smallest value of the range.

max: int or float

Highest value of the range.

scale: string {‘lin’, ‘log’}

Method used to scale the input value on the specified range.

name: string

Name of the attributes the slider is affected to.

init: int or float

Initial value. Specified in the real range, not between 0 and 1. Use set method to retreive the normalized corresponding value.

res: string {‘int’, ‘float’}, optional

Sets the resolution of the slider. Defaults to ‘float’.

ramp: float, optional

Ramp time, in seconds, used to smooth the signal sent from slider to object’s attribute. Defaults to 0.025.

dataOnly: boolean, optional

Set this argument to True if the parameter does not accept audio signal as control but discrete values. If True, label will be marked with a star symbol (*). Defaults to False.

>>> s = Server().boot()
>>> s.start()
>>> ifs = [350,360,375,388]
>>> slmapfreq = SLMap(20., 2000., 'log', 'freq', ifs)
>>> slmapfeed = SLMap(0, 0.25, 'lin', 'feedback', 0)
>>> maps = [slmapfreq, slmapfeed, SLMapMul(.1)]
>>> a = SineLoop(freq=ifs, mul=.1).out()
>>> a.ctrl(maps)

Public Data Attributes:

name

string.

init

float.

res

string.

ramp

float.

dataOnly

boolean.

Inherited from Map

min

int or float.

max

int or float.

scale

string.

Public Methods:

__init__(min, max, scale, name, init[, res, ...])

Inherited from Map

__init__(min, max, scale, name, init[, res, ...])

get(x)

Takes x between 0 and 1 and returns scaled value.

set(x)

Takes x in the real range and returns value unscaled (between 0 and 1).

setMin(x)

Replace the min attribute.

setMax(x)

Replace the max attribute.

setScale(x)

Replace the scale attribute.


property name

string. Name of the parameter to control.

property init

float. Initial value of the slider.

property res

string. Slider resolution {int or float}.

property ramp

float. Ramp time in seconds.

property dataOnly

boolean. True if argument does not accept audio stream.

SLMapFreq

class SLMapFreq(init=1000)[source]

SLMap with normalized values for a ‘freq’ slider.

Parent

SLMap

Args
init: int or float, optional

Initial value. Specified in the real range, not between 0 and 1. Defaults to 1000.

Note

SLMapFreq values are:

  • min = 20.0

  • max = 20000.0

  • scale = ‘log’

  • name = ‘freq’

  • res = ‘float’

  • ramp = 0.025

Public Data Attributes:

Inherited from SLMap

name

string.

init

float.

res

string.

ramp

float.

dataOnly

boolean.

Inherited from Map

min

int or float.

max

int or float.

scale

string.

Public Methods:

__init__([init])

Inherited from SLMap

__init__([init])

Inherited from Map

__init__([init])

get(x)

Takes x between 0 and 1 and returns scaled value.

set(x)

Takes x in the real range and returns value unscaled (between 0 and 1).

setMin(x)

Replace the min attribute.

setMax(x)

Replace the max attribute.

setScale(x)

Replace the scale attribute.


SLMapMul

class SLMapMul(init=1.0)[source]

SLMap with normalized values for a ‘mul’ slider.

Parent

SLMap

Args
init: int or float, optional

Initial value. Specified in the real range, not between 0 and 1. Defaults to 1.

Note

SLMapMul values are:

  • min = 0.0

  • max = 2.0

  • scale = ‘lin’

  • name = ‘mul’

  • res = ‘float’

  • ramp = 0.025

Public Data Attributes:

Inherited from SLMap

name

string.

init

float.

res

string.

ramp

float.

dataOnly

boolean.

Inherited from Map

min

int or float.

max

int or float.

scale

string.

Public Methods:

__init__([init])

Inherited from SLMap

__init__([init])

Inherited from Map

__init__([init])

get(x)

Takes x between 0 and 1 and returns scaled value.

set(x)

Takes x in the real range and returns value unscaled (between 0 and 1).

setMin(x)

Replace the min attribute.

setMax(x)

Replace the max attribute.

setScale(x)

Replace the scale attribute.


SLMapPhase

class SLMapPhase(init=0.0)[source]

SLMap with normalized values for a ‘phase’ slider.

Parent

SLMap

Args
init: int or float, optional

Initial value. Specified in the real range, not between 0 and 1. Defaults to 0.

Note

SLMapPhase values are:

  • min = 0.0

  • max = 1.0

  • scale = ‘lin’

  • name = ‘phase’

  • res = ‘float’

  • ramp = 0.025

Public Data Attributes:

Inherited from SLMap

name

string.

init

float.

res

string.

ramp

float.

dataOnly

boolean.

Inherited from Map

min

int or float.

max

int or float.

scale

string.

Public Methods:

__init__([init])

Inherited from SLMap

__init__([init])

Inherited from Map

__init__([init])

get(x)

Takes x between 0 and 1 and returns scaled value.

set(x)

Takes x in the real range and returns value unscaled (between 0 and 1).

setMin(x)

Replace the min attribute.

setMax(x)

Replace the max attribute.

setScale(x)

Replace the scale attribute.


SLMapQ

class SLMapQ(init=1.0)[source]

SLMap with normalized values for a ‘q’ slider.

Parent

SLMap

Args
init: int or float, optional

Initial value. Specified in the real range, not between 0 and 1. Defaults to 1.

Note

SLMapQ values are:

  • min = 0.1

  • max = 100.0

  • scale = ‘log’

  • name = ‘q’

  • res = ‘float’

  • ramp = 0.025

Public Data Attributes:

Inherited from SLMap

name

string.

init

float.

res

string.

ramp

float.

dataOnly

boolean.

Inherited from Map

min

int or float.

max

int or float.

scale

string.

Public Methods:

__init__([init])

Inherited from SLMap

__init__([init])

Inherited from Map

__init__([init])

get(x)

Takes x between 0 and 1 and returns scaled value.

set(x)

Takes x in the real range and returns value unscaled (between 0 and 1).

setMin(x)

Replace the min attribute.

setMax(x)

Replace the max attribute.

setScale(x)

Replace the scale attribute.


SLMapDur

class SLMapDur(init=1.0)[source]

SLMap with normalized values for a ‘dur’ slider.

Parent

SLMap

Args
init: int or float, optional

Initial value. Specified in the real range, not between 0 and 1. Defaults to 1.

Note

SLMapDur values are:

  • min = 0.

  • max = 60.0

  • scale = ‘lin’

  • name = ‘dur’

  • res = ‘float’

  • ramp = 0.025

Public Data Attributes:

Inherited from SLMap

name

string.

init

float.

res

string.

ramp

float.

dataOnly

boolean.

Inherited from Map

min

int or float.

max

int or float.

scale

string.

Public Methods:

__init__([init])

Inherited from SLMap

__init__([init])

Inherited from Map

__init__([init])

get(x)

Takes x between 0 and 1 and returns scaled value.

set(x)

Takes x in the real range and returns value unscaled (between 0 and 1).

setMin(x)

Replace the min attribute.

setMax(x)

Replace the max attribute.

setScale(x)

Replace the scale attribute.


SLMapPan

class SLMapPan(init=0.0)[source]

SLMap with normalized values for a ‘pan’ slider.

Parent

SLMap

Args
init: int or float, optional

Initial value. Specified in the real range, not between 0 and 1. Defaults to 0.

Note

SLMapPhase values are:

  • min = 0.0

  • max = 1.0

  • scale = ‘lin’

  • name = ‘pan’

  • res = ‘float’

  • ramp = 0.025

Public Data Attributes:

Inherited from SLMap

name

string.

init

float.

res

string.

ramp

float.

dataOnly

boolean.

Inherited from Map

min

int or float.

max

int or float.

scale

string.

Public Methods:

__init__([init])

Inherited from SLMap

__init__([init])

Inherited from Map

__init__([init])

get(x)

Takes x between 0 and 1 and returns scaled value.

set(x)

Takes x in the real range and returns value unscaled (between 0 and 1).

setMin(x)

Replace the min attribute.

setMax(x)

Replace the max attribute.

setScale(x)

Replace the scale attribute.