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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Variables<br />

could be rewritten as a loop:<br />

0 to: 2 do: [ :i |<br />

anInstr<br />

start: i s<br />

freq: ((i + 1) * 100) hz<br />

dur: 1 s].<br />

In the loop above, the expression within brackets<br />

anInstr start: i s<br />

freq: ((i + 1) * 100) hz<br />

dur: 1 s<br />

is iteratively evaluated with i set to the values 0, 1, and 2.<br />

To learn more about how you can use Smalltalk in a script, refer to the Script examples in the file<br />

Scripts.<br />

<strong>Kyma</strong> Variables<br />

A <strong>Kyma</strong> variable represents the value of a <strong>Sound</strong> parameter; it can be a Variable <strong>Sound</strong>, a <strong>Sound</strong>CollectionVariable,<br />

or a name preceded by a question mark.<br />

You can use <strong>Kyma</strong> variables in a script. <strong>The</strong> following example plays a harmonic series (of ?total harmonics<br />

of 100 hz, spaced 1 second apart):<br />

1 to: ?total do: [ :i |<br />

pluck start: (i - 1) s freq: (100 * i) hz].<br />

<strong>The</strong> variable ?total controls the number of times the code within the square brackets is executed; thus,<br />

it determines the number of events in this Script. When you load this Script <strong>Sound</strong>, <strong>Kyma</strong> will prompt<br />

you <strong>for</strong> a value <strong>for</strong> ?total. As the use of <strong>Kyma</strong> variables in this sample script suggests, scripts can be<br />

used as inputs of other scripts.<br />

Variables in Scripts and FileInterpreters<br />

Each event in a Script or FileInterpreter script corresponds to a mapping of variable names to values <strong>for</strong><br />

those variables. When you load a Script, it binds the variables of its input(s) to the values supplied in the<br />

script.<br />

You can see a list of the selected <strong>Sound</strong>’s variables by choosing Get info from the Info menu.<br />

If the script fails to map one of the variables to a value, then you must supply a value <strong>for</strong> that variable in<br />

some other way, either by entering values when prompted, by using the <strong>Sound</strong> as an example <strong>for</strong> a new<br />

class, or by making the <strong>Sound</strong> an input of another Script or FileInterpreter.<br />

<strong>Kyma</strong> variables in the script of a Script or a FileInterpreter are treated just like variable parameters. <strong>The</strong>se<br />

variables must be set from “outside” (that is, from some <strong>Sound</strong> to the right of them in the signal flow diagram).<br />

Smalltalk Variables<br />

You can also use Smalltalk variables in a script. A Smalltalk variable has no preceding question mark;<br />

instead it has to be declared at the beginning of the script in which it is used. Smalltalk variables are used<br />

as temporary storage locations within a script. <strong>The</strong>y do not directly represent <strong>Sound</strong> parameters.<br />

A Smalltalk variable is defined only within the script in which it appears. A <strong>Kyma</strong> variable is defined<br />

throughout the entire <strong>Sound</strong> structure in which it appears.<br />

Smalltalk variables must be declared at the beginning of the Script by typing them between vertical lines,<br />

| curTime curFreq |<br />

528

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

Saved successfully!

Ooh no, something went wrong!