add function to clear filters on all tracks
This commit is contained in:
parent
1e12d79d68
commit
e504088da1
|
|
@ -27,6 +27,7 @@ from .events import *
|
||||||
from .exceptions import *
|
from .exceptions import *
|
||||||
from .filters import *
|
from .filters import *
|
||||||
from .objects import *
|
from .objects import *
|
||||||
|
from .queue import *
|
||||||
from .player import Player
|
from .player import Player
|
||||||
from .pool import *
|
from .pool import *
|
||||||
from .queue import *
|
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,8 @@ class Equalizer(Filter):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def metal(cls):
|
def metal(cls):
|
||||||
"""Equalizer preset which increases the mids of a track,
|
"""Equalizer preset which increases the mids of a track,
|
||||||
preferably one of the metal genre, to make it sound
|
preferably one of the metal genre, to make it sound
|
||||||
more full and concert-like.
|
more full and concert-like.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ class Equalizer(Filter):
|
||||||
@classmethod
|
@classmethod
|
||||||
def piano(cls):
|
def piano(cls):
|
||||||
"""Equalizer preset which increases the mids and highs
|
"""Equalizer preset which increases the mids and highs
|
||||||
of a track, preferably a piano based one, to make it
|
of a track, preferably a piano based one, to make it
|
||||||
stand out.
|
stand out.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -110,11 +110,11 @@ class Timescale(Filter):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
tag: str,
|
tag: str,
|
||||||
speed: float = 1.0,
|
speed: float = 1.0,
|
||||||
pitch: float = 1.0,
|
pitch: float = 1.0,
|
||||||
rate: float = 1.0
|
rate: float = 1.0
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
@ -137,9 +137,9 @@ class Timescale(Filter):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def vaporwave(cls):
|
def vaporwave(cls):
|
||||||
"""Timescale preset which slows down the currently playing track,
|
"""Timescale preset which slows down the currently playing track,
|
||||||
giving it the effect of a half-speed record/casette playing.
|
giving it the effect of a half-speed record/casette playing.
|
||||||
|
|
||||||
This preset will assign the tag 'vaporwave'.
|
This preset will assign the tag 'vaporwave'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -149,11 +149,11 @@ class Timescale(Filter):
|
||||||
def nightcore(cls):
|
def nightcore(cls):
|
||||||
"""Timescale preset which speeds up the currently playing track,
|
"""Timescale preset which speeds up the currently playing track,
|
||||||
which matches up to nightcore, a genre of sped-up music
|
which matches up to nightcore, a genre of sped-up music
|
||||||
|
|
||||||
This preset will assign the tag 'nightcore'.
|
This preset will assign the tag 'nightcore'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return cls(tag="nightcore", speed=1.25, pitch=1.3)
|
return cls(tag="nightcore", speed=1.25, pitch=1.3)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Pomice.TimescaleFilter tag={self.tag} speed={self.speed} pitch={self.pitch} rate={self.rate}>"
|
return f"<Pomice.TimescaleFilter tag={self.tag} speed={self.speed} pitch={self.pitch} rate={self.rate}>"
|
||||||
|
|
@ -199,10 +199,10 @@ class Tremolo(Filter):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
tag: str,
|
tag: str,
|
||||||
frequency: float = 2.0,
|
frequency: float = 2.0,
|
||||||
depth: float = 0.5
|
depth: float = 0.5
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
@ -231,10 +231,10 @@ class Vibrato(Filter):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
tag: str,
|
tag: str,
|
||||||
frequency: float = 2.0,
|
frequency: float = 2.0,
|
||||||
depth: float = 0.5
|
depth: float = 0.5
|
||||||
):
|
):
|
||||||
|
|
||||||
|
|
@ -252,7 +252,7 @@ class Vibrato(Filter):
|
||||||
|
|
||||||
self.payload = {"vibrato": {"frequency": self.frequency,
|
self.payload = {"vibrato": {"frequency": self.frequency,
|
||||||
"depth": self.depth}}
|
"depth": self.depth}}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Pomice.VibratoFilter tag={self.tag} frequency={self.frequency} depth={self.depth}>"
|
return f"<Pomice.VibratoFilter tag={self.tag} frequency={self.frequency} depth={self.depth}>"
|
||||||
|
|
||||||
|
|
@ -308,22 +308,22 @@ class ChannelMix(Filter):
|
||||||
self.right_to_right = right_to_right
|
self.right_to_right = right_to_right
|
||||||
self.tag = tag
|
self.tag = tag
|
||||||
|
|
||||||
self.payload = {"channelMix": {"leftToLeft": self.left_to_left,
|
self.payload = {"channelMix": {"leftToLeft": self.left_to_left,
|
||||||
"leftToRight": self.left_to_right,
|
"leftToRight": self.left_to_right,
|
||||||
"rightToLeft": self.right_to_left,
|
"rightToLeft": self.right_to_left,
|
||||||
"rightToRight": self.right_to_right}
|
"rightToRight": self.right_to_right}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return (
|
return (
|
||||||
f"<Pomice.ChannelMix tag={self.tag} left_to_left={self.left_to_left} left_to_right={self.left_to_right} "
|
f"<Pomice.ChannelMix tag={self.tag} left_to_left={self.left_to_left} left_to_right={self.left_to_right} "
|
||||||
f"right_to_left={self.right_to_left} right_to_right={self.right_to_right}>"
|
f"right_to_left={self.right_to_left} right_to_right={self.right_to_right}>"
|
||||||
)
|
)
|
||||||
|
|
||||||
class Distortion(Filter):
|
class Distortion(Filter):
|
||||||
"""Filter which generates a distortion effect. Useful for certain filter implementations where
|
"""Filter which generates a distortion effect. Useful for certain filter implementations where
|
||||||
distortion is needed.
|
distortion is needed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
@ -374,7 +374,6 @@ class LowPass(Filter):
|
||||||
"""Filter which supresses higher frequencies and allows lower frequencies to pass.
|
"""Filter which supresses higher frequencies and allows lower frequencies to pass.
|
||||||
You can also do this with the Equalizer filter, but this is an easier way to do it.
|
You can also do this with the Equalizer filter, but this is an easier way to do it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *, tag: str, smoothing: float = 20):
|
def __init__(self, *, tag: str, smoothing: float = 20):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ from .exceptions import FilterInvalidArgument, FilterTagAlreadyInUse, FilterTagI
|
||||||
from .filters import Filter
|
from .filters import Filter
|
||||||
from .objects import Track
|
from .objects import Track
|
||||||
from .pool import Node, NodePool
|
from .pool import Node, NodePool
|
||||||
|
from .queue import Queue
|
||||||
|
|
||||||
class Filters:
|
class Filters:
|
||||||
"""Helper class for filters"""
|
"""Helper class for filters"""
|
||||||
|
|
@ -54,6 +55,7 @@ class Filters:
|
||||||
"""Removes all filters from the list"""
|
"""Removes all filters from the list"""
|
||||||
self._filters = []
|
self._filters = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_all_payloads(self):
|
def get_all_payloads(self):
|
||||||
"""Returns a formatted dict of all the filter payloads"""
|
"""Returns a formatted dict of all the filter payloads"""
|
||||||
|
|
@ -373,7 +375,7 @@ class Player(VoiceProtocol):
|
||||||
self._volume = volume
|
self._volume = volume
|
||||||
return self._volume
|
return self._volume
|
||||||
|
|
||||||
async def add_filter(self, filter: Filter, fast_apply=False) -> Filter:
|
async def add_filter(self, filter: Filter, fast_apply: bool = False) -> Filter:
|
||||||
"""Adds a filter to the player. Takes a pomice.Filter object.
|
"""Adds a filter to the player. Takes a pomice.Filter object.
|
||||||
This will only work if you are using a version of Lavalink that supports filters.
|
This will only work if you are using a version of Lavalink that supports filters.
|
||||||
If you would like for the filter to apply instantly, set the `fast_apply` arg to `True`.
|
If you would like for the filter to apply instantly, set the `fast_apply` arg to `True`.
|
||||||
|
|
@ -389,7 +391,7 @@ class Player(VoiceProtocol):
|
||||||
|
|
||||||
return self._filters
|
return self._filters
|
||||||
|
|
||||||
async def remove_filter(self, filter_tag: str, fast_apply=False) -> Filter:
|
async def remove_filter(self, filter_tag: str, fast_apply: bool = False) -> Filter:
|
||||||
"""Removes a filter from the player. Takes a filter tag.
|
"""Removes a filter from the player. Takes a filter tag.
|
||||||
This will only work if you are using a version of Lavalink that supports filters.
|
This will only work if you are using a version of Lavalink that supports filters.
|
||||||
If you would like for the filter to apply instantly, set the `fast_apply` arg to `True`.
|
If you would like for the filter to apply instantly, set the `fast_apply` arg to `True`.
|
||||||
|
|
@ -405,7 +407,7 @@ class Player(VoiceProtocol):
|
||||||
|
|
||||||
return self._filters
|
return self._filters
|
||||||
|
|
||||||
async def reset_filters(self, *, fast_apply=False):
|
async def reset_filters(self, *, fast_apply: bool = False):
|
||||||
"""Resets all currently applied filters to their default parameters.
|
"""Resets all currently applied filters to their default parameters.
|
||||||
You must have filters applied in order for this to work.
|
You must have filters applied in order for this to work.
|
||||||
If you would like the filters to be removed instantly, set the `fast_apply` arg to `True`.
|
If you would like the filters to be removed instantly, set the `fast_apply` arg to `True`.
|
||||||
|
|
@ -419,6 +421,8 @@ class Player(VoiceProtocol):
|
||||||
)
|
)
|
||||||
self._filters.reset_filters()
|
self._filters.reset_filters()
|
||||||
await self._node.send(op="filters", guildId=str(self.guild.id))
|
await self._node.send(op="filters", guildId=str(self.guild.id))
|
||||||
|
|
||||||
|
|
||||||
if fast_apply:
|
if fast_apply:
|
||||||
await self.seek(self.position)
|
await self.seek(self.position)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ from .exceptions import QueueEmpty, QueueException, QueueFull
|
||||||
|
|
||||||
|
|
||||||
class Queue(Iterable[Track]):
|
class Queue(Iterable[Track]):
|
||||||
|
"""Queue for Pomice. This queue takes pomice.Track as an input and includes looping and shuffling."""
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
max_size: Optional[int] = None,
|
max_size: Optional[int] = None,
|
||||||
|
|
@ -24,7 +25,7 @@ class Queue(Iterable[Track]):
|
||||||
overflow: bool = True,
|
overflow: bool = True,
|
||||||
):
|
):
|
||||||
self.max_size: Optional[int] = max_size
|
self.max_size: Optional[int] = max_size
|
||||||
self._queue = [] # type: ignore
|
self._queue: List[Track] = [] # type: ignore
|
||||||
self._overflow: bool = overflow
|
self._overflow: bool = overflow
|
||||||
self._loop_mode: Optional[LoopMode] = None
|
self._loop_mode: Optional[LoopMode] = None
|
||||||
self._current_item: Optional[Track] = None
|
self._current_item: Optional[Track] = None
|
||||||
|
|
@ -331,4 +332,9 @@ class Queue(Iterable[Track]):
|
||||||
|
|
||||||
def shuffle(self):
|
def shuffle(self):
|
||||||
"""Shuffles the queue."""
|
"""Shuffles the queue."""
|
||||||
return random.shuffle(self._queue)
|
return random.shuffle(self._queue)
|
||||||
|
|
||||||
|
def clear_track_filters(self):
|
||||||
|
"""Clears all filters applied to tracks"""
|
||||||
|
for track in self._queue:
|
||||||
|
track.filters = None
|
||||||
Loading…
Reference in New Issue