Presentation is loading. Please wait.

Presentation is loading. Please wait.

Laptop Instrument Meeting 4 January 29, 2018.

Similar presentations


Presentation on theme: "Laptop Instrument Meeting 4 January 29, 2018."— Presentation transcript:

1 Laptop Instrument Meeting 4 January 29, 2018

2 ChucK Program 1 // Plays random frequencies // Connect unit generator SinOsc s => dac; // Start loop while (true) { // Generate random frequency // and assign to s Std.rand2f(30.0,1000.0) => s.freq; // Play for 100 milliseconds 100::ms => now; }

3 ChucK Program 2 // Plays octaves // Connect unit generator SinOsc s => dac; // Set starting frequency as a real number 30.0 => float playfreq; // Start loop while (playfreq <= 10000) { // Set frequency playfreq => s.freq; // Play for 2 seconds 2::second => now; // Double frequency 2 *=> playfreq; }

4 Low Notes Double bass: E or C Tuba: D Contrabassoon: B flat

5 Low Notes: Pipe Organ Massey Memorial Organ: 5640 pipes
Chautauqua Institution, New York

6 What is a computer program?
A sequence of statements. Either Statements end with a terminator (for example, ;) Statements are separated with a separator Statements are executed in order. But There may be branches There may be loops

7 What might go wrong? A syntax error: when the rules of the language are not followed A semantic error: perfect syntax, but the wrong result due to Logic Typos

8 Variables and values Variable names: identifiers Value types
An identifier is a sequence of characters and digits, starting with a character. Capitalization counts. Variables are assigned values Value types int : integer (signed) float : real number (signed), a number with a decimal point time : internal to ChucK, sometimes called ChucKian dur : duration

9 Storing and Calculating
Before using a variable, it must be declared. This action sets aside a space of the proper shape to hold the value. Declaring: int foo; dur short; float some;

10 Storing and Calculating (2)
Once declared, a value of the correct type can be assigned (stored) in the space named by the variable. Assigning: value on left, location on right, => 2 => foo; 10::ms => short; Declaring and assigning together: 120.0 => float some;

11 Storing and Calculating (3)
Example 120.0 => float some; //declare and initialize some 120.0

12 Storing and Calculating (4)
Arithmetic 120.0 => float some; some => some; // increment some 220.0

13 Storing and Calculating (5)
Arithmetic 120.0 => float some; some => some; => some; //increment shorthand some 320.0

14 Storing and Calculating (6)
0 => int i; //declare and initialize

15 Storing and Calculating (7)
0 => int i; i++; // increment by 1 1

16 Peeking <<< i >>>; <<< “Answer:” , i >>>;

17 Exercise After each step, use the ChucK “print” statement to display the value of the answer. // Declare foo as an integer and store 3 // Increment foo by 5 // Increment foo by 1 // Multiply foo by 4 // Subtract 11 from foo // Divide foo by 7 Answer is 3. Integer divide.


Download ppt "Laptop Instrument Meeting 4 January 29, 2018."

Similar presentations


Ads by Google