code cleanup
This commit is contained in:
parent
8d50cb9c28
commit
46f1aaa698
|
|
@ -21,15 +21,16 @@ class Equalizer:
|
||||||
self.eq = self._factory(self, levels)
|
self.eq = self._factory(self, levels)
|
||||||
self.raw = levels
|
self.raw = levels
|
||||||
|
|
||||||
self.payload = {'equalizer': {'bands': self.eq}}
|
|
||||||
|
|
||||||
self.payload = {"equalizer": {"bands": self.eq}}
|
self.payload = {"equalizer": {"bands": self.eq}}
|
||||||
|
|
||||||
def _factory(self, levels: list):
|
def _factory(self, levels: list):
|
||||||
_dict = collections.defaultdict(int)
|
_dict = collections.defaultdict(int)
|
||||||
|
|
||||||
_dict.update(levels)
|
_dict.update(levels)
|
||||||
_dict = [{"band": i, "gain": _dict[i]} for i in range(15)]
|
_dict = [{"band": i, "gain": _dict[i]} for i in range(15)]
|
||||||
|
|
||||||
return _dict
|
return _dict
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"<Pomice.EqualizerFilter eq={self.eq} raw={self.raw}>"
|
return f"<Pomice.EqualizerFilter eq={self.eq} raw={self.raw}>"
|
||||||
|
|
||||||
|
|
@ -38,23 +39,29 @@ class Timescale(Filter):
|
||||||
"""Filter which changes the speed and pitch of a track.
|
"""Filter which changes the speed and pitch of a track.
|
||||||
Do be warned that this filter is bugged as of the lastest Lavalink dev version
|
Do be warned that this filter is bugged as of the lastest Lavalink dev version
|
||||||
due to the filter patch not corresponding with the track time.
|
due to the filter patch not corresponding with the track time.
|
||||||
|
|
||||||
In short this means that your track will either end prematurely or end later due to this.
|
In short this means that your track will either end prematurely or end later due to this.
|
||||||
This is not the library's fault.
|
This is not the library's fault.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *, speed: float = 1.0, pitch: float = 1.0, rate: float = 1.0):
|
def __init__(self, *, speed: float = 1.0, pitch: float = 1.0, rate: float = 1.0):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
if speed < 0:
|
if speed < 0:
|
||||||
raise FilterInvalidArgument("Timescale speed must be more than 0.")
|
raise FilterInvalidArgument("Timescale speed must be more than 0.")
|
||||||
if pitch < 0:
|
if pitch < 0:
|
||||||
raise FilterInvalidArgument("Timescale pitch must be more than 0.")
|
raise FilterInvalidArgument("Timescale pitch must be more than 0.")
|
||||||
if rate < 0:
|
if rate < 0:
|
||||||
raise FilterInvalidArgument("Timescale rate must be more than 0.")
|
raise FilterInvalidArgument("Timescale rate must be more than 0.")
|
||||||
|
|
||||||
self.speed = speed
|
self.speed = speed
|
||||||
self.pitch = pitch
|
self.pitch = pitch
|
||||||
self.rate = rate
|
self.rate = rate
|
||||||
|
|
||||||
self.payload = {"timescale": {"speed": self.speed,
|
self.payload = {"timescale": {"speed": self.speed,
|
||||||
"pitch": self.pitch,
|
"pitch": self.pitch,
|
||||||
"rate": self.rate}}
|
"rate": self.rate}}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Pomice.TimescaleFilter speed={self.speed} pitch={self.pitch} rate={self.rate}>"
|
return f"<Pomice.TimescaleFilter speed={self.speed} pitch={self.pitch} rate={self.rate}>"
|
||||||
|
|
||||||
|
|
@ -63,6 +70,7 @@ class Karaoke(Filter):
|
||||||
"""Filter which filters the vocal track from any song and leaves the instrumental.
|
"""Filter which filters the vocal track from any song and leaves the instrumental.
|
||||||
Best for karaoke as the filter implies.
|
Best for karaoke as the filter implies.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
|
|
@ -72,14 +80,17 @@ class Karaoke(Filter):
|
||||||
filter_width: float
|
filter_width: float
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.level = level
|
self.level = level
|
||||||
self.mono_level = mono_level
|
self.mono_level = mono_level
|
||||||
self.filter_band = filter_band
|
self.filter_band = filter_band
|
||||||
self.filter_width = filter_width
|
self.filter_width = filter_width
|
||||||
|
|
||||||
self.payload = {"karaoke": {"level": self.level,
|
self.payload = {"karaoke": {"level": self.level,
|
||||||
"monoLevel": self.mono_level,
|
"monoLevel": self.mono_level,
|
||||||
"filterBand": self.filter_band,
|
"filterBand": self.filter_band,
|
||||||
"filterWidth": self.filter_width}}
|
"filterWidth": self.filter_width}}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return (
|
return (
|
||||||
f"<Pomice.KaraokeFilter level={self.level} mono_level={self.mono_level} "
|
f"<Pomice.KaraokeFilter level={self.level} mono_level={self.mono_level} "
|
||||||
|
|
@ -91,18 +102,23 @@ class Tremolo(Filter):
|
||||||
"""Filter which produces a wavering tone in the music,
|
"""Filter which produces a wavering tone in the music,
|
||||||
causing it to sound like the music is changing in volume rapidly.
|
causing it to sound like the music is changing in volume rapidly.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *, frequency: float, depth: float):
|
def __init__(self, *, frequency: float, depth: float):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
if frequency < 0:
|
if frequency < 0:
|
||||||
raise FilterInvalidArgument(
|
raise FilterInvalidArgument(
|
||||||
"Tremolo frequency must be more than 0.")
|
"Tremolo frequency must be more than 0.")
|
||||||
if depth < 0 or depth > 1:
|
if depth < 0 or depth > 1:
|
||||||
raise FilterInvalidArgument(
|
raise FilterInvalidArgument(
|
||||||
"Tremolo depth must be between 0 and 1.")
|
"Tremolo depth must be between 0 and 1.")
|
||||||
|
|
||||||
self.frequency = frequency
|
self.frequency = frequency
|
||||||
self.depth = depth
|
self.depth = depth
|
||||||
|
|
||||||
self.payload = {"tremolo": {"frequency": self.frequency,
|
self.payload = {"tremolo": {"frequency": self.frequency,
|
||||||
"depth": self.depth}}
|
"depth": self.depth}}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Pomice.TremoloFilter frequency={self.frequency} depth={self.depth}>"
|
return f"<Pomice.TremoloFilter frequency={self.frequency} depth={self.depth}>"
|
||||||
|
|
||||||
|
|
@ -111,7 +127,9 @@ class Vibrato(Filter):
|
||||||
"""Filter which produces a wavering tone in the music, similar to the Tremolo filter,
|
"""Filter which produces a wavering tone in the music, similar to the Tremolo filter,
|
||||||
but changes in pitch rather than volume.
|
but changes in pitch rather than volume.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *, frequency: float, depth: float):
|
def __init__(self, *, frequency: float, depth: float):
|
||||||
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
if frequency < 0 or frequency > 14:
|
if frequency < 0 or frequency > 14:
|
||||||
raise FilterInvalidArgument(
|
raise FilterInvalidArgument(
|
||||||
|
|
@ -119,9 +137,12 @@ class Vibrato(Filter):
|
||||||
if depth < 0 or depth > 1:
|
if depth < 0 or depth > 1:
|
||||||
raise FilterInvalidArgument(
|
raise FilterInvalidArgument(
|
||||||
"Vibrato depth must be between 0 and 1.")
|
"Vibrato depth must be between 0 and 1.")
|
||||||
|
|
||||||
self.frequency = frequency
|
self.frequency = frequency
|
||||||
self.depth = depth
|
self.depth = depth
|
||||||
|
|
||||||
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 frequency={self.frequency} depth={self.depth}>"
|
return f"<Pomice.VibratoFilter frequency={self.frequency} depth={self.depth}>"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue