// welcome to SuperCollider... the '//' at the beginning of this line means this is a comment


/*

You can also make block comments (forward-slash-star) and everything will be ignored by SuperCollider until the matching (star-forward-slash) is found. You will see MANY comments in your class code to guide you through the learning of the programming language. Also - notice they colorize red. Colorized text makes things easier to deal with. If this current text is NOT red, simply type apple-' ... there... better?

*/


// now - just a quick example so you can make some sound!


/* Single letter, lower-case letters are the ONLY variables that do not need to be declared. You can think of them as global variables (or, the variables that already exist in your programming environment). I STRONGLY suggest you avoid these in your programs. However, for short tests, they are very handy. You can assign values to a variable with the '=' sign. Objects in SuperCollider begin with an Uppercase letter, and colorize blue. The Server object is the first object you will come across. The below statement does two things. First it assigns the value on the right to the variable on the left. Second, the statement on the right tells the Server object to find the 'internal' Server by sending it the message 'internal'. The '.' is often referred to as the messenger. Each statement of code ends with a semi-colon. Place your cursor on the line of code below, and press 'enter' (not 'return'. On some laptops or computers, you may need to press fn-return to access the 'enter' functionality.

*/


s = Server.internal;

 

/* 

In the 'post' window, you should have seen the word:


internal

appear when you evaluated the line of code above.


The above can be put as follows into plain English: Tell the Server object to access the 'internal' server, and assign this instance of the Server to the variable 's'.


You can have many Server's in SuperCollider. In fact, on multi-processer machines, you can create a server for each processer, increasing the amount of synthesis power you can take advantage of. Each Server you create is called an 'instance' of the class Server. There are two special servers created for you by default. The 'internal' Server and the 'localhost' server. The internal Server lets us do some things that others can't... we'll explain the differences later, but for now, that will be the server you use. You will notice below that the internal server window says 'inactive'... so, let's send that server a message. The 'boot' message will start it for us.

*/


s.boot;


/*

You should see some information about your sound system print in the post window, and the internal server window should now say 'running' in green. A typical posted response to the boot command will look like this:


booting 57110

localhost

Number of Devices: 5

  0 : "Built-in Microphone"

  1 : "Built-in Input"

  2 : "Built-in Output"

  3 : "Built-in Audio"

  4 : "AggFire"

"Built-in Microphone" Input Device

  Streams: 1

      0  channels 2

"Built-in Output" Output Device

  Streams: 1

      0  channels 2

SC_AudioDriver: sample rate = 44100.000000, driver's block size = 512

SuperCollider 3 server ready..

notification is on



One advantage of the 'internal' server is its ability to display the sound it is creating through the use of a sound scope. If the server is running, you can send the 'scope' message to the Server object, and a window will display with a stereo waveform.

*/


s.scope;


/*

Evaluate the code below. { } indicate functions (kind of like a small program), and what the line below does is creates a function to play a sine tone. The frequency will be set at 330 Hz, has a starting phase of 0 (so, it starts with a sine wave with a value of 0, increasing in value) with an amplitude of 0.2. On the function, we will send the .play message. The .play message takes an argument that lets you tell SuperCollider which Server to play the function on. This is passed into the play 'method' through the use of parenthesis. We will assign the result of this function to the global variable 'a' so we can stop it later.


BUT - before we make any sound, one important thing to know is that SuperCollider has a panic button of sorts... a way to kill sound in case something goes terribly wrong. This is apple-. You shouldn't need it right now... but you should know about it!

*/


a = {SinOsc.ar(430, 0, 0.2)}.play(s);


/*

You should see the sin wave in the scope, and hear it in the left speaker. Now, let's tell 'a' to stop by sending it the 'free' message

*/


a.free;


/* 

Now - to gain a little more familiarity with the SuperCollider environment, you should access and read some of its online help. To access the main help system, type apple-d (for 'd'ocumentation).


You should see a window that says SuperCollider Help. You can also access helpfiles for specific objects. For instance, if you want help with SinOsc, you can highlight the object SinOsc (with a double click), and again press apple-d. 


Feel free to explore the underlined links from the main help. BUT - for Tuesday you need to look at the first four topics under 'Getting Help'. You do not need to understand everything yet, but it will be good if you have a general idea of how the environment works.


If you want to start exploring some of the sounds and techniques you will be learning this year, I would also suggest the 'Tour of Unit Generators' helpfile under Tutorials. There are many single line commands you can look at. Use apple-. to stop the sound after each example.


In addition to the four helpfiles above, you should also read the first three chapters in the Dodge book for Tuesday. Bring questions to class... if you have none, I will assume that you understood the concepts in the reading. You do NOT need to have a deep understanding of everything in this part of the text yet (the math, how operating systems work, etc.... this is just a good beginning overview to what we will be concerned with over the next year!


Have fun!

*/