Difference between revisions of "CSC111 Sound Modification Exercises"
Line 2: | Line 2: | ||
---- | ---- | ||
<onlydft> | <onlydft> | ||
+ | =First we solve it in Pure Python with a List of integers= | ||
<source lang="python"> | <source lang="python"> | ||
# playing with an array of numbers | # playing with an array of numbers | ||
Line 67: | Line 68: | ||
+ | </source> | ||
+ | =Then we apply the Algorithm to JES= | ||
+ | <source lang="python"> | ||
+ | file = pickAFile() | ||
+ | sound = makeSound( file ) | ||
+ | blockingPlay( sound ) | ||
+ | |||
+ | startClear = 10561 | ||
+ | noSamples = getLength( sound ) | ||
+ | |||
+ | for i in range( startClear, noSamples ): | ||
+ | setSampleValueAt( sound, i, 0 ) | ||
+ | |||
+ | blockingPlay( sound ) | ||
+ | |||
+ | lenSeq = 10502 | ||
+ | startRepeat = 4071 | ||
+ | for i in range( lenSeq-1, -1, -1 ): | ||
+ | j = i + startRepeat | ||
+ | valueRight = getSampleValueAt( sound, j ) | ||
+ | valueLeft = getSampleValueAt( sound, i ) | ||
+ | setSampleValueAt( sound, j, valueRight + valueLeft/3 ) | ||
+ | |||
+ | blockingPlay( sound ) | ||
+ | |||
</source> | </source> | ||
</onlydft> | </onlydft> |