09.12.2012 Views

The Kyma Language for Sound Design, Version 4.5

The Kyma Language for Sound Design, Version 4.5

The Kyma Language for Sound Design, Version 4.5

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Algorithmic Splicing and Mixing<br />

Scripts<br />

To algorithmically specify when <strong>Sound</strong>s should start and how they should overlap in time, use the Script<br />

<strong>Sound</strong>, found in the Algorithms category of the prototypes. <strong>The</strong> Script algorithmically constructs a Mixer<br />

of <strong>Sound</strong>s within TimeOffsets according to a script. Each line of the script has the <strong>for</strong>mat<br />

soundName start: aTime.<br />

In other words, you type the name of an input, the word start:, and a time when a copy of the <strong>Sound</strong><br />

should start. Each of the inputs is used as a kind of model or template <strong>for</strong> creating a copy, so you can create<br />

any number of copies of each input, each one starting at a different time and even overlapping with<br />

each other in time.<br />

For example, the script,<br />

s1 start: 0 s.<br />

s2 start: 1 s.<br />

s1 start: 3 s.<br />

would result in the following timeline:<br />

s1<br />

s2<br />

0 1 2 3 4 5 6<br />

You can extend the idea of templates even further by making some of the parameters of the input <strong>Sound</strong>s<br />

variables instead of fixed constants. A variable is a word preceded by a question mark (and shows up in<br />

green in the user interface). <strong>The</strong>n you can set the values of the variable parameters from the script. <strong>The</strong><br />

<strong>for</strong>mat <strong>for</strong> setting a variable parameter from the script is:<br />

soundName start: aTime varName1: value1 … varNameN: valueN.<br />

In other words, after assigning the <strong>Sound</strong> a start time, list the name of each variable followed by a colon<br />

and the specific value that you would like to assign to that variable. For example, suppose you had a<br />

<strong>Sound</strong> whose Frequency field was ?freq and whose Gain field was ?amp. You could use the following<br />

line in a script to create a copy of that <strong>Sound</strong> whose frequency was 443 hertz, amplitude was one half, and<br />

start time was 3.2 seconds:<br />

a<strong>Sound</strong> start: 3.2 s freq: 443 hz amp: 0.5.<br />

As it turns out, these scripts are actually programs in the Smalltalk programming language. This can<br />

come in very handy in cases where you have some systematic description of the <strong>Sound</strong> you want to create.<br />

For example, say that you wanted to construct some new, strange kind of reverberation based on the<br />

HarmonicResonator. You decide that you would like to create a Mixer of six of these resonators, each<br />

with a slightly different resonant frequency. You could get a Mixer from the prototypes, open it up and<br />

drag six copies of the HarmonicResonator one-by-one from the prototypes into the Mixer, then alter each<br />

of the six Frequency fields one-by-one. <strong>The</strong>n if you wanted to adjust those settings, you would have to<br />

open each of the six one-by-one in order to test out a different set of Frequency values. Or you could<br />

instead leverage the power of programming and create those six copies in a loop:<br />

1 to: 6 do: [ :i |<br />

res<br />

start: 0 s<br />

freq: (0.5 * i + 25) hz].<br />

<strong>The</strong>n you could change the number of resonators simply by changing the 6 to a 10 (or whatever). And<br />

you could change the relationship between the frequencies, simply by changing the expression following<br />

the freq: message.<br />

71<br />

s1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!