Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix & document Filters #289

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 59 additions & 6 deletions wavelink/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from typing import TYPE_CHECKING, TypedDict

if TYPE_CHECKING:
from typing_extensions import Self, Unpack

Check warning on line 29 in wavelink/filters.py

View workflow job for this annotation

GitHub Actions / Type Coverage and Linting @ 3.x

Import "typing_extensions" could not be resolved from source (reportMissingModuleSource)

from .types.filters import ChannelMix as ChannelMixPayload
from .types.filters import Distortion as DistortionPayload
Expand Down Expand Up @@ -680,11 +680,38 @@
self._vibrato = filters.get("vibrato", Vibrato({}))
self._rotation = filters.get("rotation", Rotation({}))
self._distortion = filters.get("distortion", Distortion({}))
self._channel_mix = filters.get("channelMix", ChannelMix({}))
self._low_pass = filters.get("lowPass", LowPass({}))
self._channel_mix = filters.get("channel_mix", ChannelMix({}))
self._low_pass = filters.get("low_pass", LowPass({}))

def set_filters(self, **filters: Unpack[FiltersOptions]) -> None:
# TODO: document this later maybe?
"""Set multiple filters at once to a standalone Filter object.
To set the filters to the player directly see :meth:`wavelink.Player.set_filters`

Parameters
----------
volume: float
The Volume filter to apply to the player.
equalizer: :class:`wavelink.Equalizer`
The Equalizer filter to apply to the player.
karaoke: :class:`wavelink.Karaoke`
The Karaoke filter to apply to the player.
timescale: :class:`wavelink.Timescale`
The Timescale filter to apply to the player.
tremolo: :class:`wavelink.Tremolo`
The Tremolo filter to apply to the player.
vibrato: :class:`wavelink.Vibrato`
The Vibrato filter to apply to the player.
rotation: :class:`wavelink.Rotation`
The Rotation filter to apply to the player.
distortion: :class:`wavelink.Distortion`
The Distortion filter to apply to the player.
channel_mix: :class:`wavelink.ChannelMix`
The ChannelMix filter to apply to the player.
low_pass: :class:`wavelink.LowPass`
The LowPass filter to apply to the player.
reset: bool
Whether to reset all filters that were not specified.
"""

reset: bool = filters.get("reset", False)
if reset:
Expand All @@ -699,8 +726,8 @@
self._vibrato = filters.get("vibrato", self._vibrato)
self._rotation = filters.get("rotation", self._rotation)
self._distortion = filters.get("distortion", self._distortion)
self._channel_mix = filters.get("channelMix", self._channel_mix)
self._low_pass = filters.get("lowPass", self._low_pass)
self._channel_mix = filters.get("channel_mix", self._channel_mix)
self._low_pass = filters.get("low_pass", self._low_pass)

def _reset(self) -> None:
self._volume = None
Expand All @@ -723,7 +750,33 @@

@classmethod
def from_filters(cls, **filters: Unpack[FiltersOptions]) -> Self:
# TODO: document this later maybe?
"""Creates a Filters object with specified filters.

Parameters
----------
volume: float
The Volume filter to apply to the player.
equalizer: :class:`wavelink.Equalizer`
The Equalizer filter to apply to the player.
karaoke: :class:`wavelink.Karaoke`
The Karaoke filter to apply to the player.
timescale: :class:`wavelink.Timescale`
The Timescale filter to apply to the player.
tremolo: :class:`wavelink.Tremolo`
The Tremolo filter to apply to the player.
vibrato: :class:`wavelink.Vibrato`
The Vibrato filter to apply to the player.
rotation: :class:`wavelink.Rotation`
The Rotation filter to apply to the player.
distortion: :class:`wavelink.Distortion`
The Distortion filter to apply to the player.
channel_mix: :class:`wavelink.ChannelMix`
The ChannelMix filter to apply to the player.
low_pass: :class:`wavelink.LowPass`
The LowPass filter to apply to the player.
reset: bool
Whether to reset all filters that were not specified.
"""

self = cls()
self._set_with_reset(filters)
Expand Down
Loading