@@ -17,6 +17,7 @@ export rect,
1717 bartlett_hann,
1818 blackman,
1919 blackmanharris,
20+ nuttall,
2021 kaiser,
2122 flattop,
2223 dpss,
@@ -514,6 +515,57 @@ function blackmanharris(n::Integer; term::Integer=4, padding::Integer=0, zeropha
514515 end
515516end
516517
518+ """
519+ $nuttall_winplot
520+
521+ nuttall(n::Integer; term::Integer=4, padding::Integer=0, zerophase::Bool=false)
522+ nuttall(dims; term::Integer=4, padding=0, zerophase=false)
523+
524+ Nuttall window of length `n` with `padding` zeros. These windows can be seen as
525+ the improved version of the Blackman-Harris windows with regard to maximum
526+ sidelobe level. The number of terms can be selected with `term` ∈ [3,4]. For
527+ `term = 3`, the maximum sidelobe level is about -71.48 dB, while for `term = 4`
528+ (the default), it improves to -98.17 dB.
529+
530+ The 3-term window `w3(x)` and the 4-term window `w4(x)` are defined by sampling
531+ the following continuous functions in the range `[-0.5, 0.5]`:
532+
533+ w3(x) = 0.4243801 + 0.4973406*cos(2π*x) + 0.0782793*cos(4π*x)
534+
535+ w4(x) = 0.3635819 + 0.4891775*cos(2π*x) + 0.1365995*cos(4π*x) + 0.0106411*cos(6π*x)
536+
537+ For more details see [Nuttall, A. H. (1981). Some windows with very good
538+ sidelobe behavior. IEEE Transactions on Acoustics, Speech, Signal Processing,
539+ 29, 84-91](https://ieeexplore.ieee.org/document/1163506)
540+
541+ The `nuttall` windows do not generally satisfy the Constant Overlap-Add
542+ (COLA) property. Nevertheless, when using `zerophase = true` and implementing the
543+ following boundary conditions they approximately do:
544+ - For the 3-term window the overlap should be 66% and the window length should
545+ be a multiple of 3.
546+ - For the 4-term window the overlap should be 75% and the window length should
547+ be a multiple of 4.
548+
549+ $(twoD_docs ())
550+
551+ $zerophase_docs
552+ """
553+ function nuttall (n:: Integer ; term:: Integer = 4 , padding:: Integer = 0 , zerophase:: Bool = false )
554+ if term == 4
555+ a0, a1, a2, a3 = 0.3635819 , 0.4891775 , 0.1365995 , 0.0106411
556+ makewindow (n, padding, zerophase) do x
557+ muladd (a1, cospi (2 x), muladd (a2, cospi (4 x), muladd (a3, cospi (6 x), a0)))
558+ end
559+ elseif term == 3
560+ a0, a1, a2 = 0.4243801 , 0.4973406 , 0.0782793
561+ makewindow (n, padding, zerophase) do x
562+ muladd (a1, cospi (2 x), muladd (a2, cospi (4 x), a0))
563+ end
564+ else
565+ throw (ArgumentError (" `term` must be either 3 or 4" ))
566+ end
567+ end
568+
517569"""
518570$kaiser_winplot
519571
@@ -745,7 +797,7 @@ function matrix_window(func::F, dims::Tuple{Integer,Integer}, arg::Union{RealOr2
745797end
746798
747799for func in (:rect , :hanning , :hamming , :cosine , :lanczos ,
748- :triang , :bartlett , :bartlett_hann , :blackman , :blackmanharris , :flattop )
800+ :triang , :bartlett , :bartlett_hann , :blackman , :blackmanharris , :nuttall , : flattop )
749801 @eval function $func (dims:: Tuple{Integer,Integer} ; padding:: IntegerOr2 = 0 , zerophase:: BoolOr2 = false )
750802 return matrix_window ($ func, dims; padding, zerophase)
751803 end
0 commit comments