Skip to content

Instantly share code, notes, and snippets.

@tremby
Created November 15, 2012 02:02
Show Gist options
  • Save tremby/4076178 to your computer and use it in GitHub Desktop.
Save tremby/4076178 to your computer and use it in GitHub Desktop.
# fadefactor is a short method which returns a float based on the one passed in
# audio is a bytearray
for i in range(fadeinframes):
offset = i * framesize
frame = str(audio[offset:offset + framesize])
value = struct.unpack(frameformat, frame)
audio[offset:offset + framesize] = struct.pack(frameformat,
*(fadefactor(float(i) / fadeinframes) * v for v in value))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment