Section 10.1. Composing Sounds Through Addition


[Page 312 (continued)]

10.1. Composing Sounds Through Addition

Creating sounds digitally that didn't exist previously is lots of fun. Rather than simply moving around samples or multiplying them, we actually change their valuesadd waves together. The result are sounds that never existed until you made them.

In physics, adding sounds involves issues of canceling waves out and enforcing other factors. In math, it's about matrices. In computer science, it's the easiest process in the world! Let's say that you've got a sound, source, that you want to add in to the current Sound object. Simply add the values at the same index numbers! That's it!


[Page 313]

// loop through all of the source for (int i = 0; i < source.getLength(); i++) {   // add source sound value and this sound value   value = this.getSampleValueAt(i) +           source.getSampleValueAt(i);   // set the value in this sound to the new value   this.setSampleValueAt(i,value); }




Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
ISBN: N/A
EAN: N/A
Year: 2007
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net