Before we go on to the mid term, we will review a few things:
9.1 Variables in Message Boxes
Variables are expressed with a $-sign. Usually they are used to refer to elements in a list, so that $1 refers to the first element in the list, $2 to the second, and so on.
In Figure 9.1 we have three constructions. The first two will produce the same output. Let’s start with pack, an object we use to make individual numbers into a list. In this case, pack is created with the arguments “f 40”, meaning that when we create the object, the number 40 in stored in the memory slot corresponding to the cold inlet. The number box connected to the hot inlet will give a value to f and execute the program (hot inlet), so you will get a list with a variable first element and 40 for the second.
In the second construction we put $1 in the first element of the message box. $1 is a variable that will take the value of the incoming number. Again this produces a list with a variable first element and 40 for the second.
In the third construction we try putting $1 in a different place in the list, and in the same way, $1 takes the value of the incoming number. The result is a list with 40 in the first element, variable in the second and 60 in the third.
In Figure 9.2 we see a new use. Instead of just placing $1 in a list, we now try two things:
- We place $1 inside a string.
- We also use $2.
In message boxes, $1 and $2 take the values of an incoming list. Thus, if we send 3 in the number box, pack will produce the list “3 40”.
The message box will then finally output the list “3-banana 40”.
Just to clarify, if the message box had the content “ban$2n$1”, the result would be “ban40n3”. Try these things out!
9.2 Variables and Abstractions
Abstractions can also have arguments. The arguments are lists of numbers and symbols, but let’s focus on numbers for now. Lets imagine an abstraction with the arguments “34 21”. Inside the abstraction you will be able to retrieve the values of the list of arguments in two ways:
- You can send a bang to an object [f $1] to get the argument (34). banging [f $2] will retrieve the second argument (21).
- You can put $-sign variables inside receive, send, throw~ and catch~ objects. Thus, inside this abstraction, the object [r orange-$1] will in effect become [r orange-34] and the object [throw~ app$2le] will in effect become [throw~ app21le].
Embedding $-sign variables in abstractions allows us to send individualized messages to each abstraction as we can see in Figure 9.3 below:
9.3 Vibrato / LFO Modulation
One thing that was really common in old subtractive synthesizers was something called an LFO, or Low Frequency Oscillator. If you have an oscillator with a Frequency of 1 Hz, increase its amplitude by a constant like 10, then your oscillator will go from 10 to -10 and back to 5 every second. If you add this oscillator’s output to a fixed number like 4oo, then you will now oscillate from 390 to 410.
If you send this output to the frequency input of an oscillator you should be able to hear how a vibrato. This is shown in Figure 9.4.