Question: Consider changing the if block in the frequency shift recipe (Program 119 (page 264)) to sourceIndex = sourceIndex - getLength(source). Whats the difference from just
Consider changing the if block in the frequency shift recipe (Program 119 (page 264)) to sourceIndex = sourceIndex - getLength(source). What’s the difference from just setting the sourceIndex to 0? Is this better or worse? Why?
Data from Program 119

def shift(source, factor): target = makeEmptySound (getLength(source)) sourceIndex = 0 for targetIndex in range (0, getLength(target)): sourceValue = getSampleValueAt(source, int(sourceIndex)) setSampleValueAt (target, targetIndex, sourceValue) sourceIndex = sourceIndex + factor if (sourceIndex >= getLength(source)): sourceIndex = 0 play(target) return target
Step by Step Solution
3.51 Rating (154 Votes )
There are 3 Steps involved in it
This is a very minimal difference As it was previously if the sourceIndex grew too large it wou... View full answer
Get step-by-step solutions from verified subject matter experts
