Skip to content

Commit 02aa9c7

Browse files
authored
Fix range calculation for 'n' in delay filter
Updated calculation of 'n' to ensure proper range for fractional delay filter.
1 parent b92dc73 commit 02aa9c7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

content/sync.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ We can easily simulate a delay by shifting samples, but it only simulates a dela
7373
7474
# Create and apply fractional delay filter
7575
delay = 0.4 # fractional delay, in samples
76-
N = 21 # number of taps
77-
n = np.arange(-N//2, N//2) # ...-3,-2,-1,0,1,2,3...
76+
N = 21 # number of taps, keep this odd
77+
n = np.arange(-(N-1)//2, N//2+1) # -10,-9,...,0,...,9,10
7878
h = np.sinc(n - delay) # calc filter taps
7979
h *= np.hamming(N) # window the filter to make sure it decays to 0 on both sides
8080
h /= np.sum(h) # normalize to get unity gain, we don't want to change the amplitude/power

0 commit comments

Comments
 (0)