SNSamplePlayer:
Filter:
Classes (extension) | SNSampler

SNSamplePlayer : AbstractSNSampler : Object
ExtensionExtension

A sample looper, allowing to loop samples in various ways.

Description

Within its built-in looping modes a SNSamplePlayer lets you loop an array of consecutive buffers in such a way that all buffers are spread in the stereo or multichannel panorama. The built-in looping modes basically provide different ways of sequencing - either as audio grains within a Pbind or non-granular within a Pmono or Ndef. All these modes will create different output characteristics. However, to make playing most convenient and flexible, they all make use of the wonderful JITLib library, that allows an extremely flexible way of combining different concepts of sequencing and signal processing.

Class Methods

SNSamplePlayer.new(name: 'Looper', bufLength: 60, mode: 'grain', numOutChannels: 2, server, touchOSC, touchOSCPanel: 1, bufferLoader, bufLoaderPanel: 4)

Create a new SNSampleLooper instance

Arguments:

name

Optional - a Symbol or String, denoting the name of the new instance. If not given this willdefault to \Looper.

bufLength

Optional - the maximum length of a single loop in seconds. If not given this will default to 60. Often you will want to set this to the length of the buffers stored with an SNSampler.

mode

Optional - a Symbol or String, denoting the mode in which to play the looper. As of currently this may be one of the following:

\grain (default)
loops will be created as Synth grains in parallel playing Pbinds within a Ppar
\mono
loops will be created in a continously playing Pmono within a Ppar
\ndef
loops will be playing in an Ndef, using a BufRd. Looping will be handled by a Phasor
numOutChannels

Optional - a Integer, denoting the number of output channels. The looped buffers will automatically be spread accross all channels. Spreading the output is handled either by a Splay (if numOutChannels is set to 2) or a SplayAz ugen (for numOutChannels set to a value greater than 2). If not set this defaults to 2.

server

Optional - the Server on which to play the looper. If not set this will default to Server.default.

touchOSC

Optional - a NetAddr under which an installation of the popular TouchOSC OSC controller is running.

NOTE: The address will be used to send feedback to TouchOSC, so you must provide the port under which TouchOSC expects to receive OSC messages! Also, some of the widgets in CVCenter will automatically be connected, based on the IP address provided with the NetAddress. For this to work properly all elements in the TouchOSC interface (provided as layout file with SNSamplePlayer) need to be normalized, i.e. their output range must be 0.0-1.0.
touchOSCPanel

Optional - TouchOSC's user interface can be organized in a number of panels. Panels are numbered, beginning from 1. This is also reflected in TouchOSC's commandname structure. E.g. /1/toggle could be a toggle button on TouchOSC's first panel. If not given this will default to 1.

Returns:

an SNSamplePlayer instance

SNSamplePlayer.all

Returns:

an Event, holding all current SNSamplePlayer instances

Inherited class methods

Instance Methods

.setupPlayer(bufferArray, volumeControlNode: 1000, argBackupBuffers)

Set up the SNSamplePlayer before it can actually be played: Add an Array of buffers and define a node for an over-all volume control - setting the volume will be handled in a filter synth (more precisely: a NodeProxy role added to the end of an Ndef). If not given explicitely the volume control will be created with an ID 1000.

Arguments:

bufferArray

An Array of buffers that will be looped in the instance. Often this will be identical with an array of buffers created when setting up an SNSampler

volumeControlNode

Optional - an Integer, denoting the position of the volume control in the chain of synths and filters (defined in an Ndef or NodeProxy).

NOTE: This ID is not a regular node ID in the server tree!

.initDef(argMode, bufferArray)

Initialize or switch the mode in which the player will play. Available modes will be the ones described in *new.

Arguments:

argMode

A Symbol - either \grain, \mono or \ndef

bufferArray

Optional - an array of buffers, initialized with Buffer: *allocConsecutive.

NOTE: The number of buffers must be the same as the number of buffers for which the player was initialized!

.play

Start playing the SNSamplePlayer. Internally this will start playing the Ndef that keeps the loopers for all buffers. You may inspect the Ndef using an NdefMixer.

.pause

Pause the player. Internally this will pause the Ndef that keeps the loopers for all buffers.

.resume

Resume a paused player. Internally this will resume the Ndef that keeps the loopers for all buffers.

.quit(fadeTime: 0.2)

Quit the player. This will clear the loopers and all effects that have been chained to the output of the player. Once an SNSamplePlayer has been quit it can not be restarted but you can initialize a new one under the same name.

Arguments:

fadeTime

A Float or Integer, determining the fade-out time of the player in seconds.

.freeHangingNodes

When using mode \grain (the default) it may happen under certain circumstances that grains are not freed properly (they remain on the server, consuming memory). In these cases calling this method will clear all nodes and free memory. Though this may have an audible effect new grains should build up automatically and it will often be preferable to have a short moment of silence than running out of memory.

.setLoopMaxLength(index, length)

SNSamplePlayer has originally been designed to be used in combination with SNSampler, allowing you to record sound sequences up to a specified length on the fly. However, sound sequences won't necessarily fill up a whole buffer which means, when looping over the buffer, silence at the end of the buffer will be part of the loop. This method tells the looper how much of the buffer should be used for looping.

The method especially makes sense in combination with the doneAction of an SNSampler. The doneAction can be passed a numerical index (the index of the buffer in the array of consecutive buffers for which the maximum loop length shall be set) and the length of the loop in seconds.

Arguments:

index

An Integer or a whole-numbered Float, denoting the index of the buffer in the array of consecutive buffers.

length

A Float, denoting the length of the loop in seconds.

Instance variables

.debug

.debug = bool

If set to true the player will post information on the just played loops to the console.

Arguments:

bool

A Boolean (either true or false)

.touchOSC

.touchOSC = value

Set the NetAddr under which an installation of TouchOSC will be communicating with the sampler.

NOTE: The port given in the NetAddr will be the port under which TouchOSC is listening to OSC messages coming from SuperCollider!

.touchOSCPanel

.touchOSCPanel = value

TouchOSC's graphical user interface is typically organized in panels. A toggle button on the first panel may be addressed through the following command name: /1/toggle1. The touchOSCPanel should allow you to specify the panel under which buttons connected to the SNSamplePlayer live.

.numOutChannels

The number of output channels. This is not the same as the number of buffers. Internally each buffers plays to its own channel(s). All buffer channels will then be spread over the panorama either using Splay (stereo) or SplayAz (numOutChannels > 2).

Returns:

An Array of Integers

.loopLengths

As eplained in -setLoopMaxLength a buffer may be larger than the actual audio that it contains, leaving silence at the end of the buffer. This variable contains the lengths of actually recorded audio in seconds for all buffers as set by -setLoopMaxLength.

Returns:

An Array of Float

.name

The name of the instance as assigned in *new (internally converted to a Symbol if given as String).

Returns:

.bufLength

The full length of the buffers as given in *new. This will not be the same as actual length of audio written to them (see -loopLengths).

Returns:

.server

The Server on which to play the audio - either explicitely given in *new or simply Server.default.

.looperPlayer

The Ndef that holds the looper as its source. The looper can basically be a Function or a Pattern. If desired the output can be further processed by hooking up NodeProxy roles.

Returns:

An Ndef

.out

The Ndef that's actually playing to the out channels. The number of channels will be determined by the numOutChannels argument in *new. If desired the output can be further processed by hooking up NodeProxy roles.

Returns:

An Ndef

.group

The Group, respectively ParGroup in which the Ndef returned by *out will play. If scsynth is set engine this will resolve to Group. If supernova is used (multicore virtualistaion) a ParGroup will be returned. Setting the Ndef to explicit a group allows you to free all contained nodes contained in the group without stopping the player. See -freeHangingNodes for further explanation.

Returns:

A Group or a ParGroup

.buffers

.buffers = value

Get or set the array of consecutive buffers to be looped over.

Returns:

An Array of Buffers

.mode

The mode to which the SNSamplePlayer has been initialized: \grain, \mono or \ndef.

Returns:

Inherited instance methods

Undocumented instance methods

.backupBuffers

.bufLoaderPanel

.bufLoaderPanel = value

.bufferLoader

.bufferLoader = value

.def

.resetBuffer(index)

.setBuffer(index, newBuffer)

Examples