Skip to content

Commit 726bb24

Browse files
mcabbottMichael Abbott
andauthored
Fix #39 (#40)
* define some functions once * rm eval * v0.3.1 Co-authored-by: Michael Abbott <me@escbook>
1 parent 053bbd0 commit 726bb24

File tree

2 files changed

+45
-55
lines changed

2 files changed

+45
-55
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "AppleAccelerate"
22
uuid = "13e28ba4-7ad8-5781-acae-3021b1ed3924"
3-
version = "0.3.0"
3+
version = "0.3.1"
44

55
[compat]
66
julia = "≥ 1.0.0"

src/DSP.jl

Lines changed: 44 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ end
2424

2525
## === FUNCTIONS == ##
2626

27-
## === FUNCTIONS == ##
2827
for (T, suff) in ((Float64, "D"), (Float32, ""))
2928

3029
"""
@@ -198,6 +197,50 @@ for (T, suff) in ((Float64, "D"), )
198197
end
199198

200199
## == WINDOW GENERATION == ##
200+
201+
"""
202+
blackman(length, [rtype=Float64])
203+
204+
Generates a Blackman window of length 'length'. Default return type
205+
is Vector{Float64}, but if rtype=Float32, Vector{Float32}
206+
will be returned.
207+
"""
208+
function blackman(length::Int, rtype::DataType=Float64)
209+
result::Vector{rtype} = Array{rtype}(undef, length)
210+
blackman!(result, length, 0)
211+
end
212+
213+
"""
214+
hamming(length, [rtype=Float64])
215+
216+
Generates a Hamming window of length 'length'. Default return type
217+
is Vector{Float64}, but if rtype=Float32, Vector{Float32}
218+
will be returned.
219+
"""
220+
function hamming(length::Int, rtype::DataType=Float64)
221+
result::Vector{rtype} = Array{rtype}(undef, length)
222+
hamming!(result, length, 0)
223+
end
224+
225+
"""
226+
hanning(length, [rtype=Float64])
227+
228+
Generates a denormalized Hanning window of length 'length'. Default
229+
return type is Vector{Float64}, but if rtype=Float32, Vector{Float32}
230+
will be returned.
231+
"""
232+
function hanning(length::Int, rtype::DataType=Float64)
233+
result::Vector{rtype} = Array{rtype}(undef, length)
234+
hanning!(result, length, 0)
235+
end
236+
237+
"""
238+
Alias function for `hanning`
239+
"""
240+
function hann(length::Int, rtype::DataType=Float64)
241+
hanning(length, rtype)
242+
end
243+
201244
for (T, suff) in ((Float32, ""), (Float64, "D"))
202245

203246
"""
@@ -216,19 +259,6 @@ for (T, suff) in ((Float32, ""), (Float64, "D"))
216259
end
217260
end
218261

219-
"""
220-
Generates a Blackman window of length 'length'. Default return type
221-
is Vector{Float64}, but if rtype=Float32, Vector{Float32}
222-
will be returned.
223-
224-
Returns: Vector{$T}
225-
"""
226-
@eval begin
227-
function blackman(length::Int, rtype::DataType=Float64)
228-
result::Vector{rtype} = Array{rtype}(undef, length)
229-
blackman!(result, length, 0)
230-
end
231-
end
232262

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

249-
"""
250-
Generates a Hamming window of length 'length'. Default return type
251-
is Vector{Float64}, but if rtype=Float32, Vector{Float32}
252-
will be returned.
253-
254-
Returns: Vector{$T}
255-
"""
256-
@eval begin
257-
function hamming(length::Int, rtype::DataType=Float64)
258-
result::Vector{rtype} = Array{rtype}(undef, length)
259-
hamming!(result, length, 0)
260-
end
261-
end
262-
263-
264279
"""
265280
Generates a Hanning window of length 'length' and stores it in `result'.
266281
Different window options can be set using the flag argument; default value
@@ -282,20 +297,6 @@ for (T, suff) in ((Float32, ""), (Float64, "D"))
282297
end
283298
end
284299

285-
"""
286-
Generates a denormalized Hanning window of length 'length'. Default
287-
return type is Vector{Float64}, but if rtype=Float32, Vector{Float32}
288-
will be returned.
289-
290-
Returns: Vector{$T}
291-
"""
292-
@eval begin
293-
function hanning(length::Int, rtype::DataType=Float64)
294-
result::Vector{rtype} = Array{rtype}(undef, length)
295-
hanning!(result, length, 0)
296-
end
297-
end
298-
299300
"""
300301
Alias function for hanning!
301302
@@ -307,17 +308,6 @@ for (T, suff) in ((Float32, ""), (Float64, "D"))
307308
end
308309
end
309310

310-
"""
311-
Alias function for hanning
312-
313-
Returns: Vector{$T}
314-
"""
315-
@eval begin
316-
function hann(length::Int, rtype::DataType=Float64)
317-
hanning(length, rtype)
318-
end
319-
end
320-
321311
end
322312

323313

0 commit comments

Comments
 (0)