Laptop Instrument Meeting 4 January 29, 2018.

Slides:



Advertisements
Similar presentations
1 C++ Syntax and Semantics The Development Process.
Advertisements

True or false A variable of type char can hold the value 301. ( F )
10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
Introduction to Primitives. Overview Today we will discuss: –The eight primitive types, especially int and double –Declaring the types of variables –Operations.
COMP 14 Introduction to Programming Miguel A. Otaduy May 18, 2004.
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
1 MATERI PENDUKUNG OPERATOR Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 30, 2005.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
C Programming n General Information on C n Data Types n Arithmetic Operators n Relational Operators n if, if-else, for, while by Kulapan Waranyuwat.
Arithmetic Operations. Review function statement input/output comment #include data type variable identifier constant declaration.
Principles of programming languages 5: An operational semantics of a small subset of C Department of Information Science and Engineering Isao Sasano.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Java Data Types Assignment and Simple Arithmetic.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
Chapter 2 Variables.
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Chapter 3 Using Variables, Constants, Formatting Mrs. UlshaferSept
Welcome to Computer Programming II! Computer Programming II Summer 2015.
Java Programming: Guided Learning with Early Objects Chapter 1 Basic Elements of Java.
Chapter 2 Variables.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Data Types and Expressions
Variables Mr. Crone.
BASIC ELEMENTS OF A COMPUTER PROGRAM
Lecture 4: Expressions and Variables
Building Java Programs
Computing Fundamentals
Revision Lecture
Multiple variables can be created in one declaration
Primitive Data, Variables, Loops (Maybe)
Java Programming: From Problem Analysis to Program Design, 4e
Building Java Programs Chapter 2
Programming Funamental slides
Chapter 2: Basic Elements of Java
A First Book of ANSI C Fourth Edition
Numbers.
Variables Numbers can be stored and retrieved while a program is running if they are given a home. The way that integers and decimal numbers are stored.
Building Java Programs
Laptop Instrument Meeting 7 February 7, 2018.
Chapter 2 Variables.
Building Java Programs
Variables variable: A piece of the computer's memory that is given a name and type, and can store a value. Like preset stations on a car stereo, or cell.
Building Java Programs Chapter 2
Chapter 3 Operators and Expressions
Chapter 2: Introduction to C++.
Data Types and Expressions
Building Java Programs
Building Java Programs
Lecture 4: Expressions and Variables
Building Java Programs
Introduction to Primitives
Introduction to Primitives
Building Java Programs
Primitive Types and Expressions
Unit 3: Variables in Java
Building Java Programs Chapter 2
Chapter 2 Variables.
Building Java Programs
Building Java Programs
Variables and Constants
Data Types and Expressions
Data Types and Expressions
Presentation transcript:

Laptop Instrument Meeting 4 January 29, 2018

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; }

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; }

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

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

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

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

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

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;

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;

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

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

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

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

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

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

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.