Backwards Compatibility:
Filter:
Guides | Language > SC3 vs SC2

Backwards Compatibility

Classes and methods that improve backwards compatibility with SC2 code

There are a number of classes and methods that have been added to allow for backwards compatibility with SC2 code. The most notable of these is Synth.play, which is basically a wrapper for Function.play.

Both of these will create synth nodes on the default server. Note that neither requires the use of an Out.ar UGen; they simply output to the first audio bus. One can however add an Out to Function.play in order to specify.

In general, one should be aware of this distinction when using this code. When copying such code for reuse with other SC3 classes (for example in a reusable SynthDef), it will usually be necessary to add an Out.ar. Although useful for quick testing these methods are generally inferior to SynthDef.play, as the latter is more direct, requires no modifications for general reuse, has greater general flexibility and has slightly less overhead. (Although this is insignificant in most cases, it could be relevant when large numbers of defs or nodes are being created.)

Like SynthDef.play, Function.play returns a Synth object which can then be messaged, etc. However, since Function.play creates an arbitrarily named SynthDef, one cannot reuse the resulting def, at least not without reading its name from the post window, or getting it from the Synth object.

Function.play is in general superior to both its SC2 equivalent and Synth.play. It has a number of significant features such as the ability to specify the output bus and fade times as arguments. See the Function helpfile for a more in-depth discussion.

A number of other classes and methods have also been added to improve compatibility. These are listed below. In general there are equivalent or better ways of doing the same things in SC3.

Synth *playuse Function.play or SynthDef.play
GetFileDialoguse Dialog
GetStringDialog
Synth *stopuse Server.freeAll
Synth *isPlayingServer.numSynths (this will include non-running nodes)
Mix *ar *arFilluse Mix *new and *fill
SimpleNumber.rgb
Rawarray.write