mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-22 02:37:57 -05:00
Merge V3/feature/audio into V3/develop (a.k.a. audio refactor) (#3459)
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
# The equalizer class and some audio eq functions are derived from
|
||||
# 180093157554388993's work, with his permission
|
||||
from typing import Final
|
||||
|
||||
|
||||
class Equalizer:
|
||||
def __init__(self):
|
||||
self._band_count = 15
|
||||
self.bands = [0.0 for _loop_counter in range(self._band_count)]
|
||||
self.band_count: Final[int] = 15
|
||||
self.bands = [0.0 for _loop_counter in range(self.band_count)]
|
||||
|
||||
def set_gain(self, band: int, gain: float):
|
||||
if band < 0 or band >= self._band_count:
|
||||
if band < 0 or band >= self.band_count:
|
||||
raise IndexError(f"Band {band} does not exist!")
|
||||
|
||||
gain = min(max(gain, -0.25), 1.0)
|
||||
@@ -16,13 +17,13 @@ class Equalizer:
|
||||
self.bands[band] = gain
|
||||
|
||||
def get_gain(self, band: int):
|
||||
if band < 0 or band >= self._band_count:
|
||||
if band < 0 or band >= self.band_count:
|
||||
raise IndexError(f"Band {band} does not exist!")
|
||||
return self.bands[band]
|
||||
|
||||
def visualise(self):
|
||||
block = ""
|
||||
bands = [str(band + 1).zfill(2) for band in range(self._band_count)]
|
||||
bands = [str(band + 1).zfill(2) for band in range(self.band_count)]
|
||||
bottom = (" " * 8) + " ".join(bands)
|
||||
gains = [1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.0, -0.1, -0.2, -0.25]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user