Page  00000001 Continued Evolution of the SuperCollider Real Time Synthesis Environment James McCartney 3403 Dalton St. Austin, TX 78745 james @audiosynth.com http://www.audiosynth.com Abstract SuperCollider[McCartney, 1996] is aprogramming language and environment specialized for real time audio synthesis. SuperCollider version 2.0 (SC2) is a completerewrite of the system to make it more expressive, more efficient, andeasier to use. This required rethinking the implementation in light of theexperience of the first version. It is my opinion that the new version has benefitted significantly from thisrethink. It is not simply version 1.0 with more features. This paper willgive a brief overall description of the system followed by descriptions ofa few specific features. 1 The Language SuperCollider is now a fully objectoriented language very much like Smalltalk[Goldberg, 1989]. Many of theclass names and method names are the same as those in Smalltalk.The class library currently consists of over 250 classes, to which userscan add their own. There are Collection classes such as Arrays,Dictionaries, Sets, SortedLists, Bags, etc. There are a number of differences from Smalltalk that facilitate real timeoperation and computer music applications. Among these are: a real timegarbage collector, a method lookup table so that method lookup is as fast as for C++while still retaining the dynamism of Smalltalk style methods[Driesen, 1995], positional arguments, variable length argument lists like LISP's #restor C's varargs, default values for unsupplied arguments, initial constantvalues for local variables, full lexical closure semantics as in Scheme,ability to run at interrupt level. Why invent a new language and not use an existing language? Computer music composition is a specificationproblem. Both sound synthesis and the composition of sounds are complex problems anddemand a language which is highly expressive in order to deal with thatcomplexity. Real time signal processing is a problem demanding an efficientimplementation with bounded time operations. There was no language combining the features I wanted and neededfor doing digital music synthesis. There was no other language readilyavailable that was high level, real time and capable of running atinterrupt level. Why use a text based language rather than a graphical language? There are at least two answers to this: Dynamism: Most graphical synthesis environments use statically allocatedunit generators where one screen icon represents one unit generator. InSuperCollider, the user can create structures which spawn eventsdynamically and in a nested fashion. Patches can be built dynamically and parameterized not just by floating pointnumbers from a static score, but by other graphs of unit generators aswell. Or you can construct patches algorithmically on the fly. This kind of fluidity is not possible in alanguage with statically allocated unit generators. Brevity: In SuperCollider, symmetries in a patch can be exploited by eithermultichannel expansion or programmatic patch building. For example, thefollowing 5 line program generates a patch of 49 unit generators. In agraphical program this might requirea significant amount of time and space to wire up. Another advantage isthat the size of the patch below can be easily expanded or contracted justby changing a few constants, and it can be done on the fly, per event.

Page  00000002 // 10 voices of a random sine percussion sound: s = Mix.ar(Array.fill(10, { Resonz.ar(Dust.ar(0.2, 50), 200 + 3000.0.rand,0.003)})); // reverb predelay time: z = DelayN.ar(s, 0.048); // 7 length modulated comb delays in parallel: y = Mix.ar(Array.fill(7,{ CombL.ar(z, 0.1, LFNoisel.kr(0.1.rand, 0.04,0.05), 15) })); // two parallel chains of 4 allpass delays (8 total): 4.do({ y = AllpassN.ar(y, 0.050, [0.050.rand, 0.050.rand], 1) }); // add original sound to reverb and play it: Synth.play(s+(0.2*y)); ) 2 The Synthesis Engine A number of improvements have been made in version 2.0 to make thesynthesis engine both faster and higher quality. There are many new unitgenerators in version 2.0 and many of those retained from version 1.x havebeen improved. The synthesis engine is a two rate system, withan audio sample rate and a sample block size which determines the controlrate. Unit generators either calculate a block of samples or a single value per control period. Control ratesignals are now always linearly interpolated up to audio rate whenever theyare used in order to eliminate zipper noise. There is a unit generator named Spawn which canspawn sub-events. Each spawned event can have its own control rate blocksize. Spawned event start times and stop times are single sample accurate. The synthesis engine is now separate from the language virtual machine.This makes it more efficient than in version 1 where the synthesis loop wasexecuting language code every control period. Audio buffers such as sample files and delay lines can be allocateddynamically. Delay line unit generators do not require that their buffer bezero filled to begin with, which means there is no glitch if you decide toallocate and begin using an 8 seconddelay line on a moment's notice. 3 The Environment SC2 is a fairly nice simple styled text editorwhich has an embedded interpreter. Language examples may be executeddirectly froma document by selecting them. This allows you to write pieces that aretheir own documentation. There are no proprietary format patch files.SuperCollider compiles text files and reads sound files as independentobjects rather than being bundled together as they were in SuperCollider 1. There is a built in help system that will openhelp files for any class and generate templates for any method. Since SC2is a text editor, all of the documentation can be opened by SuperColliderdirectly and the examples can be executed right from the documentation. 4 Programming Writing synthesis algorithms is morestraightforward in version 2 and results in cleaner and clearer programsthan in version 1. UGen is the name of the class of unitgenerators. A unit generator is created by sending the 'ar' or 'kr' messageto the unit generator's class object which will create instances that run at audio rate or control raterespectively. There are currently over 160 different unit generatorsavailable to work with. SinOsc.ar(800, 0, 0.2); // create a sine oscillator at 800 Hz, phase 0,amplitude 0.2 A unit generator's signal inputs can be otherunit generators, scalars, or arrays of unit generators and scalars.

Page  00000003 In order to play a unit generator, it needs to be installed in a Synthobject. A Synth is a container for one or more unit generators that executeas a group. Synth.new(SinOsc.ar(800, 0, 0.2)).play; or more briefly: Synth.play(SinOsc. ar(800, 0, 0.2)); You can do math operations on unit generators and the result will beanother unit generator. Doing math on unit generators does not do anysignal calculation itself - it builds the network of unit generators thatwill execute once they are played in a Synth. For example, the following code builds a network of three unitgenerators (sine oscillator, noise generator, adder): SinOsc.ar(800, 0, 0.2) + BrownNoise.ar(0.2); Most unit generators have multiply and addinputs which allow a faster in place multiply-add to be performed. If these inputs are not specified then the additionaloperations are not performed so there is no overhead to having thisfeature. The example above could be written as follows by using thisfeature: SinOsc.ar(800, 0, 0.2, BrownNoise.ar(0.2)); 5 Events The Spawn unit generator spawns events and mixesthem to a number of output channels. Spawn takes as an argument a functionthat creates a network of unit generators. Spawn calls this function for each event. Because Spawnis a unit generator that is a mix of sub-events, it makes it easy to applyeffects processing to an entire mix, or to have controllers that range overa series of events such as a phrase envelope. Spawned events are spliced together with single sampleaccuracy and each event may have its own sample block size. Spawn takescare of all the mixing and splicing. e = Env.linen(2, 5, 2, 0.02); II 9 second trapezoid envelope specification,amplitude 0.02 Synth.play( II spawn random panned sine waves of random frequency each 1/2 second Spawn. ar({ Pan2.ar(I/ two channel panner FSinOsc. ar(2000.0.rand, EnvGen.kr(e)), II sine oscil with anenvelope 1.0.rand2) II random pan position 2, I/two output channels 0.5) II new event each 1/2 second Instances of Spawn can spawn sub-events whichthemselves contain instances of Spawn that spawn sub-sub-events and so onto any depth. An instance of Spawn may have any number ofoutput channels and sub-events(which themselves may have any number ofchannels) may be placed at a particular channel in the output. Byseparating the output channels one may apply different effects to differentchannels of a Spawn, thereby using Spawn like a mixer with different effects sends on each channel. Spawn can be used as a building block for otherhigher level constructs such as score players. The two classes XFadeTextureand OverlapTexture are built upon Spawn and are used to generate continuous cross fading textures from any synthesis function.

Page  00000004 6 External Control External control is implemented via the Controlln unit generator. ControlIntakes as an argument a control source which may be re-patched at any timeto any other source. Sources may be any MIDI source such as controllers,pitch bend, pressure, etc., or mouse x or y position, graphical user interface controls, a floating pointvariable, or anything that responds to the 'value' message with a Floatsuch as a function or a stream or practically anything else. Controlln has a built in one pole smoothing filterto alleviate zipper effects. The control source's domain can be mappedeither linearly or exponentially to a desired range. II Mouse control of a sine wave frequency Synth.play( SinOsc. ar(Controlln.kr(MouseX.new(200, 2000, 'exponential')),0, 0.4)) or more briefly (the MouseX object knows how to wrap itself in a Controllnobject): Synth.play( SinOsc. ar(MouseX. kr(200, 2000, 'exponential'), 0, 0.4)) 7 Graphical User Interface SuperCollider contains a graphical user interface builder and code generatorin order to implement synthesis control panels. Windows can be built bydragging and dropping controls and then generating the code to instantiatethe window. In version 1 there was only one control panel window, but version 2 may have many control panelsopen at once and they can be instantiated by user code. 8 Conclusion Why is SuperCollider interesting? SuperCollidercombines real time performance and control with a high level programming language, dynamic patch construction, and a graphical userinterface builder. Its styled text editor interface makes it ideal fordemonstrating synthesis algorithms in an interactive tutorial. The abilityto add ones own classes to the library makes it a good environment for exploring higher level constructs. 9 Availability SuperCollider currently runs only on PowerMacintosh. A development version of SuperCollider 2 can be obtained fromthe directory ftp://www. audiosynth. coml/pub/5C2/ The exact file name will depend on the version currently available. Thefinal version will be announced on http://w ww.audio synth.com References [Driesen, 1995] Driesen, Karel andH~lzle, Urs 1995. "Minimizing Row Displacement Dispatch Tables",Technical Report TRCS 95-05, Dept. of Computer Science, Univ. of California, Santa Barbara. available via ftp from ftp.cs.ucsb.edu. [Goldberg, 1989] Goldberg, Adele and Robson,David 1989. Smalltalk-80: The Language, AddisonWesley, ReadingMas sachusetts. [McCartney, 1996] McCartney, James 1996. "SuperCollider: a new real time synthesis language", Proc. ICMC HongKong.