Soundfile Players

Play soundfiles from the disk.

SfMarkerXXX objects use markers features (store in the header) from an AIFF file to create more specific reading patterns.

Objects in this category

SfPlayer

class SfPlayer(path, speed=1, loop=False, offset=0, interp=2, mul=1, add=0)[source]

Soundfile player.

Reads audio data from a file using one of several available interpolation types. User can alter its pitch with the speed attribute. The object takes care of sampling rate conversion to match the Server sampling rate setting.

Parent

PyoObject

Args
path: string

Full path name of the sound to read.

speed: float or PyoObject, optional

Transpose the pitch of input sound by this factor. Defaults to 1.

1 is the original pitch, lower values play sound slower, and higher values play sound faster.

Negative values results in playing sound backward.

Although the speed attribute accepts audio rate signal, its value is updated only once per buffer size.

loop: bool, optional

If set to True, sound will play in loop. Defaults to False.

offset: float, optional

Time in seconds of input sound to be skipped, assuming speed = 1. If the object is already playing (and play() is implicitly called at the object creation), this value will be effective only on the next loop point. Defaults to 0.

interp: int, optional
Interpolation type. Defaults to 2.
  1. no interpolation

  2. linear

  3. cosinus

  4. cubic

Note

SfPlayer will send a trigger signal at the end of the playback if loop is off or any time it wraps around if loop is on. User can retrieve the trigger streams by calling obj[‘trig’]:

>>> sf = SfPlayer(SNDS_PATH + "/transparent.aif").out()
>>> trig = TrigRand(sf['trig'])

Note that the object will send as many trigs as there is channels in the sound file. If you want to retrieve only one trig, only give the first stream to the next object:

>>> def printing():
...     print("one trig!")
>>> sf = SfPlayer("/stereo/sound/file.aif").out()
>>> trig = TrigFunc(sf['trig'][0], printing)
>>> s = Server().boot()
>>> s.start()
>>> snd = SNDS_PATH + "/transparent.aif"
>>> sf = SfPlayer(snd, speed=[.75,.8], loop=True, mul=.3).out()

Public Data Attributes:

path

string.

sound

string.

speed

float or PyoObject.

loop

bool.

offset

float.

interp

int {1, 2, 3, 4}.

Inherited from PyoObject

mul

float or PyoObject.

add

float or PyoObject.

Public Methods:

__init__(path[, speed, loop, offset, ...])

setPath(path)

Sets a new sound to read.

setSound(path)

Sets a new sound to read.

setSpeed(x)

Replace the speed attribute.

setLoop(x)

Replace the loop attribute.

setOffset(x)

Replace the offset attribute.

setInterp(x)

Replace the interp attribute.

ctrl([map_list, title, wxnoserver])

Opens a sliders window to control the parameters of the object.

Inherited from PyoObject

__init__([mul, add])

__add__(x)

__radd__(x)

__iadd__(x)

__sub__(x)

__rsub__(x)

__isub__(x)

__mul__(x)

__rmul__(x)

__imul__(x)

__truediv__(x)

__rtruediv__(x)

__itruediv__(x)

__div__(x)

__rdiv__(x)

__idiv__(x)

__pow__(x)

__rpow__(x)

__mod__(x)

__neg__()

__lt__(x)

Return self<value.

__le__(x)

Return self<=value.

__eq__(x)

Return self==value.

__ne__(x)

Return self!=value.

__gt__(x)

Return self>value.

__ge__(x)

Return self>=value.

__do_comp__(comp, mode[, default])

isPlaying([all])

Returns True if the object is currently playing, otherwise, returns False.

isOutputting([all])

Returns True if the object is outputting.

get([all])

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

play([dur, delay])

Start processing without sending samples to output.

out([chnl, inc, dur, delay])

Start processing and send samples to audio output beginning at chnl.

stop([wait])

Stop processing.

mix([voices])

Mix the object's audio streams into voices streams and return a Mix object.

range(min, max)

Adjust mul and add attributes according to a given range.

setMul(x)

Replace the mul attribute.

setAdd(x)

Replace the add attribute.

setSub(x)

Replace and inverse the add attribute.

setDiv(x)

Replace and inverse the mul attribute.

set(attr, value[, port, callback])

Replace any attribute with portamento.

ctrl([map_list, title, wxnoserver])

Opens a sliders window to control the parameters of the object.

Inherited from PyoObjectBase

__init__()

dump()

Print infos about the current state of the object.

getBaseObjects()

Return a list of Stream objects managed by the instance.

getServer()

Return a reference to the current Server object.

getSamplingRate()

Return the current sampling rate (samples per second), as a float.

getBufferSize()

Return the current buffer size (samples per buffer), as an integer.

allowAutoStart([switch])

When autoStartChildren is activated in the Server, call this method with False as argument to stop the propagation of play/out/stop methods to and from this object.

useWaitTimeOnStop()

When autoStartChildren is activated in the Server, call this method to force an object given to the mul attribute of another object to use the wait time from the stop method instead of being stopped immediately.

addLinkedObject(x)

When autoStartChildren is activated in the Server, use this method to explicitly add an object in a dsp chain, which is generally controlled by the last object of the chain.

setStopDelay(x)

Set a specific waiting time when calling the stop method on this object.

getStopDelay()

Return the waiting time applied when calling the stop method on this object.

__iter__()

__next__()

next()

Alias for __next__ method.

__getitem__(i)

__setitem__(i, x)

__len__()

__repr__()

Return repr(self).

__dir__()

Default dir() implementation.

Private Data Attributes:

Inherited from PyoObject

_STREAM_TYPE

Inherited from PyoObjectBase

_STREAM_TYPE

Private Methods:

Inherited from PyoObject

_init_play()

_reset_from_set([attr])

Inherited from PyoObjectBase

_autoplay([dur, delay])

_autostop([wait])


setPath(path)[source]

Sets a new sound to read.

The number of channels of the new sound must match those of the sound loaded at initialization time.

Args
path: string

Full path of the new sound.

setSound(path)[source]

Sets a new sound to read.

The number of channels of the new sound must match those of the sound loaded at initialization time.

Args
path: string

Full path of the new sound.

setSpeed(x)[source]

Replace the speed attribute.

Args
x: float or PyoObject

new speed attribute.

setLoop(x)[source]

Replace the loop attribute.

Args
x: bool {True, False}

new loop attribute.

setOffset(x)[source]

Replace the offset attribute.

Args
x: float

new offset attribute.

setInterp(x)[source]

Replace the interp attribute.

Args
x: int {1, 2, 3, 4}

new interp attribute.

ctrl(map_list=None, title=None, wxnoserver=False)[source]

Opens a sliders window to control the parameters of the object. SLMap has a dataOnly attribute to identify parameters that don’t audio signal as control but only discrete values.

If a list of values are given to a parameter, a multisliders will be used to control each stream independently.

Args
map_list: list of SLMap objects, optional

Users defined set of parameters scaling. There is default scaling for each object that accept ctrl method.

title: string, optional

Title of the window. If none is provided, the name of the class is used.

wxnoserver: boolean, optional

With wxPython graphical toolkit, if True, tells the interpreter that there will be no server window.

If wxnoserver is set to True, the interpreter will not wait for the server GUI before showing the controller window.

property path

string. Full path of the sound.

property sound

string. Alias to the path attribute.

property speed

float or PyoObject. Transposition factor.

property loop

bool. Looping mode.

property offset

float. Time, in seconds, of the first sample to read.

property interp

int {1, 2, 3, 4}. Interpolation method.

SfMarkerLooper

class SfMarkerLooper(path, speed=1, mark=0, interp=2, mul=1, add=0)[source]

AIFF with markers soundfile looper.

Reads audio data from a AIFF file using one of several available interpolation types. User can alter its pitch with the speed attribute. The object takes care of sampling rate conversion to match the Server sampling rate setting.

The reading pointer loops a specific marker (from the MARK chunk in the header of the AIFF file) until it received a new integer in the mark attribute.

Parent

PyoObject

Args
path: string

Full path name of the sound to read.

speed: float or PyoObject, optional

Transpose the pitch of input sound by this factor. Defaults to 1.

1 is the original pitch, lower values play sound slower, and higher values play sound faster.

Negative values results in playing sound backward.

Although the speed attribute accepts audio rate signal, its value is updated only once per buffer size.

mark: float or PyoObject, optional

Integer denoting the marker to loop, in the range 0 -> len(getMarkers()). Defaults to 0.

interp: int, optional
Choice of the interpolation method. Defaults to 2.
  1. no interpolation

  2. linear

  3. cosinus

  4. cubic

>>> s = Server().boot()
>>> s.start()
>>> a = SfMarkerLooper(SNDS_PATH + '/transparent.aif', speed=[.999,1], mul=.3).out()
>>> rnd = RandInt(len(a.getMarkers()), 2)
>>> a.mark = rnd

Public Data Attributes:

speed

float or PyoObject.

mark

float or PyoObject.

interp

int {1, 2, 3, 4}.

Inherited from PyoObject

mul

float or PyoObject.

add

float or PyoObject.

Public Methods:

__init__(path[, speed, mark, interp, mul, add])

setSpeed(x)

Replace the speed attribute.

setMark(x)

Replace the mark attribute.

setInterp(x)

Replace the interp attribute.

getMarkers()

Returns a list of marker time values in samples.

ctrl([map_list, title, wxnoserver])

Opens a sliders window to control the parameters of the object.

Inherited from PyoObject

__init__([mul, add])

__add__(x)

__radd__(x)

__iadd__(x)

__sub__(x)

__rsub__(x)

__isub__(x)

__mul__(x)

__rmul__(x)

__imul__(x)

__truediv__(x)

__rtruediv__(x)

__itruediv__(x)

__div__(x)

__rdiv__(x)

__idiv__(x)

__pow__(x)

__rpow__(x)

__mod__(x)

__neg__()

__lt__(x)

Return self<value.

__le__(x)

Return self<=value.

__eq__(x)

Return self==value.

__ne__(x)

Return self!=value.

__gt__(x)

Return self>value.

__ge__(x)

Return self>=value.

__do_comp__(comp, mode[, default])

isPlaying([all])

Returns True if the object is currently playing, otherwise, returns False.

isOutputting([all])

Returns True if the object is outputting.

get([all])

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

play([dur, delay])

Start processing without sending samples to output.

out([chnl, inc, dur, delay])

Start processing and send samples to audio output beginning at chnl.

stop([wait])

Stop processing.

mix([voices])

Mix the object's audio streams into voices streams and return a Mix object.

range(min, max)

Adjust mul and add attributes according to a given range.

setMul(x)

Replace the mul attribute.

setAdd(x)

Replace the add attribute.

setSub(x)

Replace and inverse the add attribute.

setDiv(x)

Replace and inverse the mul attribute.

set(attr, value[, port, callback])

Replace any attribute with portamento.

ctrl([map_list, title, wxnoserver])

Opens a sliders window to control the parameters of the object.

Inherited from PyoObjectBase

__init__()

dump()

Print infos about the current state of the object.

getBaseObjects()

Return a list of Stream objects managed by the instance.

getServer()

Return a reference to the current Server object.

getSamplingRate()

Return the current sampling rate (samples per second), as a float.

getBufferSize()

Return the current buffer size (samples per buffer), as an integer.

allowAutoStart([switch])

When autoStartChildren is activated in the Server, call this method with False as argument to stop the propagation of play/out/stop methods to and from this object.

useWaitTimeOnStop()

When autoStartChildren is activated in the Server, call this method to force an object given to the mul attribute of another object to use the wait time from the stop method instead of being stopped immediately.

addLinkedObject(x)

When autoStartChildren is activated in the Server, use this method to explicitly add an object in a dsp chain, which is generally controlled by the last object of the chain.

setStopDelay(x)

Set a specific waiting time when calling the stop method on this object.

getStopDelay()

Return the waiting time applied when calling the stop method on this object.

__iter__()

__next__()

next()

Alias for __next__ method.

__getitem__(i)

__setitem__(i, x)

__len__()

__repr__()

Return repr(self).

__dir__()

Default dir() implementation.

Private Data Attributes:

Inherited from PyoObject

_STREAM_TYPE

Inherited from PyoObjectBase

_STREAM_TYPE

Private Methods:

Inherited from PyoObject

_init_play()

_reset_from_set([attr])

Inherited from PyoObjectBase

_autoplay([dur, delay])

_autostop([wait])


setSpeed(x)[source]

Replace the speed attribute.

Args
x: float or PyoObject

new speed attribute.

setMark(x)[source]

Replace the mark attribute.

Args
x: float or PyoObject

new mark attribute.

setInterp(x)[source]

Replace the interp attribute.

Args
x: int {1, 2, 3, 4}

new interp attribute.

getMarkers()[source]

Returns a list of marker time values in samples.

ctrl(map_list=None, title=None, wxnoserver=False)[source]

Opens a sliders window to control the parameters of the object. SLMap has a dataOnly attribute to identify parameters that don’t audio signal as control but only discrete values.

If a list of values are given to a parameter, a multisliders will be used to control each stream independently.

Args
map_list: list of SLMap objects, optional

Users defined set of parameters scaling. There is default scaling for each object that accept ctrl method.

title: string, optional

Title of the window. If none is provided, the name of the class is used.

wxnoserver: boolean, optional

With wxPython graphical toolkit, if True, tells the interpreter that there will be no server window.

If wxnoserver is set to True, the interpreter will not wait for the server GUI before showing the controller window.

property speed

float or PyoObject. Transposition factor.

property mark

float or PyoObject. Marker to loop.

property interp

int {1, 2, 3, 4}. Interpolation method.

SfMarkerShuffler

class SfMarkerShuffler(path, speed=1, interp=2, mul=1, add=0)[source]

AIFF with markers soundfile shuffler.

Reads audio data from a AIFF file using one of several available interpolation types. User can alter its pitch with the speed attribute. The object takes care of sampling rate conversion to match the Server sampling rate setting.

The reading pointer randomly choose a marker (from the MARK chunk in the header of the AIFF file) as its starting point and reads the samples until it reaches the following marker. Then, it choose another marker and reads from the new position and so on…

Parent

PyoObject

Args
path: string

Full path name of the sound to read. Can’t e changed after initialization.

speed: float or PyoObject, optional

Transpose the pitch of input sound by this factor. Defaults to 1.

1 is the original pitch, lower values play sound slower, and higher values play sound faster.

Negative values results in playing sound backward.

Although the speed attribute accepts audio rate signal, its value is updated only once per buffer size.

interp: int, optional
Choice of the interpolation method. Defaults to 2.
  1. no interpolation

  2. linear

  3. cosinus

  4. cubic

>>> s = Server().boot()
>>> s.start()
>>> sound = SNDS_PATH + "/transparent.aif"
>>> sf = SfMarkerShuffler(sound, speed=[1,1], mul=.3).out()
>>> sf.setRandomType("expon_min", 0.6)

Public Data Attributes:

speed

float or PyoObject.

interp

int {1, 2, 3, 4}.

Inherited from PyoObject

mul

float or PyoObject.

add

float or PyoObject.

Public Methods:

__init__(path[, speed, interp, mul, add])

setSpeed(x)

Replace the speed attribute.

setInterp(x)

Replace the interp attribute.

setRandomType([dist, x])

Set the random distribution type used to choose the markers.

getMarkers()

Returns a list of marker time values in samples.

ctrl([map_list, title, wxnoserver])

Opens a sliders window to control the parameters of the object.

Inherited from PyoObject

__init__([mul, add])

__add__(x)

__radd__(x)

__iadd__(x)

__sub__(x)

__rsub__(x)

__isub__(x)

__mul__(x)

__rmul__(x)

__imul__(x)

__truediv__(x)

__rtruediv__(x)

__itruediv__(x)

__div__(x)

__rdiv__(x)

__idiv__(x)

__pow__(x)

__rpow__(x)

__mod__(x)

__neg__()

__lt__(x)

Return self<value.

__le__(x)

Return self<=value.

__eq__(x)

Return self==value.

__ne__(x)

Return self!=value.

__gt__(x)

Return self>value.

__ge__(x)

Return self>=value.

__do_comp__(comp, mode[, default])

isPlaying([all])

Returns True if the object is currently playing, otherwise, returns False.

isOutputting([all])

Returns True if the object is outputting.

get([all])

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

play([dur, delay])

Start processing without sending samples to output.

out([chnl, inc, dur, delay])

Start processing and send samples to audio output beginning at chnl.

stop([wait])

Stop processing.

mix([voices])

Mix the object's audio streams into voices streams and return a Mix object.

range(min, max)

Adjust mul and add attributes according to a given range.

setMul(x)

Replace the mul attribute.

setAdd(x)

Replace the add attribute.

setSub(x)

Replace and inverse the add attribute.

setDiv(x)

Replace and inverse the mul attribute.

set(attr, value[, port, callback])

Replace any attribute with portamento.

ctrl([map_list, title, wxnoserver])

Opens a sliders window to control the parameters of the object.

Inherited from PyoObjectBase

__init__()

dump()

Print infos about the current state of the object.

getBaseObjects()

Return a list of Stream objects managed by the instance.

getServer()

Return a reference to the current Server object.

getSamplingRate()

Return the current sampling rate (samples per second), as a float.

getBufferSize()

Return the current buffer size (samples per buffer), as an integer.

allowAutoStart([switch])

When autoStartChildren is activated in the Server, call this method with False as argument to stop the propagation of play/out/stop methods to and from this object.

useWaitTimeOnStop()

When autoStartChildren is activated in the Server, call this method to force an object given to the mul attribute of another object to use the wait time from the stop method instead of being stopped immediately.

addLinkedObject(x)

When autoStartChildren is activated in the Server, use this method to explicitly add an object in a dsp chain, which is generally controlled by the last object of the chain.

setStopDelay(x)

Set a specific waiting time when calling the stop method on this object.

getStopDelay()

Return the waiting time applied when calling the stop method on this object.

__iter__()

__next__()

next()

Alias for __next__ method.

__getitem__(i)

__setitem__(i, x)

__len__()

__repr__()

Return repr(self).

__dir__()

Default dir() implementation.

Private Data Attributes:

Inherited from PyoObject

_STREAM_TYPE

Inherited from PyoObjectBase

_STREAM_TYPE

Private Methods:

Inherited from PyoObject

_init_play()

_reset_from_set([attr])

Inherited from PyoObjectBase

_autoplay([dur, delay])

_autostop([wait])


setSpeed(x)[source]

Replace the speed attribute.

Args
x: float or PyoObject

new speed attribute.

setInterp(x)[source]

Replace the interp attribute.

Args
x: int {1, 2, 3, 4}

new interp attribute.

setRandomType(dist=0, x=0.5)[source]

Set the random distribution type used to choose the markers.

Args
dist: int or string
The distribution type. Available distributions are:
  1. uniform (default)

  2. linear minimum

  3. linear maximum

  4. triangular

  5. exponential minimum

  6. exponential maximum

  7. double (bi)exponential

  8. cauchy

  9. weibull

  10. gaussian

x: float

Distribution specific parameter, if applicable, as a float between 0 and 1. Defaults to 0.5.

Note

Depending on the distribution type, x parameter is applied as follow (names as string, or associated number can be used as dist parameter):

  1. uniform
    • x: not used

  2. linear_min
    • x: not used

  3. linear_max
    • x: not used

  4. triangle
    • x: not used

  5. expon_min
    • x: slope {0 = no slope -> 1 = sharp slope}

  6. expon_max
    • x: slope {0 = no slope -> 1 = sharp slope}

  7. biexpon
    • x: bandwidth {0 = huge bandwidth -> 1 = narrow bandwidth}

  8. cauchy
    • x: bandwidth {0 = huge bandwidth -> 1 = narroe bandwidth}

  9. weibull
    • x: shape {0 = expon min => linear min => 1 = gaussian}

  10. gaussian
    • x: bandwidth {0 = huge bandwidth -> 1 = narrow bandwidth}

getMarkers()[source]

Returns a list of marker time values in samples.

ctrl(map_list=None, title=None, wxnoserver=False)[source]

Opens a sliders window to control the parameters of the object. SLMap has a dataOnly attribute to identify parameters that don’t audio signal as control but only discrete values.

If a list of values are given to a parameter, a multisliders will be used to control each stream independently.

Args
map_list: list of SLMap objects, optional

Users defined set of parameters scaling. There is default scaling for each object that accept ctrl method.

title: string, optional

Title of the window. If none is provided, the name of the class is used.

wxnoserver: boolean, optional

With wxPython graphical toolkit, if True, tells the interpreter that there will be no server window.

If wxnoserver is set to True, the interpreter will not wait for the server GUI before showing the controller window.

property speed

float or PyoObject. Transposition factor.

property interp

int {1, 2, 3, 4}. Interpolation method.