rec8 - CS 177 Week 8 Recitation Slides JES Sound functions...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS 177 Week 8 Recitation Slides JES Sound functions and Modifying Sounds Increasing/Decreasing Volume Maximizing (Normalizing) Splicing Reversing Mirroring
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 ANY QUESTIONS?
Background image of page 2
Let’s remember Sound We store sounds as array of integer values Each value is stored as 16 bits The range is from –2 (16-1) to +2 (16-1) – 1 i.e from – 32768 to 32767 3 59 28 -123 0 -32768 20456 32767 0 1 2 3 4 5 6 The length of this sound is 7
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
JES Functions about Sound pickAFile() Let the user pick a sound file (.wav file) makeSound(file) Takes a filename as input, reads the file, and creates a sound from it. Returns the sound. play(sound) Plays a sound provided as input. No return value. getLength(sound) Takes a sound as input and returns the number of samples in that sound. getSamplingRate(sound) Takes a sound as input and returns the number representing the number of samples in each second for the sound. getSamples(sound) Takes a sound as input and returns the Samples in that sound. writeSoundTo(sound, path) Takes a sound and a filename (a string) and writes the sound to that file as a WAV file. (Make sure that the filename ends in '.wav' if you want the operating system to treat it right.)
Background image of page 4
5 JES Functions about Sound getSampleValueAt(sound, index) Takes a sound and an index (an integer value), and returns the value of the sample (between -32768 and 32767) for that object. setSampleValueAt(sound, index, value) Takes a sound, an index, and a value (should be between -32768 and 32767), and sets the value of the sample at the given index in the given sound to the given value. getSampleObjectAt(sound, index) Takes a sound and an index (an integer value), and returns the Sample object at that index. getSampleValue(sample) getSample (sample) Takes a Sample object and returns its value (between -32768 and 32767). setSampleValue(sample, value) setSample (sample, value) Takes a Sample object and a value (should be between -32768 and 32767), and sets the sample to that value.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/22/2012 for the course CS 177 taught by Professor Staff during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 21

rec8 - CS 177 Week 8 Recitation Slides JES Sound functions...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online