// this is a comment

39 + 3  // evaluate this by pressing [ENTER] (OSX) or [CTRL-RETURN] (Win)
// on macs without enter-key press [FN-RETURN]

// notation of math and other functions

sqrt(9)	// square root of 9, written in functional notation
9.sqrt	// square root of 9, written in receiver.message notation

3.squared
3.cubed

pow(2,4)	// 2 to the power of 4, in functional notation
2.pow(4)	// the same but in receiver.message notation
2 pow: 4	// the same but in binary operator notation
	
2 ** 4	// another way to notate exponentiation

1/3
3.reciprocal

1/0
inf.reciprocal

100.rand
rand(100)

rrand(3, 20)
3 rrand: 20
3.rrand(20)

[3,4,5,6,7,8,9,10,11,12]
Array.series(10, 3, 1)
(3 .. 12)
3.series(4,12)

Array.rand(10, 3, 20)
{ rrand(3, 20) } ! 10

// --> in SC3 the same functionality can be achieved very often in different ways of writing

// more complicated math to evaluate ...

(1 + 5.sqrt) / 2   // the Golden Mean

pi

sin(pi*0.5)		// no, this is not a sine tone!
(pi*0.5).sin		// just the math function ...

4 == 4		
4 == 5
4 < 7		
4 > 7

// ... even more complicated but "musical" math:

2.pow(1/12)		// a musical semitone interval in equal-tempered tuning

2 ** (1/2)		// an equal-tempered tritone 
	
7/5				// a "tritone" in the harmonic series

(3 ** 6) / (2 ** 9) // a tritone in Pythagorean tuning

3.pow(2) * 5.pow(1) * 2.pow(-5) // a tritone in just intonation

440 * 2.pow((60-69)/12)		// calculation of the frequency of the middle c
60.midicps				// the more comfortable way to do this in SC

log2(1000/440) * 12 + 69	// what pitch relates to a frequency of 1000 Hz ?
1000.cpsmidi				// the more comfortable way to do this in SC

(3/2).ratiomidi			// the number of semitones related to a perfect fifth
7.midiratio				// the ratio (as floating point number) related to an interval of 7 semitones
7.midiratio.asFraction		// find a near ratio of integers

((1 + 5.sqrt) / 2).ratiomidi // which is the musical interval of the Golden Mean ?
(pi/2).ratiomidi			 // which is the interval of Pi/2 ?

// the frequencies of a major scale on C (given in MIDI semitone numbers)
[60, 62, 64, 65, 67, 69, 71, 72].midicps

// ... more readable
[60, 62, 64, 65, 67, 69, 71, 72].midicps.round(0.01)

// when we write it like this it's easier to transpose
([0, 2, 4, 5, 7, 9, 11, 12] + 60).midicps.round(0.01)
([0, 2, 4, 5, 7, 9, 11, 12] + 62).midicps.round(0.01)

// ... and easier to change the scale
([0, 2, 3, 5, 7, 8, 10, 12] + 60).midicps.round(0.01)

// what are the MIDI note numbers of the first 8 harmonics on the middle c ?
(60.midicps * [1,2,3,4,5,6,7,8]).cpsmidi.round(0.01)

// ... the same in a simpler notation
(1 .. 8).ratiomidi.round(0.01) + 60