mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-01 11:26:43 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
cd66f4f532
commit
28edd2bdd7
@ -33,8 +33,6 @@ class EMAFilter:
|
|||||||
self.alpha = alpha
|
self.alpha = alpha
|
||||||
self.ema_value = 0.0
|
self.ema_value = 0.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def apply(self, audio_signal: list[float]) -> np.ndarray:
|
def apply(self, audio_signal: list[float]) -> np.ndarray:
|
||||||
"""
|
"""
|
||||||
Apply the EMA filter to a sequence of
|
Apply the EMA filter to a sequence of
|
||||||
@ -56,11 +54,11 @@ class EMAFilter:
|
|||||||
"""
|
"""
|
||||||
if not audio_signal:
|
if not audio_signal:
|
||||||
return np.array([])
|
return np.array([])
|
||||||
|
|
||||||
ema_signal: list[float] = []
|
ema_signal: list[float] = []
|
||||||
self.ema_value = audio_signal[0]
|
self.ema_value = audio_signal[0]
|
||||||
ema_signal.append(self.ema_value)
|
ema_signal.append(self.ema_value)
|
||||||
|
|
||||||
for sample in audio_signal[1:]:
|
for sample in audio_signal[1:]:
|
||||||
if self.ema_value is None:
|
if self.ema_value is None:
|
||||||
self.ema_value = self.alpha * sample + (1 - self.alpha) * self.ema_value
|
self.ema_value = self.alpha * sample + (1 - self.alpha) * self.ema_value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user