Creative Commons Attribution Non-Commercial Share Alike License

  • Upload
    mahsa

  • View
    29

  • Download
    1

Embed Size (px)

DESCRIPTION

Creative Commons Attribution Non-Commercial Share Alike License. http://creativecommons.org/licenses/by-nc-sa/3.0/ Original Developer: Beth Simon, 2009 [email protected]. CSE8A Lecture 19 (18 was midterm). Read next class: read up to page 287 Freshman seminar: - PowerPoint PPT Presentation

Citation preview

  • Creative Commons Attribution Non-Commercial Share Alike Licensehttp://creativecommons.org/licenses/by-nc-sa/3.0/Original Developer: Beth Simon, 2009 [email protected]

  • CSE8A Lecture 19 (18 was midterm)Read next class: read up to page 287Freshman seminar:Peer Instruction: Exploring a Revolution in College Science TeachingFind out more about the theory behind clicker useAnalyze data from this and previous classes!CSE 8A Art Show! Sat Nov 14 10:30-12 noonSubmit either your collage or chromakey (one per pair)Art show open to all UCSD students JSOE High School Outreach Day -- >110 high schoolers (and their parents)We want MORE, GREAT people in CSE at UCSD!

  • Question 9: Did you read the part in red?YesNoNo, I was too pressed for timeI dont recall

    9. (3pts) Consider six variables, declared as follows: int a, b, c; int i, j, k; The purpose of the following three lines of code is to swap the values in variables a and b: c = a; a = b; b = c; In one sentence, written in the box below, state the purpose of the following three lines of code: // THERE WAS THREE LINES OF // CODE // HERE

  • Feedback from midterm surveyI was a bit surprised by the cross problem but it was a good way to test understanding of a concept in a way that we hadn't looked at a million times before.Was a good exam, I was a little freaked out after looking at the review midterms you posted online but this one seemed to be a lot easier.The group exam helped me see other ways to write code on the flowerI liked how it was a reflection of most of the problems we seen in class and not something surprising.too easyI liked the second question on the exam that had us explain how we reasoned out our solution. I think that will be very beneficial to improving our class.

  • Some good advice from your peersI feel that I could've received a much better grade on the midterm, had I studied actual code more.It had some tricky problems that really made me think.I like how most of the questions were similar to the clicker questions that we did during lecture.

  • Things Ill fix from your helpMake it clear that input is in black and whiteGroup part shorterMore space for code (it was a hint, but OK)More explanation on code writing questionFYIThere is partial credit on MCQTime is always tough

  • Be proud of yourself!I felt like skipping when I got out of the classroom because I was so happy. Studying was definitely worth it.

  • By the end of todays class you should be able toLG37: Identify, compare and contrast if-else if else statements and separate if statement blocks.LG38: Explain the relationship between amplitude, frequency, compression and rarefaction as it describes sound.LG39: Defend a choice of sampling rate and sample size for a digital sound file based on human hearing abilities and translate that into an estimate of the size of a sampling array for storing sound.LG40: Compare an array of Pixels which forms a Picture to an Array of SoundSamples which forms a Sound including the result of indexing into each.LG41: Read, trace, and write code to change the volume of a Sound object (using for each, while and for loops)

  • Advice: How to use if statementsFigure out what you want to doSketch out on paper your scenario.Are your conditions for change mutually exclusive (only one can happen?)If so, use an if, else if, (and maybe an else)Does something ALWAYS get done? Use an else.If more than one thing gets done then probably this is in a separate if statementConditional change not related to each other should be in separate (multiple) if statements.

  • Lab (Quiz) Review: Write if statement to make sure we have no index out of bounds errorsfor (int x = 0; x < this.getWidth(); x++) { for (int y = 0; y < this.getHeight(); y++) { int foo = this.getPixel(x-3, y-2).getRed() + this.getPixel(x+2,y+3).getRed(); }}

    if ( (x < this.getWidth() + 2) && (x >= -3) && (y < this.getHeigth() + 3) && (y >= -2) ) if ( (x < this.getWidth() - 2) && (x >= 3) && (y < this.getHeight() - 3) && (y >= 2) ) if ( (x+2 < this.getWidth() ) && (x-3 >= 0) && (y+3 < this.getHeight() ) && (y-2 >= 0) ) if ( (x+2 0) && (y+3 0) )

  • Lab (Quiz) Review: Write if statement to make sure we have no index out of bounds errorsfor (int x = 0; x < this.getWidth(); x++) { for (int y = 0; y < this.getHeight(); y++) { int foo = this.getPixel(x-3, y-2).getRed() + this.getPixel(x+2,y+3).getRed(); }}

  • Which of these statements best characterizes sepia?All Color components are changed, based on that same components original value (red changed based on red, blue changed based on blue, green changed based on green)All Color components are changed, based on one components original value (just use one component to make decision)Some (not all) Color components are changed, based on their original valueSome (not all) Color components are changed based on reds original component valueNone of these are true!IsomorphicDont show results until after next one

  • Which of these statements best characterizes posterize?All Color components are changed, based on that same components original value (red changed based on red, blue changed based on blue, green changed based on green)All Color components are changed, based on one components original value (just use one component to make decision)Some (not all) Color components are changed, based on their original valueSome (not all) Color components are changed based on reds original component valueNone of these are true!

  • Chapter 8: Sound!

  • If the following sound were modified to be louder it wouldHave shorter frequency and stronger compressions/rarefactionsHave smaller amplitude and stronger compressions/rarefactionsHave higher frequency and stronger compressions/rarefactionsHave larger amplitude and stronger compressions/rarefactionsNone of the above

  • If higher pitch?Show web site: compression rarefaction explanation

  • Sample Rate versus Sample SizeSize is max (and min) amplitude

    Rate is how often we record an amplitude

  • Beth makes bad music: Whats wrong with these decisions?Discuss: (3 min)Ive decided that I dont like the sampling rate and sample size provided by the book authors. Comment on my decision to use

    Sampling RateSample SizeExplanation5,000Hz4 bits100,000Hz32 bits

  • Match the Java type to the (simplified) diagramThis is something you look atThis is something you listen toPicture Sound Pixel SoundSample Pixel[] SoundSample[]There are a few details hiding here like Picture has a few more things in it.. Later

  • Our Representation of SoundString fileName = FileChooser.pickAFile();Sound noise = new Sound(fileName);SoundSample[] noiseArray = noise.getSamples();noiseArray[3].setValue(0);int foo = noiseArray[2].getValue();

    String fileName = FileChooser.pickAFile();Picture pic = new Picture(fileName);Pixel[] pixArray = pic.getPixels();pixArray[3].setBlue(255);int foo = pixArray[2].getRed();

    *