Merge V3/feature/audio into V3/develop (a.k.a. audio refactor) (#3459)

This commit is contained in:
Draper
2020-05-20 21:30:06 +01:00
committed by GitHub
parent ef76affd77
commit 8fa47cb789
53 changed files with 12372 additions and 10144 deletions

View File

@@ -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]