Reference | Common methods

# play

Start a process

### play

The `play` message is of common use in sc. Different objects respond to it in various ways, but the simple meaning is: start a process. It is usually implemented by objects in contributed libraries as well.

play usually returns the playing object which might not be the same as the one the message was sent to.

opposite: `stop`

## Clocks, Routines, Streams and Patterns

For a full list of which classes that implements `play`, see Methods: play

### clock.play (stream)

returns: the clock( r = Routine.new({ "...playing".postln; 1.wait; "ok, that was it".postln }); SystemClock.play(r); )

See Clock: *play

### routine.play (clock)

returns: the routineRoutine.new({ "...playing".postln; 1.wait; "ok, that was it".postln }).play;

See Routine: -play

### stream.play (clock)

returns: the stream

the stream will loop until it returns nilFuncStream({ "ok, that was it".postln; 1 }).play;

See FuncStream: -play

### pausestream.play (clock) / task.play (clock)

returns: the streama = PauseStream.new(FuncStream.new({ "ok, that was it".postln; 1 })); a.play; a.stop; a.play; a.stop; a = Task.new({ loop({ "ok, that was it".postln; 1.wait; }) }); a.play; a.stop;

See Stream: -play and Task: -play

### pattern.play (clock, protoEvent)

returns: an EventStreamPlayer( Pseq([ Pbind(\freq, Pn(500, 1)), Pbind(\dur, Pn(0.1, 1)) ], 2).play; )

See Pattern: -play

## Playing single Synths from SynthDefs on the server

The following play messages both cause a SynthDef to be written, send it to the server and start a synth with it there.

NOTE: Some UGens are added in this process.

- an Out UGen for playing the audio to the first audio busses. If the function returns an Out UGen, this is omitted.
- an envelope with a `gate` control for releasing and crossfading. If the function provides its own releasable envelope, this is omitted.

Also note that they should not be used in quickly running automated processes, as there are more efficient alternatives ( see SynthDefs versus Synths )

### function.play (target, outbus, fadeTime, addAction, args)

returns: a Synth

outbus | on what bus to play (default: 0)
fadeTime | in what time to fade out when released (default: 0.02)
addAction | where to add the node (\addToHead by default)
args | controls to set when starting the synth

See Function: -play a = { PinkNoise.ar([0.1, 0.1]) }.play; a.release; // setting argument a = { |freq = 500| HPF.ar(PinkNoise.ar([1, 1] * 0.4), freq) }.play; a.set(\freq, 1000) a.release; // passing argument with play: a = { |freq = 500| HPF.ar(PinkNoise.ar([1, 1] * 0.4), freq) }.play(args: [\freq, 10000]); // note that you can use Out ugens but you do not need to { Out.ar(1, PinkNoise.ar(0.1)) }.play; { XOut.ar(0, MouseX.kr(0,1), PinkNoise.ar(0.1*[1,1])) }.play; // mouse x controls level

### synthDef.play (target, args, addAction)

returns: a Synth

Note that you need an out ugen to hear the result. Examples of how to write to the busses in the helpfiles: Out / ReplaceOut / XOut / OffsetOut

Nevertheless, synths can also run without any writing activity: (see e.g. SendTrig)

Some operations provide an out ugen internally: see for example `function.play`, which plays out to a bus number provided in the argument passed to `.play`( x = SynthDef(\test, { arg out, amp=0.1; var sound; sound = PinkNoise.ar(amp * [1,1]); Out.ar(out, sound); }).play; ) //set the synth x.set(\amp, 0.2); //free the synth x.free;

See SynthDef: -play

NOTE: `Synth.play(function)` is synonymous, for backwards compatibility with sc2
helpfile source: /Applications/SuperCollider.app/Contents/Resources/HelpSource/Reference/play.schelp
link::Reference/play::