diff --git a/pomice/filters.py b/pomice/filters.py index 5ce33df..fbd0bea 100644 --- a/pomice/filters.py +++ b/pomice/filters.py @@ -43,7 +43,63 @@ class Equalizer(Filter): return _dict def __repr__(self) -> str: - return f"" + return f"" + + @classmethod + def flat(cls): + """Equalizer preset which represents a flat EQ board, + with all levels set to their default values. + """ + + levels = [ + (0, 0.0), (1, 0.0), (2, 0.0), (3, 0.0), (4, 0.0), + (5, 0.0), (6, 0.0), (7, 0.0), (8, 0.0), (9, 0.0), + (10, 0.0), (11, 0.0), (12, 0.0), (13, 0.0), (14, 0.0) + ] + return cls(tag="flat", levels=levels) + + @classmethod + def boost(cls): + """Equalizer preset which boosts the sound of a track, + making it sound fun and energetic by increasing the bass + and the highs. + """ + + levels = [ + (0, -0.075), (1, 0.125), (2, 0.125), (3, 0.1), (4, 0.1), + (5, .05), (6, 0.075), (7, 0.0), (8, 0.0), (9, 0.0), + (10, 0.0), (11, 0.0), (12, 0.125), (13, 0.15), (14, 0.05) + ] + return cls(tag="boost", levels=levels) + + @classmethod + def metal(cls): + """Equalizer preset which increases the mids of a track, + preferably one of the metal genre, to make it sound + more full and concert-like. + """ + + levels = [ + (0, 0.0), (1, 0.1), (2, 0.1), (3, 0.15), (4, 0.13), + (5, 0.1), (6, 0.0), (7, 0.125), (8, 0.175), (9, 0.175), + (10, 0.125), (11, 0.125), (12, 0.1), (13, 0.075), (14, 0.0) + ] + + return cls(tag="metal", levels=levels) + + @classmethod + def piano(cls): + """Equalizer preset which increases the mids and highs + of a track, preferably a piano based one, to make it + stand out. + """ + + levels = [ + (0, -0.25), (1, -0.25), (2, -0.125), (3, 0.0), + (4, 0.25), (5, 0.25), (6, 0.0), (7, -0.25), (8, -0.25), + (9, 0.0), (10, 0.0), (11, 0.5), (12, 0.25), (13, -0.025) + ] + return cls(tag="piano", levels=levels) class Timescale(Filter): @@ -79,8 +135,28 @@ class Timescale(Filter): "pitch": self.pitch, "rate": self.rate}} + @classmethod + def vaporwave(cls): + """Timescale preset which slows down the currently playing track, + giving it the effect of a half-speed record/casette playing. + + This preset will assign the tag 'vaporwave'. + """ + + return cls(tag="vaporwave", speed=0.8, pitch=0.8) + + @classmethod + def nightcore(cls): + """Timescale preset which speeds up the currently playing track, + which matches up to nightcore, a genre of sped-up music + + This preset will assign the tag 'nightcore'. + """ + + return cls(tag="nightcore", speed=1.25, pitch=1.3) + def __repr__(self): - return f"" + return f"" class Karaoke(Filter): @@ -112,7 +188,7 @@ class Karaoke(Filter): def __repr__(self): return ( - f"" ) @@ -146,7 +222,7 @@ class Tremolo(Filter): "depth": self.depth}} def __repr__(self): - return f"" + return f"" class Vibrato(Filter): @@ -178,7 +254,7 @@ class Vibrato(Filter): "depth": self.depth}} def __repr__(self): - return f"" + return f"" class Rotation(Filter): @@ -194,7 +270,7 @@ class Rotation(Filter): self.payload = {"rotation": {"rotationHz": self.rotation_hertz}} def __repr__(self) -> str: - return f"" + return f"" class ChannelMix(Filter): @@ -241,7 +317,7 @@ class ChannelMix(Filter): def __repr__(self) -> str: return ( - f"" ) @@ -288,7 +364,7 @@ class Distortion(Filter): def __repr__(self) -> str: return ( - f" " + f" " f"cos_offset={self.cos_offset} cos_scale={self.cos_scale} tan_offset={self.tan_offset} " f"tan_scale={self.tan_scale} offset={self.offset} scale={self.scale}" ) @@ -307,6 +383,6 @@ class LowPass(Filter): self.payload = {"lowPass": {"smoothing": self.smoothing}} def __repr__(self) -> str: - return f"" + return f"" diff --git a/pomice/player.py b/pomice/player.py index cff48bc..5cf38b7 100644 --- a/pomice/player.py +++ b/pomice/player.py @@ -294,6 +294,9 @@ class Player(VoiceProtocol): if track.spotify: # First lets try using the tracks ISRC, every track has one (hopefully) try: + if not track.isrc: + # We have to bare raise here because theres no other way to skip this block feasibly + raise search: Track = (await self._node.get_tracks( f"{track._search_type}:{track.isrc}", ctx=track.ctx))[0] except: diff --git a/pomice/spotify/objects.py b/pomice/spotify/objects.py index 0492ec2..b52b4d5 100644 --- a/pomice/spotify/objects.py +++ b/pomice/spotify/objects.py @@ -9,7 +9,11 @@ class Track: self.artists = ", ".join(artist["name"] for artist in data["artists"]) self.length = data["duration_ms"] self.id = data["id"] - self.isrc = data["external_ids"]["isrc"] + + if data.get("external_ids"): + self.isrc = data["external_ids"]["isrc"] + else: + self.isrc = None if data.get("album") and data["album"].get("images"): self.image = data["album"]["images"][0]["url"]