Skip to content

Commit

Permalink
Merge branch 'master' into app_emojis
Browse files Browse the repository at this point in the history
Signed-off-by: UK <[email protected]>
  • Loading branch information
NeloBlivion authored Oct 17, 2024
2 parents 7872075 + 33adf22 commit 2930699
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ These changes are available on the `master` branch, but have not yet been releas
([#2521](https://github.com/Pycord-Development/pycord/pull/2521))
- `Emoji` has been renamed to `GuildEmoji`.
([#2501](https://github.com/Pycord-Development/pycord/pull/2501))
- Replaced audioop (deprecated module) implementation of `PCMVolumeTransformer.read`
method with a pure Python equivalent.
([#2176](https://github.com/Pycord-Development/pycord/pull/2176))

### Deprecated

Expand Down
14 changes: 12 additions & 2 deletions discord/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

from __future__ import annotations

import array
import asyncio
import audioop
import io
import json
import logging
Expand All @@ -37,6 +37,7 @@
import threading
import time
import traceback
from math import floor
from typing import IO, TYPE_CHECKING, Any, Callable, Generic, TypeVar

from .errors import ClientException
Expand Down Expand Up @@ -704,8 +705,17 @@ def cleanup(self) -> None:
self.original.cleanup()

def read(self) -> bytes:
maxval = 0x7FFF
minval = -0x8000

volume = min(self._volume, 2.0)
ret = self.original.read()
return audioop.mul(ret, 2, min(self._volume, 2.0))
samples = array.array("h")
samples.frombytes(ret)
for i in range(len(samples)):
samples[i] = int(floor(min(maxval, max(samples[i] * volume, minval))))

return samples.tobytes()


class AudioPlayer(threading.Thread):
Expand Down

0 comments on commit 2930699

Please sign in to comment.