forked from JuliaDSP/DSP.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_winplots.jl
40 lines (34 loc) · 1.15 KB
/
gen_winplots.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# this script is used to generate the ascii plots used in the window docstrings
using UnicodePlots
using DSP
open(joinpath(@__DIR__, "src", "winplots.jl"), "w") do io
println(io, """
#####################################################
# THIS FILE IS AUTO-GENERATED
# to re-generate use the `gen_winplots.jl` script
#####################################################
""")
for (winfunc, args) in [
(rect, ()),
(hanning, ()),
(hamming, ()),
(tukey, (0.4)),
(cosine, ()),
(lanczos, ()),
(triang, ()),
(bartlett, ()),
(gaussian, (0.2)),
(bartlett_hann, ()),
(blackman, ()),
(kaiser, (3)),
(dpss, (2, 1)),
]
ymax = winfunc == dpss ? 0.2 : 1.0
n = winfunc == triang ? 7 : 69
fname = split(string(winfunc), ".")[end]
println(io, "const $(fname)_winplot = padplot(\"\"\"")
# convert Nx1 matrices to vectors with [:] - necessary for dpss
print(io, lineplot(winfunc(n, args...)[:], ylim=[0,ymax], xlim=[1,n], width=70, canvas=BlockCanvas))
println(io, "\"\"\")\n")
end
end