Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
fix(audio): Fadein not working properly for mono.
Browse files Browse the repository at this point in the history
  • Loading branch information
TerryGeng committed Dec 13, 2021
1 parent 02abdd6 commit c624c32
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mumbleBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,11 @@ def _fadeout(self, _pcm_data, stereo=False, fadein=False):
pcm_data[4 * i + 2:4 * i + 4] = struct.pack("<h", round(
struct.unpack("<h", pcm_data[4 * i + 2:4 * i + 4])[0] * mask[i]))
else:
mask = [math.exp(-x / 60) for x in range(0, int(len(pcm_data) / 2))]
if not fadein:
mask = [math.exp(-x / 60) for x in range(0, int(len(pcm_data) / 2))]
else:
mask = [math.exp(-x / 60) for x in reversed(range(0, int(len(pcm_data) / 2)))]

for i in range(int(len(pcm_data) / 2)):
pcm_data[2 * i:2 * i + 2] = struct.pack("<h",
round(struct.unpack("<h", pcm_data[2 * i:2 * i + 2])[0] * mask[i]))
Expand Down

0 comments on commit c624c32

Please sign in to comment.