Fading the start of a sound with Python
I'm a student in a programming class and I just can't get this fading in开发者_如何学运维 to work... Right now it's just muting the first few samples of length fade_length... can anyone tell me why it does so so I can find out a way to fix it?
<code erased>
Help without direct answers would be great. Thank you
If you're using Python 2.x, try
factor = 1.0 * index / fade_length
An int
divided by a larger int
is 0. You have to coerce the operation to floating point division.
Edit:
You can also use from __future__ import division
to make the division operator use true division like Python 3. Use '//' for floor division.
精彩评论