Skip to content

Commit 1dd6c07

Browse files
authored
Refactor FilterType class and improve type hints
Updated type hints for inputs list and removed unused imports.
1 parent 574d100 commit 1dd6c07

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎audio_filters/show_response.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
https://en.wikipedia.org/wiki/Frequency_response
55
"""
66

7-
from __future__ import annotations
8-
9-
from abc import abstractmethod
10-
from math import pi
11-
from typing import Protocol
7+
class FilterType(Protocol):
8+
def process(self, sample: float) -> float:
9+
"""
10+
Calculate y[n]
1211
13-
import matplotlib.pyplot as plt
14-
import numpy as np
12+
>>> issubclass(FilterType, Protocol)
13+
True
14+
"""
1515

1616

1717
class FilterType(Protocol):
@@ -51,7 +51,7 @@ def show_frequency_response(filter_type: FilterType, samplerate: int) -> None:
5151
"""
5252

5353
size = 512
54-
inputs = [1] + [0] * (size - 1)
54+
inputs: list[float] = [1.0] + [0.0] * (size - 1)
5555
outputs = [filter_type.process(item) for item in inputs]
5656

5757
filler = [0] * (samplerate - size) # zero-padding

0 commit comments

Comments
 (0)