Consider changing the if block in the frequency shift method (Program 86) to sourceIndex = sourceIndex - s.getLength(). What’s the dif- ference from just setting the sourceIndex to 0? This change will also reset the sourceIndex for wrapping back to the front of the sound. Is this better or worse?

What will be an ideal response?

It is an extra operation so it would be a bit slower than just reseting to 0. But, it can give better results. Why? When the factor is greater than zero you will run out of source before you fill up the target. You can wrap and take from the front again. But, depending on the length of the sound and the factor you may not want the very first value as the one to start with when you wrap. Assume you have a sound with just 11 values and you use a factor of 2. If you reset to 0 you will get values at indicies: 0, 2, 4, 6, 8, 10, 0, 2, 4, 6, and 8. If you use
sourceIndex = sourceIndex - s.getLength() you will get indicies: 0, 2, 4, 6, 8, 10, 1, 3, 5, 7, and 9.


Computer Science & Information Technology

You might also like to view...

The first option that appears with the Format as Table command is Table style selection

Indicate whether the statement is true or false.

Computer Science & Information Technology

One of the early criticisms of C++ was that it did not provide a comprehensive library of classes.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology