This is my fade_out
function.
def fade_out (snd, fade_length):
new_snd = sound.copy(snd)
factor = 1.0/fade_length
fade_o = 1
for sample in new_snd:
sound.set_left(sample, int(sound.get_left(sample)*fade_o))
sound.set_right(sample, int(sound.get_right(sample)*fade_o))
if fade_o > 0:
fade_o = fade_o - factor
return new_snd
The first problem I have is with this part:
if fade_o > 0:
fade_o = fade_o - factor
I don't understand why face_o
is only subtracted from once. I thought fade_o
would continue to be subtracted from until it reaches 0.
The second problem I have is that I don't know how to make the fade-out start on the time I want. For example, if the sound length is 600 000 and the fade length is 100 000, I want to start fade out at an offset of 500 000 (which is 600 000 - 100 000
). I am not sure how t开发者_运维知识库o do this.
I thought of something along these lines:
for sample in new_snd:
if sound.get_index(sample) > (len(snd)-fade_length):
sound.set_left(sample,........)
But, this doesn't seem to be working.
精彩评论