CSE 8A Chapter Notes - Chapter 10.3: The Delay

46 views3 pages

Document Summary

Create echoes by adding wave forms to the sound. Do this by adding more samples to a certain sample that is already into the sound make these samples fainter public void echo (int delay) Sound s = new sound(this. getfilename()); int value = 0; for (int i = delay; i < this. getlength(); i++) value = (int) (s. getsamplevalueat(i-delay) * 0. 6); this. setsamplevalueat(i, this. getsamplevalueat(i) +value); First, we make a copy of the sound. Then, we initialize a value variable of type int to 0. We then loop from the delay sample to then end of the sound: the delay sample is passed in from the parameter. We set the value to first get the sample at i-delay and then multiplying it by. We finally set the value at in the sound caller object to its current sample value + the value we got from the code above it. Higher delay numbers real echo public sound echo(int delay, int numechoes) int soundlength = this. getlength();

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents