Skip to content

Commit 645cd51

Browse files
committed
Merge branch 'feat/audioop' of https://github.com/davidhozic/pycord into feat/audioop
2 parents 11bfdbc + d82d0d3 commit 645cd51

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

discord/player.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
import threading
3636
import time
3737
import traceback
38-
from math import floor
3938
from itertools import chain
39+
from math import floor
4040
from typing import IO, TYPE_CHECKING, Any, Callable, Generic, TypeVar
4141

4242
from .errors import ClientException
@@ -701,11 +701,25 @@ def read(self) -> bytes:
701701
minval = -0x8000
702702

703703
ret = self.original.read()
704-
samples = bytes(chain.from_iterable(
705-
int(floor(min(maxval, max(int.from_bytes(ret[i * 2: (i + 1) * 2], "little", signed=True) * min(self._volume, 2.0), minval))))
706-
.to_bytes(2, "little", signed=True)
707-
for i in range(len(ret) // 2)
708-
))
704+
samples = bytes(
705+
chain.from_iterable(
706+
int(
707+
floor(
708+
min(
709+
maxval,
710+
max(
711+
int.from_bytes(
712+
ret[i * 2 : (i + 1) * 2], "little", signed=True
713+
)
714+
* min(self._volume, 2.0),
715+
minval,
716+
),
717+
)
718+
)
719+
).to_bytes(2, "little", signed=True)
720+
for i in range(len(ret) // 2)
721+
)
722+
)
709723
return samples
710724

711725

0 commit comments

Comments
 (0)