Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #39 #40

Merged
merged 3 commits into from
Sep 9, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 44 additions & 54 deletions src/DSP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ end

## === FUNCTIONS == ##

## === FUNCTIONS == ##
for (T, suff) in ((Float64, "D"), (Float32, ""))

"""
Expand Down Expand Up @@ -198,6 +197,50 @@ for (T, suff) in ((Float64, "D"), )
end

## == WINDOW GENERATION == ##

"""
blackman(length, [rtype=Float64])

Generates a Blackman window of length 'length'. Default return type
is Vector{Float64}, but if rtype=Float32, Vector{Float32}
will be returned.
"""
function blackman(length::Int, rtype::DataType=Float64)
result::Vector{rtype} = Array{rtype}(undef, length)
blackman!(result, length, 0)
end

"""
hamming(length, [rtype=Float64])

Generates a Hamming window of length 'length'. Default return type
is Vector{Float64}, but if rtype=Float32, Vector{Float32}
will be returned.
"""
function hamming(length::Int, rtype::DataType=Float64)
result::Vector{rtype} = Array{rtype}(undef, length)
hamming!(result, length, 0)
end

"""
hanning(length, [rtype=Float64])

Generates a denormalized Hanning window of length 'length'. Default
return type is Vector{Float64}, but if rtype=Float32, Vector{Float32}
will be returned.
"""
function hanning(length::Int, rtype::DataType=Float64)
result::Vector{rtype} = Array{rtype}(undef, length)
hanning!(result, length, 0)
end

"""
Alias function for `hanning`
"""
function hann(length::Int, rtype::DataType=Float64)
hanning(length, rtype)
end

for (T, suff) in ((Float32, ""), (Float64, "D"))

"""
Expand All @@ -216,19 +259,6 @@ for (T, suff) in ((Float32, ""), (Float64, "D"))
end
end

"""
Generates a Blackman window of length 'length'. Default return type
is Vector{Float64}, but if rtype=Float32, Vector{Float32}
will be returned.

Returns: Vector{$T}
"""
@eval begin
function blackman(length::Int, rtype::DataType=Float64)
result::Vector{rtype} = Array{rtype}(undef, length)
blackman!(result, length, 0)
end
end

"""
Generates a Hamming window of length 'length' and stores it in `result'. By
Expand All @@ -246,21 +276,6 @@ for (T, suff) in ((Float32, ""), (Float64, "D"))
end
end

"""
Generates a Hamming window of length 'length'. Default return type
is Vector{Float64}, but if rtype=Float32, Vector{Float32}
will be returned.

Returns: Vector{$T}
"""
@eval begin
function hamming(length::Int, rtype::DataType=Float64)
result::Vector{rtype} = Array{rtype}(undef, length)
hamming!(result, length, 0)
end
end


"""
Generates a Hanning window of length 'length' and stores it in `result'.
Different window options can be set using the flag argument; default value
Expand All @@ -282,20 +297,6 @@ for (T, suff) in ((Float32, ""), (Float64, "D"))
end
end

"""
Generates a denormalized Hanning window of length 'length'. Default
return type is Vector{Float64}, but if rtype=Float32, Vector{Float32}
will be returned.

Returns: Vector{$T}
"""
@eval begin
function hanning(length::Int, rtype::DataType=Float64)
result::Vector{rtype} = Array{rtype}(undef, length)
hanning!(result, length, 0)
end
end

"""
Alias function for hanning!

Expand All @@ -307,17 +308,6 @@ for (T, suff) in ((Float32, ""), (Float64, "D"))
end
end

"""
Alias function for hanning

Returns: Vector{$T}
"""
@eval begin
function hann(length::Int, rtype::DataType=Float64)
hanning(length, rtype)
end
end

end


Expand Down