remove some unused function and some formatting cleanup#1045
Merged
Conversation
eshaz
reviewed
Jun 3, 2026
| # standard numeric/scientific libraries | ||
| import numpy as np | ||
| import scipy.signal as sps | ||
| from scipy.special import i0 |
Contributor
There was a problem hiding this comment.
This will be needed if the sinc lut ever needs to be regenerated.
Contributor
Author
There was a problem hiding this comment.
Might make sense to move it to where the sinc lut functions are since it's tied to those
Comment on lines
+76
to
+124
| # kaiser_beta = 5 | ||
| sinc_tap_count = 16 # must be multiple of 2 | ||
| sinc_phase_count = 2**16 | ||
|
|
||
| @njit | ||
| def sinc(x): | ||
| if x == 0.0: | ||
| return 1.0 | ||
| x_pi = np.pi * x | ||
| return math.sin(x_pi) / x_pi | ||
| # @njit | ||
| # def sinc(x): | ||
| # if x == 0.0: | ||
| # return 1.0 | ||
| # x_pi = np.pi * x | ||
| # return math.sin(x_pi) / x_pi | ||
|
|
||
|
|
||
| def kaiser_window(x, a, beta, i0_beta): | ||
| r = x / a | ||
| if r < -1.0 or r > 1.0: | ||
| return 0.0 | ||
|
|
||
| t = math.sqrt(1.0 - r * r) | ||
| return i0(beta * t) / i0_beta | ||
| # def kaiser_window(x, a, beta, i0_beta): | ||
| # r = x / a | ||
| # if r < -1.0 or r > 1.0: | ||
| # return 0.0 | ||
| # | ||
| # t = math.sqrt(1.0 - r * r) | ||
| # return i0(beta * t) / i0_beta | ||
|
|
||
|
|
||
| # https://ccrma.stanford.edu/~jos/sasp/Kaiser_Windows_Transforms.html | ||
| def build_kaiser_lut(beta, taps, phases): | ||
| a = taps // 2 | ||
|
|
||
| offsets = np.arange(a - 1, -a - 1, -1) | ||
| offsets_len = len(offsets) | ||
|
|
||
| table = np.zeros((phases + 1, taps), dtype=np.float32) | ||
| weights = np.empty(offsets_len, dtype=np.float32) | ||
| i0_beta = i0(beta) | ||
|
|
||
| for i in range(phases): | ||
| phase = i / phases | ||
|
|
||
| s = 0.0 | ||
| for j in range(offsets_len): | ||
| x = offsets[j] + phase | ||
| weight = sinc(x) * kaiser_window(x, a, beta, i0_beta) | ||
|
|
||
| weights[j] = weight | ||
| s += weight | ||
|
|
||
| table[i, :] = weights / s | ||
|
|
||
| # copy the last phase to avoid bounds checking later on when we do linear interpolation | ||
| table[phases] = table[phases - 1] | ||
|
|
||
| return table | ||
| # def build_kaiser_lut(beta, taps, phases): | ||
| # a = taps // 2 | ||
| # | ||
| # offsets = np.arange(a - 1, -a - 1, -1) | ||
| # offsets_len = len(offsets) | ||
| # | ||
| # table = np.zeros((phases + 1, taps), dtype=np.float32) | ||
| # weights = np.empty(offsets_len, dtype=np.float32) | ||
| # i0_beta = i0(beta) | ||
| # | ||
| # for i in range(phases): | ||
| # phase = i / phases | ||
| # | ||
| # s = 0.0 | ||
| # for j in range(offsets_len): | ||
| # x = offsets[j] + phase | ||
| # weight = sinc(x) * kaiser_window(x, a, beta, i0_beta) | ||
| # | ||
| # weights[j] = weight | ||
| # s += weight | ||
| # | ||
| # table[i, :] = weights / s | ||
| # | ||
| # # copy the last phase to avoid bounds checking later on when we do linear interpolation | ||
| # table[phases] = table[phases - 1] | ||
| # | ||
| # return table |
Contributor
There was a problem hiding this comment.
Maybe it would make sense to move the sinc lut code into it's own file vs. commenting it out, so it has a better chance of surviving additional cleanup activities.
Contributor
Author
There was a problem hiding this comment.
Yeah wasn't sure how to best handle it
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description
Remove some unused functions and imports and clean up some formatting