A Quick Introduction to SuperCollider | Designing Sound Designing Sound
-
Upload
nachothefreeloader -
Category
Documents
-
view
213 -
download
0
Transcript of A Quick Introduction to SuperCollider | Designing Sound Designing Sound
-
7/27/2019 A Quick Introduction to SuperCollider | Designing Sound Designing Sound
1/7
23/10/13 23:34A Quick Introduction to SuperCollider | Designing Sound Designing Sound
Pgina 1 de 7http://designingsound.org/2013/04/a-quick-introduction-to-supercollider/
A Quick Introduction toSuperColliderPosted by Shaun Farley on Friday, April 26, 2013 4 Co mments
Guest Contribution by Graham Gatheral
Lets be honest: code can be daunting.Lets be honest: code can be daunting. All those words and numbers and operators and
punctuation errors For a start, theres no GUI. How are you supposed to make anything without a
GUI?!
Well, as well see later we can make a GUI-based synth in SuperCollider with just a few dozen lines of
code! But lets put GUIs to one side for now, because SuperColliders real power is in its ability to
produce flexible and complex dynamic systems directly from code, and without too much
trepidation My aim here is to introduce an audio synthesis programming language to an audience
that is, for the most part, more comfortable working with a GUI. So Ill start off with some simple
code examples and then move onto how SuperCollider can use game-code parametric data to drive
synthesis patches in real-time.
If you dont have SuperCollider already, download an installer here:
http://supercollider.sourceforge.net/downloads/
Regarding platforms, Im on Windows 7 but the code will certainly run f ine on a Mac.
WarningWa rn in g: The code examples below were written for demonstration purposes and have not been
fully tested. Please be careful not to expose your ears to loud sounds (particularly when using the
metal impacts tuner) as stable behaviour cannot be guaranteed. This is especially cr itical if using
headphones!
A Quick IntroductionA Quick Introduction
SuperCollider consists of three components:
an object or iented programming language
a language interpreter
a real-time sound synthesis server
When code is executed, it is interpreted and sent to the server, whereupon the sound is generated.
SuperCollider has had an Integrated Development Environment (IDE) since version 3.6, which is
great because now you have everything you need in one place:
Code editor (where you write your code!)
Help browser
Post window (shows the outcome of your code, including any errors)
Document browser [not shown below]
Search
Mailing List
SearchH OM E FE AT UR ES I NT ER VI EWS NE WS R EV IE WS BE HI ND T HE A RT RE SOU RC ES A RCH IV ES A BOU T C ONT AC T
http://supercollider.sourceforge.net/downloads/http://eepurl.com/cvOQjhttp://designingsound.org/http://designingsound.org/http://designingsound.org/contact/http://designingsound.org/about/http://designingsound.org/archives/http://designingsound.org/resources/http://designingsound.org/behind-the-art/http://designingsound.org/category/reviews/http://designingsound.org/category/news/http://designingsound.org/category/interviews/http://designingsound.org/category/features-2/http://designingsound.org/http://eepurl.com/cvOQjhttp://designingsound.org/feedhttp://www.youtube.com/user/designingsoundhttp://facebook.com/pages/Designing-Sound/184585721570http://twitter.com/designingsoundhttp://supercollider.sourceforge.net/downloads/http://designingsound.org/2013/04/a-quick-introduction-to-supercollider/#commentshttp://designingsound.org/author/shaun/http://designingsound.org/ -
7/27/2019 A Quick Introduction to SuperCollider | Designing Sound Designing Sound
2/7
23/10/13 23:34A Quick Introduction to SuperCollider | Designing Sound Designing Sound
Pgina 2 de 7http://designingsound.org/2013/04/a-quick-introduction-to-supercollider/
Lets get started!Lets get started!
Loading the IDE (scide.exe in your install directory) will automatically run the language interpreter,
so we just need to press CTRL+B to boot the serverand were ready to go. Copy and paste the
following example into the Code editor. To execute the line of code, place the cursor on the line and
press CTRL+Enter.
{SinOsc.ar(440, 0 , 0.1)}.play;The playmessage is a quick way to evaluate some code in the example above, were wrapping a
440hz Sine wave oscillator function in a SynthDef(synthesis definition), and then creating and
starting a new instance of it.
To stop SuperCollider at any time use CTRL+. (ctrl + period)
Okay so theres nothing exciting about that sine wave but stay with me! Lets create a cascade of
16 sine waves, each with a random pitch between A220 and A880
{16.do({{SinOsc.ar(Rand(220,880), 0 ,0.05)}.play; 0.1.wait;})}.fork;
Often the best way to learn is to dive in and edit some parameters try the following:
change the number preceding .doto change the number of sine waves
change the two numbers after Randto define the upper and lower pitch values
change the number before .waitto change the interval between each new sine wave
change the oscillator: replace SinOscwith LFTrior LFSaw, for example
Heres a couple more code examples (from the Help browser)
{ SinOsc.ar(SinOsc.ar(XLine.kr(1, 1000, 9), 0, 200, 800), 0, 0.25) }.play;
{ SinOsc.ar(800, SinOsc.ar(XLine.kr(1, 1000, 9), 0, 2pi), 0.25) }.play;
To begin integrating SuperCollider into a game engineTo begin integr ating Super Colli der into a gam e en gine, we need to be able to change synth
parameters in real-time. To do this we can wr ite a SynthDef, declare some arguments(later well be
passing numerical data via argumentsto parameters in the SynthDef) and send it to the server,
ready for use.
The example below will create a new SynthDefwhich Im naming sinewave. Ive created an
argument, given it the name freq and assigned it a default value of 440. Ive also c reated a variable
called output and assigned our sine wave oscillator as its value. Finally, the OutUGen (more on
these later) is writing the output to the left and right channels of our audio hardware. (search the
help browser if you want more info on whats happening here!)
(
SynthDef(\sinewave,{|freq = 440|
varvar output = SinOsc.ar(freq, 0 ,0.1);
Out.ar([0,1], output);
}).send;
)
Execute this block of code by placing the c ursor anywhere between the outermost parentheses and
http://designingsound.org/wp-content/uploads/2013/04/SC_IDE_lrg1.png -
7/27/2019 A Quick Introduction to SuperCollider | Designing Sound Designing Sound
3/7
23/10/13 23:34A Quick Introduction to SuperCollider | Designing Sound Designing Sound
Pgina 3 de 7http://designingsound.org/2013/04/a-quick-introduction-to-supercollider/
press CTRL+Enter.
Now, to create a Synthusing this SynthDef, we write the following code (xis just a global variable we
can use without first needing to define):
x = Synth(\sinewave);
and we hear our trusty sine wave. Now we can change the frequency of the sine wave by
executing this code to set the value of the freqargument to 220:
x.set(\freq, 220);So we can use SynthDefs(synthesis definitions) to c reate and run Synths, and then pass in
argumentsto change their parameters (known as Class Methods) in real-time. We can do m ore than
pass in argumentsfrom within SuperCollider though: we can take numerical data from other
systems and send it to SuperCollider as bundled OSC messages and this is how we can hook
SuperCollider up to a game engine.
I ve put up some tutorials on how to link UDK to SuperCollider:I ve put up som e tutorials on how to link UDK to SuperCollider:
Beginning with Weapon Fire
Sending Dynamic Data
Sending OSC via Kismet
Its a bit too much to delve into here, but to summarise: on the UDK side we write some code in
UnrealScript that accesses an OSC message send function stored in a custom DLL. The OSC send
function ( see Ross BencinasOSCPack) sends the message over UDP (a network protocol) to an IP
address and port defined in the DLL (in this case 127.0.0 .0 since I have everything running on the
same machine). Then you tell SuperCollider to listen out for the incoming OSC message and give it
some instructions on what to do with the data when it arrives.
This is derived from Rob Hamiltons excellent UDKOSC project.
(DLLBind is a f eature in UnrealScript and its required here because the OSC send functions are
written in C++. If youre working with a licenced version of Unreal you could maybe just integrate
the OSC classes into the source code and open up a direct link between Unreal and SuperCollider).
Now you have a system that can take almost any game code variable (floats, integers, strings etc) at
run time and use it to change SuperCollider synth parameters in real-time. Here are a few examples
of what you could use it for:
Generating one hit sfx for weapon fire, footsteps, metal impacts
Varying the intensity of wind, running water, ambient drones
Changing the dynamics of a generative music piece
The building blocks of SuperCollider are calledThe building blocks of SuperCollider are called UGensUGens(Unit Generators).(Unit Gener ator s). To put it
simply, UGenstake inputs and use them to produce sound. As previously seen, a sine wavetable
oscillator UGen(SinOsc) can be given inputs for frequency, phase offset, output multiplierand add
value to output.
{SinOsc.ar(440, 0 , 0.1, 0)}.play;
The DynKlankUGen is a bank of frequency resonators that we can use to approach physical
modelling. Using DynKlankwith an exciter UGen such as Impulsecan achieve some pretty good
metal impact sounds. Heres a quick example which triggers a SynthDefmade up of two DynKlank
UGens and some filter UGens. (You can view a variation o f this code in the Metal Impacts tuner
http://designingsound.org/wp-content/uploads/2013/04/UDKtoSCdiagram.pnghttps://ccrma.stanford.edu/wiki/UDKOSChttps://code.google.com/p/oscpack/http://www.gatheral.co.uk/tutorials/udk-supercollider/index.php?/archives/4-Sending-OSC-via-Kismet.htmlhttp://www.gatheral.co.uk/tutorials/udk-supercollider/index.php?/archives/3-Sending-dynamic-data.htmlhttp://www.gatheral.co.uk/tutorials/udk-supercollider/index.php?/archives/2-Weapon-fire.html -
7/27/2019 A Quick Introduction to SuperCollider | Designing Sound Designing Sound
4/7
23/10/13 23:34A Quick Introduction to SuperCollider | Designing Sound Designing Sound
Pgina 4 de 7http://designingsound.org/2013/04/a-quick-introduction-to-supercollider/
below)
I set up some Kismet that would send a message to SuperCollider every time the sword c ame into
contact with the metal pipe. Hitting different parts of the pipe will result in different impact sounds:
hitting the top, shorter part produces a less resonant sound for example. So the OSC message
contains parametric data to change values of the SynthDef that control the r ing times.
One of the most appealing aspects of using SuperCollider is that you can achieve a lot with very little
code. Heres a GUI interface for a m etal impact tuner that could be used to gather the parameters
required on the UDK side for generating a range of metal impact sounds in SuperCollider. For
example, an audio designer could open the GUI, tweak the frequency, ring time, filtering and reverb
settings until he/she has the required sound, then make a note of the parameters and feed them into
UDK to control a dedicated metal impacts synth in SuperCollider.
And heres a video of the GUI in use:
http://designingsound.org/wp-content/uploads/2013/04/SC_Metal_GUI.png -
7/27/2019 A Quick Introduction to SuperCollider | Designing Sound Designing Sound
5/7
23/10/13 23:34A Quick Introduction to SuperCollider | Designing Sound Designing Sound
Pgina 5 de 7http://designingsound.org/2013/04/a-quick-introduction-to-supercollider/
You can see how easy it is to make a GUI and control a wide range of metal impact sounds from the
same 40 lines of code:
(
w = Window.new("Metal Impact Tuner", Rect(200, Window.screenBounds.height-700,1055,600
SynthDef(\Rate, {|rate=1, out=5|
~playrate = Impulse.ar(rate, 0, 0.3);
Out.ar(out, ~playrate)
}).send(s);
SynthDef(\Bank1, {|out=2, freqA1=2000, freqA2=2000, freqA3=2000, freqA4=2000, freqA5=20
ringA2=2, ringA3=2, ringA4=2, ringA5=2| ~signal1 = DynKlank.ar(`[[Lag.kr(freqA1+40,1),
Lag.kr(freqA2+40,1), Lag.kr(freqA3+40,1), Lag.kr(freqA4+40,1), Lag.kr(freqA5+40,1)], nil,
[ringA1, ringA2, ringA3, ringA4, ringA5]], In.ar(5), 0.2, 0, 1).dup*0.4;
Out.ar(out, ~signal1)
}).send(s);
SynthDef(\Bank2, {|out=3, freqB1=2000, freqB2=2000, freqB3=2000, freqB4=2000, freqB5=20
ringB2=2, ringB3=2, ringB4=2, ringB5=2| ~signal2 = DynKlank.ar(`[[Lag.kr(freqB1+40,0.3)
Lag.kr(freqB2+40,0.3), Lag.kr(freqB3+40,0.3), Lag.kr(freqB4+40,0.3), Lag.kr(freqB5+40,0.3
nil, [ringB1, ringB2, ringB3, ringB4, ringB5]], In.ar(5), 0.2, 0, 1).dup*0.4;
Out.ar(out, ~signal2)
}).send(s);
SynthDef(\Filter, {|out=4, cutoff=1000|
var output;
~filtered = HPF.ar(SinOsc.ar(Rand(324,352)) * In.ar(2), Lag.kr(cutoff+20,1), 0.8) +
HPF.ar(SinOsc.ar(Rand(466,546)) * In.ar(3), Lag.kr(cutoff+20,1), 1);
~output = Mix.ar(CombL.ar(~filtered, Rand(0.3, 1.8), Array.fill(10,{(0.005).(0.01).rand2 + 0
Out.ar(out, ~output)
}).send(s);
SynthDef(\Output, {|gain=0.2, revsize=5, revtime=3, revdamp=0.5, revdry=1|
var output;
output = Mix.ar(CombL.ar(In.ar(4), Rand(0.3, 1.8), Array.fill(1, 0.07) * 0.06, 0.08));
2.do({output = AllpassN.ar(output, 0.020, [0.020.rand,0.020.rand], 1, mul:0.9) });
~reverb = GVerb.ar(In.ar(4), Lag.kr(revsize,0.3), Lag.kr(revtime,0.7), revdamp, 0.5, 15, re
output = ~reverb.dup*(gain/5);
output = output.clip2(0.75);
output = Limiter.ar(output, 0.9, 0.01);
Out.ar([0,1], output*0.5);
}).send(s);
Synth(\Bank1).autogui(window:w, step:50, vOff: 0, hOff:0, scopeOn:true) ;
Synth(\Rate, addAction:\addToHead).autogui(window:w, step:50, vOff: 0, hOff:830, scopeOn:faSynth(\Bank2, addAction:\addToTail).autogui(window:w, step:50, vOff: 200, hOff:0, scopeOn:fa
Synth(\Filter, addAction:\addToTail).autogui(window:w, step:50, vOff: 400, hOff:0, scopeOn:fal
-
7/27/2019 A Quick Introduction to SuperCollider | Designing Sound Designing Sound
6/7
23/10/13 23:34A Quick Introduction to SuperCollider | Designing Sound Designing Sound
Pgina 6 de 7http://designingsound.org/2013/04/a-quick-introduction-to-supercollider/
Reply
Nishant Pawar
April 28, 2013
Reply
Simon Leary
May 2, 2013
Synth(\Output, addAction:\addToTail).autogui(window:w, step:50, vOff: 400, hOff:360, scopeO
)
The Metal Impact Tuner is a work in progress, if you run the code be aware that the Out values need
to be as they are and c hanging them will break it. Also, the revtime control is a little unpredictable
Apart from that, have fun with it! To run the code youll need to install the autogui Quark (Quarks
are like plugins for SuperCollider). Its fairly straightforward in MacOS, just execute the following
code:
Quarks.install("autogui")
Its more complicated on Windows, but you can find instructions here.
Thanks for reading, please post in the comments if you spot an inaccuracy or something doesnt
work! If you want to find out more, theres a vibrant community of SuperCollider users on the sc-
users mailing list - and many excellent resources online, a few of which are below.
SuperCollider home - http://supercollider.sourceforge.net/
Browse code snippets and submit your own - http://sccode.org/
SuperCollider wiki - http://supercollider.sourceforge.net/wiki
Design sound effects - Designing Sound in SuperCollider
Special thanks toGraham Gatheralfor sharing his expertise through this guest contribution. Guest
contributions are always welcome and are encouraged here on Designing Sound. If you have
something youd like to share with the community, contact shaun [at] designingsound [dot] org.
Tweet 16 2
Category: featured, guest post, slideshow Tags: audio implementation, dsp environments, game audio, graham
gatheral, procedural audio, SuperCollider, synthesis, unreal
4 Comments on A Quick Introduction to SuperCollider
Great article ! ive always wanted to try this but never managed to get past
downloading, having no knowledge of code
this article would help a lot i am sure
Great article Graham. Ive been researching procedural audio for a few years
now, and it never ceases to amaze me. Abstracting the data interface to OSC is
a brilliant idea, the possibilities are endless! Im an Audio Programmer/Sound
Designer at Magenta Software and I would love to implement this with our
game engine.
Where do all the procedural audio heads hang out? Is there a mailing list or
forum you could recommend?
Pingback: The Theatre Sound Colloquium (and thoughts on sound design) | Designing Sound
Designing Sound
Pingback: GANG Newsletter: April 201 3
Leave a Reply
Your email address will not be published. Required fields are marked *
Name *
LikeLike 89
http://audiogang.dreamhosters.com/blog/gang-newsletter-april-2013/http://designingsound.org/2013/08/the-theatre-sound-colloquium-and-thoughts-on-sound-design/http://designingsound.org/tag/unreal/http://designingsound.org/tag/synthesis/http://designingsound.org/tag/supercollider/http://designingsound.org/tag/procedural-audio/http://designingsound.org/tag/graham-gatheral/http://designingsound.org/tag/game-audio/http://designingsound.org/tag/dsp-environments/http://designingsound.org/tag/audio-implementation/http://designingsound.org/category/slideshow/http://designingsound.org/category/guest-post/http://designingsound.org/category/features-2/http://gatheral.co.uk/http://en.wikibooks.org/wiki/Designing_Sound_in_SuperColliderhttp://supercollider.sourceforge.net/wikihttp://sccode.org/http://supercollider.sourceforge.net/http://www.birmingham.ac.uk/facilities/BEAST/research/supercollider/mailinglist.aspxhttp://schemawound.com/post/25034686704/quarks-on-windowshttp://twitter.com/search?q=http%3A%2F%2Fdesigningsound.org%2F2013%2F04%2Fa-quick-introduction-to-supercollider%2Fhttps://twitter.com/intent/tweet?original_referer=http%3A%2F%2Fdesigningsound.org%2F2013%2F04%2Fa-quick-introduction-to-supercollider%2F&text=A%20Quick%20Introduction%20to%20SuperCollider&tw_p=tweetbutton&url=http%3A%2F%2Fdesigningsound.org%2F2013%2F04%2Fa-quick-introduction-to-supercollider%2F&via=designingsoundhttp://designingsound.org/2013/04/a-quick-introduction-to-supercollider/#comment-31425http://designingsound.org/2013/04/a-quick-introduction-to-supercollider/?replytocom=31425#respondhttp://designingsound.org/2013/04/a-quick-introduction-to-supercollider/#comment-29936http://www.meteorsound.com/http://designingsound.org/2013/04/a-quick-introduction-to-supercollider/?replytocom=29936#respond -
7/27/2019 A Quick Introduction to SuperCollider | Designing Sound Designing Sound
7/7
23/10/13 23:34A Quick Introduction to SuperCollider | Designing Sound Designing Sound
Pgina 7 de 7http://designingsound.org/2013/04/a-quick-introduction-to-supercollider/
Post Comment
Email *
Website
Comment
Notify me of follow-up comments by email.
Notify me of new posts by email.
All content on Designing Sound is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Magazine Theme v4 by Organic Themes RSS Feed Log in
http://designingsound.org/wp-login.phphttp://designingsound.org/feed/http://www.organicthemes.com/http://www.organicthemes.com/themes/magazine-theme/