-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving estimate_filter_length into datasets module (#90)
- Loading branch information
Showing
3 changed files
with
32 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import numpy as np | ||
|
||
|
||
def estimate_filter_length( | ||
transition_bandwidth: float, attenuation_db: int = 72, sample_rate: float = 1.0 | ||
) -> int: | ||
# estimate the length of an FIR filter using harris' approximaion, | ||
# N ~= (sampling rate/transition bandwidth)*(sidelobe attenuation in dB / 22) | ||
# fred harris, Multirate Signal Processing for Communication Systems, | ||
# Second Edition, p.59 | ||
filter_length = int( | ||
np.round((sample_rate / transition_bandwidth) * (attenuation_db / 22)) | ||
) | ||
|
||
# odd-length filters are desirable because they do not introduce a half-sample delay | ||
if np.mod(filter_length, 2) == 0: | ||
filter_length += 1 | ||
|
||
return filter_length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters