Week 7 - Friday.  What did we talk about last time?  Array examples  Sound.

Slides:



Advertisements
Similar presentations
Georgia Institute of Technology Introduction to Processing Digital Sounds.
Advertisements

Week 8 - Monday.  What did we talk about last time?  StdAudio.
Week 7: Input and Output 1.  Now we are going to talk a little bit about output  You have a lot of experience with System.out.println() and System.out.print()
Investigating the sound quality of different audio file formats In this activity, we are going to record a short voice sample with a sound recording tool,
Part A Multimedia Production Rico Yu. Part A Multimedia Production Ch.1 Text Ch.2 Graphics Ch.3 Sound Ch.4 Animations Ch.5 Video.
Week 7 - Friday.  What did we talk about last time?  Array examples.
Week 11 - Friday.  What did we talk about last time?  Object methods  Accessors  Mutators  Constructors  Defining classes.
Selection Statements & Exam 1 Review Recitation – 2/13/2009 CS 180 Department of Computer Science, Purdue University.
Week 6: Arrays 1.  Loops are great  But, without a way to talk about a group of values, we can’t get the full potential out of a loop  Enter: the array.
Where I am saving it Double click on the folder that says “My Music” so that it shows in the Save In box. Double click on the folder “Sound bites”
1 CS 177 Week 15 Recitation Slides Review. Announcements Final Exam on Sat. May 8th  PHY 112 from 8-10 AM Complete your online review of your classes.
CS 106 Introduction to Computer Science I 11 / 08 / 2006 Instructor: Michael Eckmann.
AP Computer Science.  Not necessary but good programming practice in Java  When you override a super class method notation.
Week 8: Audio Processing 1.  Light and sound are both transmitted in waves 2.
Chapter 9 Audio.
CSE 1301 J Lecture 13 Sorting Richard Gesick. CSE 1301 J 2 of 30 Sorting an Array When an array's elements are in random order, our Sequential Search.
Free Sound Recorder By FreeAudioVideoSoft. Pricing & Installation Software is absolutely FREE With agreement to terms and conditions Installation Requirements:
1 Announcements l Take textbook to lab. »Be sure to read Chapter 13 before lab –MATLAB tutorial –Can skip Section 13.4 l Bring your transmitter and receiver.
Week 7 - Wednesday.  What did we talk about last time?  Introduction to arrays  Lab 6.
Problem Solving with Data Structures using Java: A Multimedia Approach Chapter 5: Arrays: A Static Data Structure for Sounds.
Audio. Why Audio Essential tool for – Interface – Narrative – Setting & Mood.
Week 2 - Monday.  What did we talk about last time?  Exceptions  Threads  OOP  Interfaces.
Chapter 17 Pointers and Arrays. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Pointers and Arrays.
Chapter 10 Strings, Searches, Sorts, and Modifications Midterm Review By Ben Razon AP Computer Science Period 3.
11 Adding Sounds Session 7.1. Session Overview  Find out how to capture and manipulate sound on a Windows PC  Show how sound is managed as an item of.
XNA Basic XACT tool. What’s format song file which XNA support? Only.wav because it’s not compress file. Beside, you need XACT project ( XACT project)
HTML Use of Multimedia on web page. HTML Media Q. How to call Image file in our web page ? A. That is the easy syntax for defining an image. 2.
Searching and Sorting, Template Functions, and Vectors ITK 169 Fall 2003.
CompSci Today’s topics Java Review Just a bunch of headings meant to trigger questions A contraction of previous notes Upcoming Midterm Exam Reading.
Computer Programming 12 Mr. Jean April 24, The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
ITEC Final Presentation For Fall 2011 Table of Content –Basic Requirements  Audacity  Inskcape  GIMP  Blender  Animation of 2D and 3D.
C Programming in Linux Jacob Chan. C/C++ and Java  Portable  Code written in one system and works in another  But in C, there are some libraries that.
Introduction to Digital Media. What is it? Digital media is what computers use to; Store, transmit, receive and manipulate data Raw data are numbers,
Scope When we create variables and functions, they are limited in where they are visible and where they can be referenced For the most part, the identifiers.
***** SWTJC STEM ***** Chapter 7 cg 50 Arrays as Parameters Regular variables are passed to a method by value; i.e., the variable value is copied to a.
Week 13 - Friday.  What did we talk about last time?  Sorting  Insertion sort  Merge sort  Started quicksort.
C Programming Lecture 16 Pointers. Pointers b A pointer is simply a variable that, like other variables, provides a name for a location (address) in memory.
Heads-Up – Programming Quiz This Week Announcement will be made via You will be provided with a login to the password-protected website You will.
Week 13 - Wednesday.  What did we talk about last time?  Color representation  Color class  Picture class.
Week 11 - Friday.  What did we talk about last time?  Object methods  Accessors  Mutators  Constructors  Defining classes.
Author Ivan Dominic Baguio. ABOUT THE GAME Game Objective  The goal of each player in the game is to discard all cards in his hand before every other.
Copyright © 2000, Department of Systems and Computer Engineering, Carleton University 1 Introduction An array is a collection of identical boxes.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 Insertion sort [ ] i=1 j=1 i=2 j=2 insert i=3 at j=1 [ ] i=3 j=1 insert i=4 at j=0 [
1 BUILDING JAVA PROGRAMS CHAPTER 7.2 ARRAY TRAVERSAL ALGORITHMS.
CS 31 Discussion, Week 5 Faisal Alquaddoomi, Office Hours: BH 2432, MW 4:30-6:30pm, F 12:00-1:00pm (today)
Week 12 - Wednesday.  What did we talk about last time?  Hunters and prey.
Week 7 - Wednesday.  What did we talk about last time?  Introduction to arrays  Lab 6.
Week 10 - Friday.  What did we talk about last time?  References and primitive types  Started review.
Sorting and Shuffling Arrays CS 233G Intermediate C++ Programming for Games.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 9 Structures and Sequential Access Files.
Week 6 - Friday.  What did we talk about last time?  Loop examples.
Chapter 16 Pointers and Arrays Pointers and Arrays We've seen examples of both of these in our LC-3 programs; now we'll see them in C. Pointer Address.
CS 31 Discussion, Week 7 Faisal Alquaddoomi, Office Hours: BH 2432, W 4:30-6:30pm, F 12:30-1:30pm.
CompSci 4 Chap 10 November 4, 2010 Prof. Susan Rodger.
Arrays and Sorting. Process Open a file that contains integers, one per line. Read each line, convert to short and store each into an array Sort the array.
Arrays. What is an array? An array is a collection of data types. For example, what if I wanted to 10 different integers? int num1; int num2; int num3;
Week 7 - Friday CS 121.
Week 7 - Wednesday CS 121.
Week 15 – Wednesday CS 121.
CS 177 Week 15 Recitation Slides
Week 9 – Audio Processing
2 code samples int [] array; int i, j, temp; for(i = 0; i < array.length/2; i++) { j = array.length-1-i; temp = array[i]; array[i] = array[j]; array[j]
I Can’t Hear You! Sound Get out your notes.
I Can’t Hear You! Sound Get out your notes.
Chapter 9 Audio.
Week 7 - Monday CS 121.
Presentation transcript:

Week 7 - Friday

 What did we talk about last time?  Array examples  Sound

 We can represent a deck of cards as an array of 52 items  One easy way is to make each item a String giving the name of the card  We can extend last time's lab and store each of these names in an array

 Swapping the values of two variables is a fundamental operation in programming  It is going to become more important in arrays because now the order of variables has become important  The simplest way to swap two variables involves using a third variable as a temporary location

 Here is an example of swapping two String s indexed i and j in an array of String s called array int i = in.nextInt(); int j = in.nextInt(); String temp = array[i]; array[i] = array[j]; array[j] = temp; int i = in.nextInt(); int j = in.nextInt(); String temp = array[i]; array[i] = array[j]; array[j] = temp;

 Using the swap code, we can do a random shuffling of a deck  To do so, we go through each element of the array, and randomly swap it with any of the later elements for( int i = 0; i < n; i++ ) { exchange = i + (int)(Math.random() * (n - i)); temp = deck[i]; deck[i] = deck[exchange]; deck[exchange] = temp; } for( int i = 0; i < n; i++ ) { exchange = i + (int)(Math.random() * (n - i)); temp = deck[i]; deck[i] = deck[exchange]; deck[exchange] = temp; }

 Audio data on Windows machines is sometimes stored in a WAV file  A WAV file is much simpler than an MP3 because it has no compression  Even so, it contains two channels (for stereo) and can have many different sample rates and formats for recording sound  The StdAudio class lets you read and write a WAV file easily and always deal with a single array of sound, sampled at 44,100 Hz

 Everything you’d want to do with sound:  To do interesting things, you have to manipulate the array of samples  Make sure you added StdAudio.java to your project before trying to use it MethodUse double[] read(String file) Read a WAV file into an array of double s void save(String file, double[] input) Save an array of double s (samples) into a WAV file void play(String file) Play a WAV file void play(double[] input) Play an array of double s (samples)

 Let’s load a file into an array:  If the song has these samples:  Perhaps samples will contain: String file = "song.wav"; double[] samples = StdAudio.read(file); String file = "song.wav"; double[] samples = StdAudio.read(file);

 With the audio samples loaded into the array named samples, we can play them as follows: StdAudio.play(samples);

 Or, we could generate sound from scratch with StdAudio  This example from the book creates 1 second of the pitch A440: double[] sound = new double[StdAudio.SAMPLE_RATE + 1]; for( int i = 0; i < sound.length; i++ ) sound[i] = Math.sin(2 * Math.PI * i * 440 / StdAudio.SAMPLE_RATE); StdAudio.play(sound); double[] sound = new double[StdAudio.SAMPLE_RATE + 1]; for( int i = 0; i < sound.length; i++ ) sound[i] = Math.sin(2 * Math.PI * i * 440 / StdAudio.SAMPLE_RATE); StdAudio.play(sound);

 What if we wanted to play the second half of a sound followed by the first half?  I know, why would we want to do that? double[] samples = StdAudio.read(file); double[] switched = new double[samples.length]; for(int i = 0; i < samples.length/2; i++ ) switched[i + samples.length/2] = samples[i]; for(int i = samples.length/2; i < samples.length; i++ ) switched[i - samples.length/2] = samples[i]; StdAudio.play(switched); double[] samples = StdAudio.read(file); double[] switched = new double[samples.length]; for(int i = 0; i < samples.length/2; i++ ) switched[i + samples.length/2] = samples[i]; for(int i = samples.length/2; i < samples.length; i++ ) switched[i - samples.length/2] = samples[i]; StdAudio.play(switched);

 StdDraw

 Keep reading Chapter 6 of the textbook  Read Project 3 carefully and get started  It's a harder project than the previous two!  Office hours from 3:30-5pm canceled this today due to travel