Play a MIDI file

Do this and that.

poll and scope

Check what's going on with your UGens:

{LFNoise0.kr(5).round(0.01).poll(label: "watchThis")}.scope
// by default, poll is triggered 10 times per second, but you can change it:
{LFNoise0.kr(5).round(0.01).poll(trig: 1, label: "watchThis")}.scope // triggers poll once every second

From SC's reference:

WARNING: Printing values from the Server in intensive for the CPU. Poll should be used for debugging purposes.

Random numbers

rrand

rrand(0, 5) // generates a random number between 0 and 5 (inclusive)

rand

rand(10) // generates a random integer number between 0 and 10 (10 not included)
rand(10.0) // generates a random decimal number between 0.0 and 10.0 (10.0 not included)
10.0.rand // same as above
10.0.rand.round(0.01) // same as above with rounding
exprand(1, 10.0) // generates a random decimal number between 0.0 and 10.0, mostly lower values

Note the difference between these two:

dup(rand(100), 5) // picks a number, duplicates it
dup({rand(100)}, 5) // duplicates the function of picking a number

LFNoise0, LFNoise1, LFNoise2

Random values between -1 and +1 generated at a specified rate. Compare the three:

Arrays

Various array operations:

a = [10, 11, 12, 13, 14, 15, 16, 17]
a.reverse // reverse
a.scramble // scramble
a.choose // picks one element at random
a.size // returns size of array
a.at(0) // retrieves item at specified position
a[0] // same as above
a.wrapAt(9) // retrives item at specified position, wrapping around if > a.size
a ++ 999 // ++ (concatenate) adds something to the end of the array
a ++ \hi // a Symbol is a single character
a ++ 'hi' // same as above
a ++ "hi" // a String is a collection of characters
a.insert(5, "wow") // inserts "wow" at position 5, pushes other items forward
a // evaluate this and see that none of the above operations actually changed the original array
a.put(2, "oops") // put "oops" at index 2 (destructive; evaluate line above again to check)
a.add(44) // adds new element at the end of the array (permanently)
a.do({arg whatever, blech; [blech, whatever].postln}) // how to "do" an array
b = Array.series(5, 1); // create an array with 5 sequential numbers, starting at 1)
b.mirror // makes it a palindrome
b.permute(3) // permute: item in position 3 goes to position 0, and vice-versa
b.powerset // returns all possible combinations of the array's elements
Array.fill(10, "same"); // Another way of building an array
Array.fill(10, {arg counter; (counter + 1)*440});