Product SiteDocumentation Site The "play" Function

The play function does exactly what it says: it plays its input. The input must be a function with an audio-rate signal generator as the return value.
The following two examples produce the same output:
{ 440, 0, 0.2 ); }.play;
play( { 440, 0, 0.2 ); } );
The first example is written from an object-oriented perspective. Functions know how to play their return value, when passed the play message. This is true of all Functions whose return value is an audio-rate UGen. The second example is written from a functional perspective. The Function called play will play its input, which must be a Function whose return value is an audio-rate UGen. Whether you should write play in the functional or object-oriented way depends on which makes more sense to you.
Try to re-write the above example so that the play function operates on a variable-defined Function.
The arguments to SinOsc, whether the audio- or control-rate generator, are these:
  • The first is called freq; it sets the frequency.
  • The second is called add; it is added to all values produced by the UGen.
  • The third is called mul; all values produced by the UGen are multiplied by this.
You now know enough to spend hours with the sine oscillator UGen. Try combining audio- and control-rate UGens, and try to figure out what happens when each of the arguments is adjusted. Be careful that your audio interface's volume isn't set too high! Experiment with this one:
   var myFrequency = freq:1, mul:200, add:400 );
   var sound = { myFrequency, 0, 0.2 ); };

   play( sound );