-
~
in~mul
The tilde symbol,~
, followed by a word beginning with a lower character, is used to indicate environment variables. Environment variables act like global variables in the environment in which they are defined:
Environment | SuperCollider 3.12.2 Help
Except for large or specific projects, I don’t think there is usually a need to define and switch between multiple environments.There are three types of variables in sclang:
- Interpreter variables
- Global scope variables, which can be used by assigning a value to the variable:
- A single lowercase letter from
a
toz
. s
is assigned Server.local by default, and users should not reassign it with a different value, as s with the default value is used in the help documents and by many users.
( a = 1; b = 2; a + b )
- Local variables
- Local scope variables, which should be defined with the keyword
var
- A word starting with a lowercase character.
( a = 0; { var a, b; a = 3; b = 5; a + b }.().postln; a // This a is outside the code block above, so its value is not 3, but 0. )
- Local scope variables, which should be defined with the keyword
- Environmental variables:
- can be used by assigning a value
- See above for details.
( ~freq1 = 440; ~freq2 = 441; ~freq2 - ~freq1 )
- Interpreter variables
-
!
is a ‘syntactic sugar’ (a syntactic shortcut) ofdup
.
The following examples are all the same:[1, 1, 1] 1!3 1.dup(3)
-
\
in\amplitudes.kr(...)
and\mul.kr(...)
Please read the thread below:
NamedControl: a better way to write SynthDef arguments
The following PDF would be very helpful for you (it is really gentle):